summaryrefslogtreecommitdiff
path: root/tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2024-03-07 06:41:07 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-03-07 06:41:07 +0000
commit17dabff1dd38e8f0e08736176a8a587e039e610a (patch)
treebd40604eb4b00a1a0e63edfe28cb0ebe33f23029 /tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt
parentded14cc2110e39408f74abac8a83e0a0f16608d2 (diff)
parent7e8ae158f4a73ee580c468d71ca9a1df6f90a8cd (diff)
downloadLauncher3-17dabff1dd38e8f0e08736176a8a587e039e610a.tar.gz
Merge "Merge Android 14 QPR2 to AOSP main" into main
Diffstat (limited to 'tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt')
-rw-r--r--tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt b/tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt
new file mode 100644
index 0000000000..da4de7ddf2
--- /dev/null
+++ b/tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.celllayout.testgenerator
+
+import android.graphics.Rect
+import com.android.launcher3.celllayout.board.CellLayoutBoard
+import java.util.Random
+
+class RandomMultiBoardGenerator(generator: Random) : RandomBoardGenerator(generator) {
+ override fun generateBoard(
+ width: Int,
+ height: Int,
+ remainingEmptySpaces: Int
+ ): CellLayoutBoard {
+ val cellLayoutBoard = CellLayoutBoard(width, height)
+ fillBoard(cellLayoutBoard, Rect(0, 0, width / 2, height), remainingEmptySpaces / 2)
+ return fillBoard(
+ cellLayoutBoard,
+ Rect(width / 2, 0, width, height),
+ remainingEmptySpaces / 2
+ )
+ }
+}