summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java')
-rw-r--r--tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java86
1 files changed, 60 insertions, 26 deletions
diff --git a/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java b/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java
index c9170bc..93c2b01 100644
--- a/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java
+++ b/tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java
@@ -42,7 +42,6 @@ import android.content.Context;
import android.content.Intent;
import androidx.recyclerview.widget.RecyclerView;
-import androidx.test.espresso.contrib.RecyclerViewActions;
import androidx.test.espresso.intent.Intents;
import androidx.test.filters.MediumTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
@@ -55,7 +54,6 @@ import com.android.wallpaper.model.PickerIntentFactory;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.model.WallpaperRotationInitializer;
import com.android.wallpaper.model.WallpaperRotationInitializer.RotationInitializationState;
-import com.android.wallpaper.module.FormFactorChecker;
import com.android.wallpaper.module.Injector;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.testing.TestCategoryProvider;
@@ -63,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;
@@ -99,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);
@@ -116,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
@@ -136,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);
@@ -176,22 +180,6 @@ public class IndividualPickerActivityTest {
}
@Test
- public void testClickTile_Mobile_showsBottomActions() {
- mTestFormFactorChecker.setFormFactor(FormFactorChecker.FORM_FACTOR_MOBILE);
-
- setActivityWithMockWallpapers(false /* isRotationEnabled */,
- WallpaperRotationInitializer.ROTATION_NOT_INITIALIZED);
- getActivity();
-
- onView(withId(R.id.wallpaper_grid)).perform(
- RecyclerViewActions.actionOnItemAtPosition(0, click()));
-
- onView(withId(R.id.action_back)).check(matches(isDisplayed()));
- onView(withId(R.id.action_information)).check(matches(isDisplayed()));
- onView(withId(R.id.action_apply)).check(matches(isDisplayed()));
- }
-
- @Test
public void testClickDailyRefreshAction_ShowsStartRotationDialog() {
setActivityWithMockWallpapers(true /* isRotationEnabled */,
WallpaperRotationInitializer.ROTATION_NOT_INITIALIZED);
@@ -406,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));
+
+ CustomShapeImageView thumbnail =
+ recyclerView.findViewHolderForAdapterPosition(index)
+ .itemView.findViewById(R.id.thumbnail);
+
+ // Assert that only the selected wallpaper has a clipped thumbnail.
+ assertEquals(thumbnail.getClipped(), index == selectedWallpaperIndex);
+ }
+ }
}