From e7c3d3d4cee3a58df3d1aa96e6ab280244a4c6fb Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Tue, 10 Jan 2023 10:47:46 -0600 Subject: [PATCH] Parsing test boards from text files to be able to add more and bigger tests It also adds an assets folder inside of Launcher3 tests. It also fixes a bug in fullReorder. Test: atest ReorderWidgets Flag: none Bug: 229292911 Change-Id: I7dadd42a3057d353326691163bb7db71a2e9dcc4 --- tests/Android.bp | 1 + tests/assets/ReorderWidgets/full_reorder_case | 28 +++ .../ReorderWidgets/move_out_reorder_case | 44 +++++ tests/assets/ReorderWidgets/push_reorder_case | 44 +++++ .../assets/ReorderWidgets/simple_reorder_case | 56 ++++++ tests/res/raw/reorder_algorithm_test.txt | 9 + .../launcher3/celllayout/CellLayoutBoard.java | 11 +- .../celllayout/CellLayoutTestCaseReader.java | 162 ++++++++++++++++++ .../celllayout/CellLayoutTestUtils.java | 4 +- .../MultipleCellLayoutsSimpleReorder.java | 2 + .../{testcases => }/ReorderTestCase.java | 4 +- .../launcher3/celllayout/ReorderWidgets.java | 65 ++++--- .../celllayout/testcases/FullReorderCase.java | 109 ------------ .../testcases/MoveOutReorderCase.java | 69 -------- .../celllayout/testcases/PushReorderCase.java | 70 -------- .../testcases/SimpleReorderCase.java | 87 ---------- 16 files changed, 398 insertions(+), 367 deletions(-) create mode 100644 tests/assets/ReorderWidgets/full_reorder_case create mode 100644 tests/assets/ReorderWidgets/move_out_reorder_case create mode 100644 tests/assets/ReorderWidgets/push_reorder_case create mode 100644 tests/assets/ReorderWidgets/simple_reorder_case create mode 100644 tests/res/raw/reorder_algorithm_test.txt create mode 100644 tests/src/com/android/launcher3/celllayout/CellLayoutTestCaseReader.java rename tests/src/com/android/launcher3/celllayout/{testcases => }/ReorderTestCase.java (93%) delete mode 100644 tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java delete mode 100644 tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java delete mode 100644 tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java delete mode 100644 tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java diff --git a/tests/Android.bp b/tests/Android.bp index 81853d15ff..f9d6f04c4d 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -69,6 +69,7 @@ filegroup { android_library { name: "Launcher3TestLib", srcs: [ ], + asset_dirs: ["assets"], resource_dirs: ["res"], static_libs: [ "launcher-aosp-tapl", diff --git a/tests/assets/ReorderWidgets/full_reorder_case b/tests/assets/ReorderWidgets/full_reorder_case new file mode 100644 index 0000000000..33ebaaea28 --- /dev/null +++ b/tests/assets/ReorderWidgets/full_reorder_case @@ -0,0 +1,28 @@ +################################################################################################### +# This file contains test case composed of the following tags: +# * # (coments): Lines starting with this character would be ignored. +# * arguments: is set of words separated by spaces that can later be parsed +# * board: represent a workspace, the first line is the dimensions of the board width x height (wxh) +# There are different characters on the board that represent different things: +# * x: The x character represents spaces that would be ignored, for example it can be used in +# the first row if we don't know how wide the smartspace is. +# * i: Represents an icon on the workspace, none in particular just an icon +# * [a-z]: Represents a widget and it can be any number or character +# except any other already in use. The whole continuos are of the same character is the +# area of the widget. +# * [A-Z]: Represents a folder and number of icons in the folder is represented by the order of +# letter in the alphabet, A=2, B=3, C=4 ... etc. +# Test are parsed by CellLayoutTestCaseReader.java and boards are parsed by CellLayoutBoard.java +################################################################################################### +# Test 4x4 +board: 4x4 +xxxx +bbmm +iimm +iiaa +arguments: 0 3 +board: 4x4 +xxxx +bbii +mmii +mmaa \ No newline at end of file diff --git a/tests/assets/ReorderWidgets/move_out_reorder_case b/tests/assets/ReorderWidgets/move_out_reorder_case new file mode 100644 index 0000000000..db0a91dd54 --- /dev/null +++ b/tests/assets/ReorderWidgets/move_out_reorder_case @@ -0,0 +1,44 @@ +################################################################################################### +# This file contains test case composed of the following tags: +# * # (coments): Lines starting with this character would be ignored. +# * arguments: is set of words separated by spaces that can later be parsed +# * board: represent a workspace, the first line is the dimensions of the board width x height (wxh) +# There are different characters on the board that represent different things: +# * x: The x character represents spaces that would be ignored, for example it can be used in +# the first row if we don't know how wide the smartspace is. +# * i: Represents an icon on the workspace, none in particular just an icon +# * [a-z]: Represents a widget and it can be any number or character +# except any other already in use. The whole continuos are of the same character is the +# area of the widget. +# * [A-Z]: Represents a folder and number of icons in the folder is represented by the order of +# letter in the alphabet, A=2, B=3, C=4 ... etc. +# Test are parsed by CellLayoutTestCaseReader.java and boards are parsed by CellLayoutBoard.java +################################################################################################### +# Test 5x5 +board: 5x5 +xxxxx +cd-m- +cgaaa +ctaaa +ctaaa +arguments: 1 2 +board: 5x5 +xxxxx +cde-- +cgaaa +ctaaa +ctaaa +# Test 6x5 +board: 6x5 +xxxxxx +cd-m-- +cgaaaa +ctaaaa +ctaaaa +arguments: 1 2 +board: 6x5 +xxxxxx +cdg--- +cmaaaa +ctaaaa +ctaaaa \ No newline at end of file diff --git a/tests/assets/ReorderWidgets/push_reorder_case b/tests/assets/ReorderWidgets/push_reorder_case new file mode 100644 index 0000000000..8e845a2462 --- /dev/null +++ b/tests/assets/ReorderWidgets/push_reorder_case @@ -0,0 +1,44 @@ +################################################################################################### +# This file contains test case composed of the following tags: +# * # (coments): Lines starting with this character would be ignored. +# * arguments: is set of words separated by spaces that can later be parsed +# * board: represent a workspace, the first line is the dimensions of the board width x height (wxh) +# There are different characters on the board that represent different things: +# * x: The x character represents spaces that would be ignored, for example it can be used in +# the first row if we don't know how wide the smartspace is. +# * i: Represents an icon on the workspace, none in particular just an icon +# * [a-z]: Represents a widget and it can be any number or character +# except any other already in use. The whole continuos are of the same character is the +# area of the widget. +# * [A-Z]: Represents a folder and number of icons in the folder is represented by the order of +# letter in the alphabet, A=2, B=3, C=4 ... etc. +# Test are parsed by CellLayoutTestCaseReader.java and boards are parsed by CellLayoutBoard.java +################################################################################################### +#Test 5x5 +board: 5x5 +xxxxx +bbbm- +--ccc +--ddd +----- +arguments: 2 1 +board: 5x5 +xxxxx +--m-- +bbb-- +--ccc +--ddd +#6x5 Test +board: 6x5 +xxxxxx +bbbbm- +--aaa- +--ddd- +------ +arguments: 2 1 +board: 6x5 +xxxxxx +--m--- +bbbb-- +--aaa- +--ddd- \ No newline at end of file diff --git a/tests/assets/ReorderWidgets/simple_reorder_case b/tests/assets/ReorderWidgets/simple_reorder_case new file mode 100644 index 0000000000..f5eb7b6f5c --- /dev/null +++ b/tests/assets/ReorderWidgets/simple_reorder_case @@ -0,0 +1,56 @@ +################################################################################################### +# This file contains test case composed of the following tags: +# * # (coments): Lines starting with this character would be ignored. +# * arguments: is set of words separated by spaces that can later be parsed +# * board: represent a workspace, the first line is the dimensions of the board width x height (wxh) +# There are different characters on the board that represent different things: +# * x: The x character represents spaces that would be ignored, for example it can be used in +# the first row if we don't know how wide the smartspace is. +# * i: Represents an icon on the workspace, none in particular just an icon +# * [a-z]: Represents a widget and it can be any number or character +# except any other already in use. The whole continuos are of the same character is the +# area of the widget. +# * [A-Z]: Represents a folder and number of icons in the folder is represented by the order of +# letter in the alphabet, A=2, B=3, C=4 ... etc. +# Test are parsed by CellLayoutTestCaseReader.java and boards are parsed by CellLayoutBoard.java +################################################################################################### +# Test 5x5 +board: 5x5 +xxxxx +--mm- +--mm- +----- +----- +arguments: 0 4 +board: 5x5 +xxxxx +----- +----- +mm--- +mm--- +# Test 4x4 +board: 4x4 +xxxx +--mm +--mm +---- +arguments: 3 3 +board: 4x4 +xxxx +---- +--mm +--mm +# Test 6x5 +board: 6x5 +xxxxxx +-mm--- +-mm--- +------ +------ +arguments: 4 3 +board: 6x5 +xxxxxx +------ +------ +----mm +----mm \ No newline at end of file diff --git a/tests/res/raw/reorder_algorithm_test.txt b/tests/res/raw/reorder_algorithm_test.txt new file mode 100644 index 0000000000..4930e932a4 --- /dev/null +++ b/tests/res/raw/reorder_algorithm_test.txt @@ -0,0 +1,9 @@ +arguments: 5 6 normal +board: 6x5 +xxxxx- +------ +------ +---3-- +---3-- +---3-- +# this is a comment \ No newline at end of file diff --git a/tests/src/com/android/launcher3/celllayout/CellLayoutBoard.java b/tests/src/com/android/launcher3/celllayout/CellLayoutBoard.java index 6d75180f8c..cf96f04e37 100644 --- a/tests/src/com/android/launcher3/celllayout/CellLayoutBoard.java +++ b/tests/src/com/android/launcher3/celllayout/CellLayoutBoard.java @@ -179,7 +179,6 @@ public class CellLayoutBoard implements Comparable { Map mWidgetsMap = new HashMap<>(); List mIconPoints = new ArrayList<>(); - Map mIconsMap = new HashMap<>(); WidgetRect mMain = null; @@ -270,7 +269,9 @@ public class CellLayoutBoard implements Comparable { } public void addIcon(int x, int y) { - removeOverlappingItems(new Point(x, y)); + Point iconCoord = new Point(x, y); + removeOverlappingItems(iconCoord); + mIconPoints.add(new IconPoint(iconCoord, CellType.ICON)); mWidget[x][y] = 'i'; } @@ -306,8 +307,12 @@ public class CellLayoutBoard implements Comparable { return new WidgetRect(type, widgetRect); } + public static boolean isFolder(char type) { + return type >= 'A' && type <= 'Z'; + } + public static boolean isWidget(char type) { - return type != CellType.ICON && type != CellType.EMPTY; + return type != CellType.ICON && type != CellType.EMPTY && (type >= 'a' && type <= 'z'); } public static boolean isIcon(char type) { diff --git a/tests/src/com/android/launcher3/celllayout/CellLayoutTestCaseReader.java b/tests/src/com/android/launcher3/celllayout/CellLayoutTestCaseReader.java new file mode 100644 index 0000000000..e33a304941 --- /dev/null +++ b/tests/src/com/android/launcher3/celllayout/CellLayoutTestCaseReader.java @@ -0,0 +1,162 @@ +/* + * 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; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; + +import android.graphics.Point; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; + +public class CellLayoutTestCaseReader { + + public abstract static class TestSection { + State state; + + public TestSection(State state) { + this.state = state; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + } + + public static class Comment extends TestSection { + public Comment() { + super(State.COMMENT); + } + } + + public static class Arguments extends TestSection { + String[] arguments; + + public Arguments(String[] arguments) { + super(State.ARGUMENTS); + this.arguments = arguments; + } + } + + public static class Board extends TestSection { + Point gridSize; + String board; + + public Board(Point gridSize, String board) { + super(State.BOARD); + this.gridSize = gridSize; + this.board = board; + } + } + + public enum State { + START, + ARGUMENTS, + BOARD, + END, + COMMENT + } + + String mTest; + + protected CellLayoutTestCaseReader(String test) { + mTest = test; + } + + public static CellLayoutTestCaseReader readFromFile(String fileName) throws IOException { + String fileStr = new BufferedReader(new InputStreamReader( + getInstrumentation().getContext().getAssets().open(fileName)) + ).lines().collect(Collectors.joining("\n")); + return new CellLayoutTestCaseReader(fileStr); + } + + private State getStateFromLine(String line) { + String typeWithColons = line.trim().split(" ")[0].trim(); + String type = typeWithColons.substring(0, typeWithColons.length() - 1); + try { + return Enum.valueOf(State.class, type.toUpperCase()); + } catch (Exception e) { + throw new RuntimeException( + "The given tag " + typeWithColons + " doesn't match with the existing tags"); + } + } + + private String removeTag(String line) { + return line.split(":")[1]; + } + + private TestSection parseNextLine(Iterator it) { + String line = it.next(); + if (line.trim().charAt(0) == '#') { + return new Comment(); + } + State state = getStateFromLine(line); + line = removeTag(line); + switch (state) { + case ARGUMENTS: + return new Arguments(parseArgumentsLine(line)); + case BOARD: + Point grid = parseGridSize(line); + return new Board(grid, parseBoard(it, grid.y)); + default: + return new Comment(); + } + } + + List parse() { + List sections = new ArrayList<>(); + String[] lines = mTest.split("\n"); + Iterator it = Arrays.stream(lines).iterator(); + while (it.hasNext()) { + TestSection section = parseNextLine(it); + if (section.state == State.COMMENT) { + continue; + } + sections.add(section); + } + return sections; + } + + private String parseBoard(Iterator it, int rows) { + StringBuilder board = new StringBuilder(); + for (int j = 0; j < rows; j++) { + board.append(it.next() + "\n"); + } + return board.toString(); + } + + private String[] parseArgumentsLine(String line) { + return Arrays.stream(line.trim().split(" ")).map(String::trim).toArray(String[]::new); + } + + private Point parseGridSize(String line) { + String[] values = line.toLowerCase(Locale.ROOT).split("x"); + int x = Integer.parseInt(values[0].trim()); + int y = Integer.parseInt(values[1].trim()); + return new Point(x, y); + } +} diff --git a/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java b/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java index 2960807098..e3d07a99f1 100644 --- a/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java +++ b/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java @@ -51,8 +51,8 @@ public class CellLayoutTestUtils { board.addIcon(pos.cellX, pos.cellY); } else { // is widget - board.addWidget(pos.cellX, pos.cellY, params.cellHSpan, params.cellVSpan, - (char) ('A' + widgetCount)); + board.addWidget(params.getCellX(), params.getCellY(), params.cellHSpan, + params.cellVSpan, (char) ('a' + widgetCount)); widgetCount++; } } diff --git a/tests/src/com/android/launcher3/celllayout/MultipleCellLayoutsSimpleReorder.java b/tests/src/com/android/launcher3/celllayout/MultipleCellLayoutsSimpleReorder.java index 9b52fe826c..706c1a7187 100644 --- a/tests/src/com/android/launcher3/celllayout/MultipleCellLayoutsSimpleReorder.java +++ b/tests/src/com/android/launcher3/celllayout/MultipleCellLayoutsSimpleReorder.java @@ -17,6 +17,8 @@ package com.android.launcher3.celllayout.testcases; import android.graphics.Point; +import com.android.launcher3.celllayout.ReorderTestCase; + import java.util.Map; /** diff --git a/tests/src/com/android/launcher3/celllayout/testcases/ReorderTestCase.java b/tests/src/com/android/launcher3/celllayout/ReorderTestCase.java similarity index 93% rename from tests/src/com/android/launcher3/celllayout/testcases/ReorderTestCase.java rename to tests/src/com/android/launcher3/celllayout/ReorderTestCase.java index 98fc20c228..ed84a60fae 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/ReorderTestCase.java +++ b/tests/src/com/android/launcher3/celllayout/ReorderTestCase.java @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.celllayout.testcases; +package com.android.launcher3.celllayout; import android.graphics.Point; -import com.android.launcher3.celllayout.CellLayoutBoard; - import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; diff --git a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java index c2fe3de407..e8dd3c0455 100644 --- a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java +++ b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java @@ -25,12 +25,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.launcher3.InvariantDeviceProfile; -import com.android.launcher3.celllayout.testcases.FullReorderCase; -import com.android.launcher3.celllayout.testcases.MoveOutReorderCase; import com.android.launcher3.celllayout.testcases.MultipleCellLayoutsSimpleReorder; -import com.android.launcher3.celllayout.testcases.PushReorderCase; -import com.android.launcher3.celllayout.testcases.ReorderTestCase; -import com.android.launcher3.celllayout.testcases.SimpleReorderCase; import com.android.launcher3.tapl.Widget; import com.android.launcher3.tapl.WidgetResizeFrame; import com.android.launcher3.testing.shared.TestProtocol; @@ -40,12 +35,14 @@ import com.android.launcher3.util.rule.ShellCommandRule; import org.junit.Assume; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -159,27 +156,23 @@ public class ReorderWidgets extends AbstractLauncherUiTest { } @Test - public void simpleReorder() throws ExecutionException, InterruptedException { - runTestCaseMap(SimpleReorderCase.TEST_BY_GRID_SIZE, - SimpleReorderCase.class.getSimpleName()); - } - - @Ignore - @Test - public void pushTest() throws ExecutionException, InterruptedException { - runTestCaseMap(PushReorderCase.TEST_BY_GRID_SIZE, PushReorderCase.class.getSimpleName()); - } - - @Ignore - @Test - public void fullReorder() throws ExecutionException, InterruptedException { - runTestCaseMap(FullReorderCase.TEST_BY_GRID_SIZE, FullReorderCase.class.getSimpleName()); + public void simpleReorder() throws Exception { + runTestCaseMap(getTestMap("ReorderWidgets/simple_reorder_case"), "push_reorder_case"); } @Test - public void moveOutReorder() throws ExecutionException, InterruptedException { - runTestCaseMap(MoveOutReorderCase.TEST_BY_GRID_SIZE, - MoveOutReorderCase.class.getSimpleName()); + public void pushTest() throws Exception { + runTestCaseMap(getTestMap("ReorderWidgets/push_reorder_case"), "push_reorder_case"); + } + + @Test + public void fullReorder() throws Exception { + runTestCaseMap(getTestMap("ReorderWidgets/full_reorder_case"), "full_reorder_case"); + } + + @Test + public void moveOutReorder() throws Exception { + runTestCaseMap(getTestMap("ReorderWidgets/move_out_reorder_case"), "move_out_reorder_case"); } @Test @@ -188,4 +181,28 @@ public class ReorderWidgets extends AbstractLauncherUiTest { runTestCaseMap(MultipleCellLayoutsSimpleReorder.TEST_BY_GRID_SIZE, MultipleCellLayoutsSimpleReorder.class.getSimpleName()); } + + private void addTestCase(Iterator sections, + Map testCaseMap) { + CellLayoutTestCaseReader.Board startBoard = + ((CellLayoutTestCaseReader.Board) sections.next()); + CellLayoutTestCaseReader.Arguments point = + ((CellLayoutTestCaseReader.Arguments) sections.next()); + CellLayoutTestCaseReader.Board endBoard = + ((CellLayoutTestCaseReader.Board) sections.next()); + Point moveTo = new Point(Integer.parseInt(point.arguments[0]), + Integer.parseInt(point.arguments[1])); + testCaseMap.put(startBoard.gridSize, + new ReorderTestCase(startBoard.board, moveTo, endBoard.board)); + } + + private Map getTestMap(String testPath) throws IOException { + Map testCaseMap = new HashMap<>(); + Iterator iterableSection = + CellLayoutTestCaseReader.readFromFile(testPath).parse().iterator(); + while (iterableSection.hasNext()) { + addTestCase(iterableSection, testCaseMap); + } + return testCaseMap; + } } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java deleted file mode 100644 index d68d2ede61..0000000000 --- a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2022 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.testcases; - -import android.graphics.Point; - -import java.util.Map; - -/** - * The grids represent the workspace to be build by TestWorkspaceBuilder, to see what each character - * in the board mean refer to {@code CellType} - */ -public class FullReorderCase { - - /** 5x5 Test - **/ - private static final String START_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "222mm\n" - + "222mm\n" - + "ii111\n" - + "ii111"; - private static final Point MOVE_TO_5x5 = new Point(0, 4); - private static final String END_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "222ii\n" - + "222ii\n" - + "mm111\n" - + "mm111"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, - MOVE_TO_5x5, - END_BOARD_STR_5x5); - - /** 6x5 Test - **/ - private static final String START_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "2222mm\n" - + "2222mm\n" - + "ii1111\n" - + "ii1111"; - private static final Point MOVE_TO_6x5 = new Point(0, 4); - private static final String END_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "2222ii\n" - + "2222ii\n" - + "mm1111\n" - + "mm1111"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, - MOVE_TO_6x5, - END_BOARD_STR_6x5); - - /** 4x4 Test - **/ - private static final String START_BOARD_STR_4x4 = "" - + "xxxx\n" - + "22mm\n" - + "iimm\n" - + "ii11"; - private static final Point MOVE_TO_4x4 = new Point(0, 3); - private static final String END_BOARD_STR_4x4 = "" - + "xxxx\n" - + "22ii\n" - + "mmii\n" - + "mm11"; - - private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, - MOVE_TO_4x4, - END_BOARD_STR_4x4); - - /** 4x4 Test - **/ - private static final String START_BOARD_STR_4x5 = "" - + "xxxx\n" - + "22mm\n" - + "iimm\n" - + "ii11\n" - + "ii11"; - private static final Point MOVE_TO_4x5 = new Point(0, 3); - private static final String END_BOARD_STR_4x5 = "" - + "xxxx\n" - + "22ii\n" - + "mmii\n" - + "mm11\n" - + "ii11"; - - private static final ReorderTestCase TEST_CASE_4x5 = new ReorderTestCase(START_BOARD_STR_4x5, - MOVE_TO_4x5, - END_BOARD_STR_4x5); - - public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, - new Point(6, 5), TEST_CASE_6x5, - new Point(4, 4), TEST_CASE_4x4, - new Point(4, 5), TEST_CASE_4x5); -} diff --git a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java deleted file mode 100644 index 047d3422df..0000000000 --- a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2022 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.testcases; - -import android.graphics.Point; - -import java.util.Map; - -/** - * The grids represent the workspace to be build by TestWorkspaceBuilder, to see what each character - * in the board mean refer to {@code CellType} - */ -public class MoveOutReorderCase { - - /** 5x5 Test - **/ - private static final String START_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "34-m-\n" - + "35111\n" - + "32111\n" - + "32111"; - private static final Point MOVE_TO_5x5 = new Point(1, 2); - private static final String END_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "345--\n" - + "3m111\n" - + "32111\n" - + "32111"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, - MOVE_TO_5x5, - END_BOARD_STR_5x5); - - /** 6x5 Test - **/ - private static final String START_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "34-m--\n" - + "351111\n" - + "321111\n" - + "321111"; - private static final Point MOVE_TO_6x5 = new Point(1, 2); - private static final String END_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "345---\n" - + "3m1111\n" - + "321111\n" - + "321111"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, - MOVE_TO_6x5, - END_BOARD_STR_6x5); - - public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, - new Point(6, 5), TEST_CASE_6x5); -} diff --git a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java deleted file mode 100644 index 38c9aee0fd..0000000000 --- a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2022 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.testcases; - -import android.graphics.Point; - -import java.util.Map; - -/** - * The grids represent the workspace to be build by TestWorkspaceBuilder, to see what each character - * in the board mean refer to {@code CellType} - */ -public class PushReorderCase { - - /** 5x5 Test - **/ - private static final String START_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "222m-\n" - + "--111\n" - + "--333\n" - + "-----"; - private static final Point MOVE_TO_5x5 = new Point(2, 1); - private static final String END_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "--m--\n" - + "222--\n" - + "--111\n" - + "--333"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, - MOVE_TO_5x5, - END_BOARD_STR_5x5); - - - /** 6x5 Test - **/ - private static final String START_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "2222m-\n" - + "--111-\n" - + "--333-\n" - + "------"; - private static final Point MOVE_TO_6x5 = new Point(2, 1); - private static final String END_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "--m---\n" - + "2222--\n" - + "--111-\n" - + "--333-"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, - MOVE_TO_6x5, - END_BOARD_STR_6x5); - - public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, - new Point(6, 5), TEST_CASE_6x5); -} diff --git a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java deleted file mode 100644 index c9f6849854..0000000000 --- a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2022 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.testcases; - -import android.graphics.Point; - -import java.util.Map; - -/** - * The grids represent the workspace to be build by TestWorkspaceBuilder, to see what each character - * in the board mean refer to {@code CellType} - */ -public class SimpleReorderCase { - - /** 5x5 Test - **/ - private static final String START_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "--mm-\n" - + "--mm-\n" - + "-----\n" - + "-----"; - private static final Point MOVE_TO_5x5 = new Point(0, 4); - private static final String END_BOARD_STR_5x5 = "" - + "xxxxx\n" - + "-----\n" - + "-----\n" - + "mm---\n" - + "mm---"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, - MOVE_TO_5x5, - END_BOARD_STR_5x5); - - /** 4x4 Test - **/ - private static final String START_BOARD_STR_4x4 = "" - + "xxxx\n" - + "--mm\n" - + "--mm\n" - + "----"; - private static final Point MOVE_TO_4x4 = new Point(3, 3); - private static final String END_BOARD_STR_4x4 = "" - + "xxxx\n" - + "----\n" - + "--mm\n" - + "--mm"; - private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, - MOVE_TO_4x4, - END_BOARD_STR_4x4); - - /** 6x5 Test - **/ - private static final String START_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "-mm---\n" - + "-mm---\n" - + "------\n" - + "------"; - private static final Point MOVE_TO_6x5 = new Point(4, 3); - private static final String END_BOARD_STR_6x5 = "" - + "xxxxxx\n" - + "------\n" - + "------\n" - + "----mm\n" - + "----mm"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, - MOVE_TO_6x5, - END_BOARD_STR_6x5); - - public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, - new Point(4, 4), TEST_CASE_4x4, - new Point(6, 5), TEST_CASE_6x5); -}