summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-05-26 16:05:17 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-05-27 18:23:29 -0700
commitda4fe1a6244457f144e0a331cada3ada17157809 (patch)
tree71a921324999c5c61598d08b1de864c426c8bc8e /tests
parentc54c701a94e213503d0c6d2ff414e91a50c14133 (diff)
downloadandroid_packages_apps_Trebuchet-da4fe1a6244457f144e0a331cada3ada17157809.tar.gz
android_packages_apps_Trebuchet-da4fe1a6244457f144e0a331cada3ada17157809.tar.bz2
android_packages_apps_Trebuchet-da4fe1a6244457f144e0a331cada3ada17157809.zip
Moving the QSB to the workspace grid.
The QSB will only be resent on the first screen of the workspace covering the full width of the first row. If will not be movable. The first screen of the workspace will not be movable. The searchDropTargetBar no longer contains the QSB (it can be renamed in aseparate cl). Refactoring all QSB related logic by moving it to a custom view inflated only using xml. Change-Id: Icb4fd6eb855df1af15f685961c38351bf4fd4f4a
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/BindWidgetTest.java15
-rw-r--r--tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java66
2 files changed, 70 insertions, 11 deletions
diff --git a/tests/src/com/android/launcher3/BindWidgetTest.java b/tests/src/com/android/launcher3/BindWidgetTest.java
index 81cb8b56b..5c5069fea 100644
--- a/tests/src/com/android/launcher3/BindWidgetTest.java
+++ b/tests/src/com/android/launcher3/BindWidgetTest.java
@@ -205,10 +205,13 @@ public class BindWidgetTest extends LauncherInstrumentationTestCase {
*/
private void setupAndVerifyContents(
LauncherAppWidgetInfo item, Class<?> widgetClass, String desc) {
- // Add new screen
- long screenId = LauncherSettings.Settings.call(
- mResolver, LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
- .getLong(LauncherSettings.Settings.EXTRA_VALUE);
+ long screenId = Workspace.FIRST_SCREEN_ID;
+ // Update the screen id counter for the provider.
+ LauncherSettings.Settings.call(mResolver, LauncherSettings.Settings.METHOD_NEW_SCREEN_ID);
+
+ if (screenId > Workspace.FIRST_SCREEN_ID) {
+ screenId = Workspace.FIRST_SCREEN_ID;
+ }
ContentValues v = new ContentValues();
v.put(LauncherSettings.WorkspaceScreens._ID, screenId);
v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, 0);
@@ -263,7 +266,7 @@ public class BindWidgetTest extends LauncherInstrumentationTestCase {
item.minSpanY = info.minSpanY;
item.user = mWidgetManager.getUser(info);
item.cellX = 0;
- item.cellY = 0;
+ item.cellY = 1;
item.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
if (bindWidget) {
@@ -319,7 +322,7 @@ public class BindWidgetTest extends LauncherInstrumentationTestCase {
item.minSpanX = 2;
item.minSpanY = 2;
item.cellX = 0;
- item.cellY = 0;
+ item.cellY = 1;
item.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
return item;
}
diff --git a/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java b/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
index ccd8f7361..ebf06ba38 100644
--- a/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
+++ b/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
@@ -208,6 +208,57 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
}});
}
+ public void testWorkspace_first_row_blocked() throws Exception {
+ // The first screen has one item on the 4th column which needs moving, as the first row
+ // will be kept empty.
+ long[][][] ids = createGrid(new int[][][]{{
+ { -1, -1, -1, -1},
+ { 3, 1, 7, 0},
+ { 8, 7, 7, -1},
+ { 5, 2, 7, -1},
+ }}, 0);
+
+ new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, new HashMap<String, Point>(),
+ new Point(4, 4), new Point(3, 4)).migrateWorkspace();
+
+ // Items in the second column of the first screen should get placed on a new screen.
+ verifyWorkspace(new long[][][] {{
+ { -1, -1, -1},
+ {ids[0][1][0], ids[0][1][1], ids[0][1][2]},
+ {ids[0][2][0], ids[0][2][1], ids[0][2][2]},
+ {ids[0][3][0], ids[0][3][1], ids[0][3][2]},
+ }, {
+ {ids[0][1][3]},
+ }});
+ }
+
+ public void testWorkspace_items_moved_to_empty_first_row() throws Exception {
+ // Items will get moved to the next screen to keep the first screen empty.
+ long[][][] ids = createGrid(new int[][][]{{
+ { -1, -1, -1, -1},
+ { 0, 1, 0, 0},
+ { 8, 7, 7, -1},
+ { 5, 6, 7, -1},
+ }}, 0);
+
+ new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, new HashMap<String, Point>(),
+ new Point(4, 4), new Point(3, 3)).migrateWorkspace();
+
+ // Items in the second column of the first screen should get placed on a new screen.
+ verifyWorkspace(new long[][][] {{
+ { -1, -1, -1},
+ {ids[0][2][0], ids[0][2][1], ids[0][2][2]},
+ {ids[0][3][0], ids[0][3][1], ids[0][3][2]},
+ }, {
+ {ids[0][1][1], ids[0][1][0], ids[0][1][2]},
+ {ids[0][1][3]},
+ }});
+ }
+
+ private long[][][] createGrid(int[][][] typeArray) throws Exception {
+ return createGrid(typeArray, 1);
+ }
+
/**
* Initializes the DB with dummy elements to represent the provided grid structure.
* @param typeArray A 3d array of item types. {@see #addItem(int, long, long, int, int)} for
@@ -215,14 +266,18 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
* two represent the workspace grid.
* @return the same grid representation where each entry is the corresponding item id.
*/
- private long[][][] createGrid(int[][][] typeArray) throws Exception {
+ private long[][][] createGrid(int[][][] typeArray, long startScreen) throws Exception {
+ LauncherSettings.Settings.call(getMockContentResolver(),
+ LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
long[][][] ids = new long[typeArray.length][][];
for (int i = 0; i < typeArray.length; i++) {
// Add screen to DB
- long screenId = LauncherSettings.Settings.call(getMockContentResolver(),
- LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
- .getLong(LauncherSettings.Settings.EXTRA_VALUE);
+ long screenId = startScreen + i;
+
+ // Keep the screen id counter up to date
+ LauncherSettings.Settings.call(getMockContentResolver(),
+ LauncherSettings.Settings.METHOD_NEW_SCREEN_ID);
ContentValues v = new ContentValues();
v.put(LauncherSettings.WorkspaceScreens._ID, screenId);
@@ -270,7 +325,8 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
} else {
assertEquals(1, c.getCount());
c.moveToNext();
- assertEquals(id, c.getLong(0));
+ assertEquals(String.format("Failed to verify item ad %d %d, %d", i, y, x),
+ id, c.getLong(0));
total++;
}
c.close();