From c3ecf392e3c9a52996ebac672e8832dea9551f4c Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Tue, 9 Aug 2022 11:18:28 -0700 Subject: [PATCH] Adding 4x4 roerder widget test Fix: 241000659 Test: atest ReorderWidgets Change-Id: I7dea2fbc676710798187b50d27b63ced9910a43b --- .../celllayout/testcases/FullReorderCase.java | 33 ++++++++++--- .../testcases/MoveOutReorderCase.java | 33 +++++++++---- .../celllayout/testcases/PushReorderCase.java | 48 +++++++++++-------- .../testcases/SimpleReorderCase.java | 36 +++++++++----- 4 files changed, 103 insertions(+), 47 deletions(-) diff --git a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java index ff03a50fbc..1326389ab7 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java @@ -20,46 +20,65 @@ import android.graphics.Point; import java.util.Map; public class FullReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "222mm\n" + "222mm\n" + "ad111\n" + "bc111"; - private static final Point MOVE_TO_5x5 = new Point(0, 4); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "222ad\n" + "222bc\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" + "ad1111\n" + "bc1111"; - private static final Point MOVE_TO_6x5 = new Point(0, 4); - private static final String END_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222ad\n" + "2222bc\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" + + "admm\n" + + "bc11"; + private static final Point MOVE_TO_4x4 = new Point(0, 3); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "22ad\n" + + "mmbc\n" + + "mm11"; + + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); + public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java index 32bf05a52c..1701390268 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java @@ -20,47 +20,64 @@ import android.graphics.Point; import java.util.Map; 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); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "34-m\n" + + "3511\n" + + "3211"; + private static final Point MOVE_TO_4x4 = new Point(1, 2); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "345-\n" + + "3m11\n" + + "3211"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); + public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java index b386946176..bb8d5e9631 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java @@ -17,60 +17,68 @@ package com.android.launcher3.celllayout.testcases; import android.graphics.Point; -import com.android.launcher3.celllayout.CellLayoutBoard; - import java.util.Map; public class PushReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "222m-\n" + "--111\n" + "--333\n" + "-----"; - private static final CellLayoutBoard START_BOARD_5x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR_5x5); - 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 CellLayoutBoard END_BOARD_5x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, + MOVE_TO_5x5, END_BOARD_STR_5x5); - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_5x5, - MOVE_TO_5x5, - END_BOARD_5x5); - + /** 6x5 Test + **/ private static final String START_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222m-\n" + "--111-\n" + "--333-\n" + "------"; - private static final CellLayoutBoard START_BOARD_6x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR_6x5); - 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 CellLayoutBoard END_BOARD_6x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, + MOVE_TO_6x5, END_BOARD_STR_6x5); - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_6x5, - MOVE_TO_6x5, - END_BOARD_6x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "222m\n" + + "-111\n" + + "----"; + private static final Point MOVE_TO_4x4 = new Point(2, 1); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "--m-\n" + + "222-\n" + + "-111"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java index 57e1398bd2..30269a0f5d 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java @@ -17,35 +17,47 @@ package com.android.launcher3.celllayout.testcases; import android.graphics.Point; -import com.android.launcher3.celllayout.CellLayoutBoard; - import java.util.Map; public class SimpleReorderCase { - private static final String START_BOARD_STR = "" + + /** 5x5 Test + **/ + private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "--mm-\n" + "--mm-\n" + "-----\n" + "-----"; - private static final CellLayoutBoard START_BOARD_5x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR); - private static final Point MOVE_TO_5x5 = new Point(4, 4); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "-----\n" + "-----\n" + "---mm\n" + "---mm"; - private static final CellLayoutBoard END_BOARD_5x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, + MOVE_TO_5x5, END_BOARD_STR_5x5); - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_5x5, - MOVE_TO_5x5, - END_BOARD_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); public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(4, 4), TEST_CASE_4x4); }