diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-07-08 08:32:44 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-07-09 16:19:26 -0700 |
commit | a5c8a9eb666da16bc4c9ea4412868e22ace8d1f0 (patch) | |
tree | 1e612ea9a361beae540c943d18af1ad233fb0f5d /tests/src/com/android/launcher3 | |
parent | f03bd4f5470eed9808a0e6f345de94f4e578ae85 (diff) | |
download | android_packages_apps_Trebuchet-a5c8a9eb666da16bc4c9ea4412868e22ace8d1f0.tar.gz android_packages_apps_Trebuchet-a5c8a9eb666da16bc4c9ea4412868e22ace8d1f0.tar.bz2 android_packages_apps_Trebuchet-a5c8a9eb666da16bc4c9ea4412868e22ace8d1f0.zip |
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.
Bug: 28536314
Change-Id: Ibebfd7dd33aa2cbd9ca28d2d611dd0a4a5971444
Diffstat (limited to 'tests/src/com/android/launcher3')
-rw-r--r-- | tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java | 54 |
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()); + } + } } |