summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-13 16:02:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-07-13 16:02:18 +0000
commitba162aa7d2a49c09c00ff3184ffda3bea0e55509 (patch)
treec710837d19924e755e5df101a5ca60b32d1e455b /tests
parentc6e5fdb7acf01d4c5824f9e3e212d046c90d61c1 (diff)
parenta5c8a9eb666da16bc4c9ea4412868e22ace8d1f0 (diff)
downloadandroid_packages_apps_Trebuchet-ba162aa7d2a49c09c00ff3184ffda3bea0e55509.tar.gz
android_packages_apps_Trebuchet-ba162aa7d2a49c09c00ff3184ffda3bea0e55509.tar.bz2
android_packages_apps_Trebuchet-ba162aa7d2a49c09c00ff3184ffda3bea0e55509.zip
Merge "Adding logic to pull in workspace data from another Launcher3 based provider. This allows OEMs to keep the user's homescreen intact while changing the default home app package." into ub-launcher3-calgary
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java54
1 files changed, 53 insertions, 1 deletions
diff --git a/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java b/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
index 4dae42f7e..fc7fe48fd 100644
--- a/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
+++ b/tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java
@@ -1,6 +1,7 @@
package com.android.launcher3.model;
import android.content.ContentValues;
+import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Point;
@@ -12,10 +13,12 @@ import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
+import com.android.launcher3.model.GridSizeMigrationTask.MultiStepMigrationTask;
import com.android.launcher3.util.TestLauncherProvider;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedList;
/**
* Unit tests for {@link GridSizeMigrationTask}
@@ -337,7 +340,7 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
} else {
assertEquals(1, c.getCount());
c.moveToNext();
- assertEquals(String.format("Failed to verify item ad %d %d, %d", i, y, x),
+ assertEquals(String.format("Failed to verify item at %d %d, %d", i, y, x),
id, c.getLong(0));
total++;
}
@@ -388,4 +391,53 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
getMockContentResolver().insert(LauncherSettings.Favorites.CONTENT_URI, values);
return id;
}
+
+ public void testMultiStepMigration_small_to_large() throws Exception {
+ MultiStepMigrationTaskVerifier verifier = new MultiStepMigrationTaskVerifier();
+ verifier.migrate(new Point(3, 3), new Point(5, 5));
+ verifier.assertCompleted();
+ }
+
+ public void testMultiStepMigration_large_to_small() throws Exception {
+ MultiStepMigrationTaskVerifier verifier = new MultiStepMigrationTaskVerifier(
+ 5, 5, 4, 4,
+ 4, 4, 3, 4
+ );
+ verifier.migrate(new Point(5, 5), new Point(3, 4));
+ verifier.assertCompleted();
+ }
+
+ public void testMultiStepMigration_zig_zag() throws Exception {
+ MultiStepMigrationTaskVerifier verifier = new MultiStepMigrationTaskVerifier(
+ 5, 7, 4, 7,
+ 4, 7, 3, 7
+ );
+ verifier.migrate(new Point(5, 5), new Point(3, 7));
+ verifier.assertCompleted();
+ }
+
+ private static class MultiStepMigrationTaskVerifier extends MultiStepMigrationTask {
+
+ private final LinkedList<Point> mPoints;
+
+ public MultiStepMigrationTaskVerifier(int... points) {
+ super(null, null);
+
+ mPoints = new LinkedList<>();
+ for (int i = 0; i < points.length; i += 2) {
+ mPoints.add(new Point(points[i], points[i + 1]));
+ }
+ }
+
+ @Override
+ protected boolean runStepTask(Point sourceSize, Point nextSize) throws Exception {
+ assertEquals(sourceSize, mPoints.poll());
+ assertEquals(nextSize, mPoints.poll());
+ return false;
+ }
+
+ public void assertCompleted() {
+ assertTrue(mPoints.isEmpty());
+ }
+ }
}