diff options
| author | Tianguang Zhang <tianguang@google.com> | 2021-03-03 20:21:26 +0100 |
|---|---|---|
| committer | Ching Sung Li <chriscsli@google.com> | 2021-03-08 07:44:12 +0000 |
| commit | d913daf28f2c399b9f4a9ff1dc2dafcb64b75720 (patch) | |
| tree | 493a004748aa1d501c65159dc41b07e0c4964127 /tests | |
| parent | 6ea4b95b7b0e0e51eb13a985bb51282505a44921 (diff) | |
| download | platform_packages_apps_WallpaperPicker2-d913daf28f2c399b9f4a9ff1dc2dafcb64b75720.tar.gz platform_packages_apps_WallpaperPicker2-d913daf28f2c399b9f4a9ff1dc2dafcb64b75720.tar.bz2 platform_packages_apps_WallpaperPicker2-d913daf28f2c399b9f4a9ff1dc2dafcb64b75720.zip | |
Round thumbnail for individual picker
This CL configures IndividualPickerFragment to use a round thumbnail for the applied wallpaper.
Screenshots
* Day - https://screenshot.googleplex.com/3tzed4USi4VyR38.png
* Night - https://screenshot.googleplex.com/mcF6nM4NQwWuWTk.png
Bug: 178745862
Fixes: 178745862
Test: added in IndividualPickerActivityTest.java
Change-Id: Icb9142d2c3d43e312be8c9c0b1647eedededef87
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java | 68 |
1 files changed, 60 insertions, 8 deletions
diff --git a/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java b/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java index a4decf4..902a42c 100644 --- a/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java +++ b/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java @@ -61,6 +61,7 @@ import com.android.wallpaper.testing.TestFormFactorChecker; import com.android.wallpaper.testing.TestInjector; import com.android.wallpaper.testing.TestWallpaperCategory; import com.android.wallpaper.testing.TestWallpaperInfo; +import com.android.wallpaper.testing.TestWallpaperPreferences; import com.android.wallpaper.testing.TestWallpaperRotationInitializer; import org.hamcrest.Matcher; @@ -97,6 +98,9 @@ public class IndividualPickerActivityTest { private TestWallpaperCategory mTestCategory; + private TestWallpaperPreferences mPreferences; + private ArrayList<WallpaperInfo> mWallpapers; + @Rule public ActivityTestRule<IndividualPickerActivity> mActivityRule = new ActivityTestRule<>(IndividualPickerActivity.class, false, false); @@ -114,6 +118,15 @@ public class IndividualPickerActivityTest { sWallpaperInfo1.setAttributions(Arrays.asList( "Attribution 0", "Attribution 1", "Attribution 2")); + + sWallpaperInfo1.setCollectionId("collection"); + + mPreferences = (TestWallpaperPreferences) mInjector.getPreferences(context); + + mWallpapers = new ArrayList<>(); + mWallpapers.add(sWallpaperInfo1); + mWallpapers.add(sWallpaperInfo2); + mWallpapers.add(sWallpaperInfo3); } @After @@ -134,15 +147,8 @@ public class IndividualPickerActivityTest { private void setActivityWithMockWallpapers(boolean isRotationEnabled, @RotationInitializationState int rotationState) { - sWallpaperInfo1.setCollectionId("collection"); - - ArrayList<WallpaperInfo> wallpapers = new ArrayList<>(); - wallpapers.add(sWallpaperInfo1); - wallpapers.add(sWallpaperInfo2); - wallpapers.add(sWallpaperInfo3); - mTestCategory = new TestWallpaperCategory( - "Test category", "collection", wallpapers, 0 /* priority */); + "Test category", "collection", mWallpapers, 0 /* priority */); mTestCategory.setIsRotationEnabled(isRotationEnabled); mTestCategory.setRotationInitializationState(rotationState); @@ -388,4 +394,50 @@ public class IndividualPickerActivityTest { assertEquals("Attribution 0", holder.itemView.findViewById(R.id.tile) .getContentDescription()); } + + /** + * Tests whether the selected wallpaper has a clipped thumbnail: first wallpaper. + */ + @Test + public void testSelectFirstWallpaper_ShowsClippedThumbnail() { + runSelectWallpaperTest(0); + } + + /** + * Tests whether the selected wallpaper has a clipped thumbnail: second wallpaper. + */ + @Test + public void testSelectSecondWallpaper_ShowsClippedThumbnail() { + runSelectWallpaperTest(1); + } + + /** + * Tests whether the selected wallpaper has a clipped thumbnail: third wallpaper. + */ + @Test + public void testSelectThirdWallpaper_ShowsClippedThumbnail() { + runSelectWallpaperTest(2); + } + + private void runSelectWallpaperTest(int selectedWallpaperIndex) { + mPreferences.setHomeWallpaperRemoteId( + mWallpapers.get(selectedWallpaperIndex).getWallpaperId()); + + setActivityWithMockWallpapers(false /* isRotationEnabled */, + WallpaperRotationInitializer.ROTATION_NOT_INITIALIZED); + IndividualPickerActivity activity = getActivity(); + + RecyclerView recyclerView = activity.findViewById(R.id.wallpaper_grid); + + for (int index = 0; index < 3; index++) { + assertNotNull(recyclerView.findViewHolderForAdapterPosition(index)); + + CircularImageView thumbnail = + recyclerView.findViewHolderForAdapterPosition(index) + .itemView.findViewById(R.id.thumbnail); + + // Assert that only the selected wallpaper has a clipped thumbnail. + assertEquals(thumbnail.getClipped(), index == selectedWallpaperIndex); + } + } } |
