Merge "Parsing test boards from text files to be able to add more and bigger tests" into udc-dev

This commit is contained in:
Sebastián Franco
2023-04-13 20:32:34 +00:00
committed by Android (Google) Code Review
16 changed files with 398 additions and 367 deletions
+1
View File
@@ -69,6 +69,7 @@ filegroup {
android_library {
name: "Launcher3TestLib",
srcs: [ ],
asset_dirs: ["assets"],
resource_dirs: ["res"],
static_libs: [
"launcher-aosp-tapl",
@@ -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
@@ -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
@@ -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-
@@ -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
+9
View File
@@ -0,0 +1,9 @@
arguments: 5 6 normal
board: 6x5
xxxxx-
------
------
---3--
---3--
---3--
# this is a comment
@@ -179,7 +179,6 @@ public class CellLayoutBoard implements Comparable<CellLayoutBoard> {
Map<Character, WidgetRect> mWidgetsMap = new HashMap<>();
List<IconPoint> mIconPoints = new ArrayList<>();
Map<Character, IconPoint> mIconsMap = new HashMap<>();
WidgetRect mMain = null;
@@ -270,7 +269,9 @@ public class CellLayoutBoard implements Comparable<CellLayoutBoard> {
}
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<CellLayoutBoard> {
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) {
@@ -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<String> 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<TestSection> parse() {
List<TestSection> sections = new ArrayList<>();
String[] lines = mTest.split("\n");
Iterator<String> 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<String> 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);
}
}
@@ -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++;
}
}
@@ -17,6 +17,8 @@ package com.android.launcher3.celllayout.testcases;
import android.graphics.Point;
import com.android.launcher3.celllayout.ReorderTestCase;
import java.util.Map;
/**
@@ -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;
@@ -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<CellLayoutTestCaseReader.TestSection> sections,
Map<Point, ReorderTestCase> 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<Point, ReorderTestCase> getTestMap(String testPath) throws IOException {
Map<Point, ReorderTestCase> testCaseMap = new HashMap<>();
Iterator<CellLayoutTestCaseReader.TestSection> iterableSection =
CellLayoutTestCaseReader.readFromFile(testPath).parse().iterator();
while (iterableSection.hasNext()) {
addTestCase(iterableSection, testCaseMap);
}
return testCaseMap;
}
}
@@ -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<Point, ReorderTestCase> 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);
}
@@ -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<Point, ReorderTestCase> TEST_BY_GRID_SIZE =
Map.of(new Point(5, 5), TEST_CASE_5x5,
new Point(6, 5), TEST_CASE_6x5);
}
@@ -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<Point, ReorderTestCase> TEST_BY_GRID_SIZE =
Map.of(new Point(5, 5), TEST_CASE_5x5,
new Point(6, 5), TEST_CASE_6x5);
}
@@ -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<Point, ReorderTestCase> 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);
}