summaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2021-10-06 22:54:03 +0000
committerXin Li <delphij@google.com>2021-10-06 22:54:03 +0000
commitc875da62344b3fe6e8827c995fd52d674ab5e5f6 (patch)
tree4da1225c5be4fd0cb544c0d872a41b3a3b57aae6 /tests/src
parentf0a63b0eb5ec8f58dfb822cc3c8e1a0cc33ca03a (diff)
parent6b3db4ce8b89d324b362f83a2e1ffa656e432b4a (diff)
downloadplatform_packages_apps_WallpaperPicker2-c875da62344b3fe6e8827c995fd52d674ab5e5f6.tar.gz
platform_packages_apps_WallpaperPicker2-c875da62344b3fe6e8827c995fd52d674ab5e5f6.tar.bz2
platform_packages_apps_WallpaperPicker2-c875da62344b3fe6e8827c995fd52d674ab5e5f6.zip
Merge Android 12HEADmaster
Bug: 202323961 Merged-In: I5cd8ed57adca2a94eafd78a73a82e3c495846a29 Change-Id: I76f7416e711e5164143de4f0573b6b682d9f4161
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/wallpaper/picker/PreviewActivityTest.java30
-rw-r--r--tests/src/com/android/wallpaper/picker/individual/IndividualPickerActivityTest.java86
-rw-r--r--tests/src/com/android/wallpaper/testing/TestAsset.java2
-rw-r--r--tests/src/com/android/wallpaper/testing/TestBitmapCropper.java4
-rw-r--r--tests/src/com/android/wallpaper/testing/TestCategoryProvider.java8
-rw-r--r--tests/src/com/android/wallpaper/testing/TestInjector.java11
-rw-r--r--tests/src/com/android/wallpaper/testing/TestUserEventLogger.java4
-rw-r--r--tests/src/com/android/wallpaper/testing/TestWallpaperInfo.java2
8 files changed, 101 insertions, 46 deletions
diff --git a/tests/src/com/android/wallpaper/picker/PreviewActivityTest.java b/tests/src/com/android/wallpaper/picker/PreviewActivityTest.java
index 98855fa..eee481a 100644
--- a/tests/src/com/android/wallpaper/picker/PreviewActivityTest.java
+++ b/tests/src/com/android/wallpaper/picker/PreviewActivityTest.java
@@ -147,7 +147,7 @@ public class PreviewActivityTest {
launchActivityIntentWithMockWallpaper();
assertNull(mWallpaperPersister.getCurrentHomeWallpaper());
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Home screen".
onView(withText(R.string.set_wallpaper_home_screen_destination)).perform(click());
@@ -175,7 +175,7 @@ public class PreviewActivityTest {
launchActivityIntentWithMockWallpaper();
assertNull(mWallpaperPersister.getCurrentLockWallpaper());
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Lock screen."
onView(withText(R.string.set_wallpaper_lock_screen_destination)).perform(click());
@@ -204,7 +204,7 @@ public class PreviewActivityTest {
assertNull(mWallpaperPersister.getCurrentHomeWallpaper());
assertNull(mWallpaperPersister.getCurrentLockWallpaper());
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Both."
onView(withText(R.string.set_wallpaper_both_destination)).perform(click());
@@ -237,7 +237,7 @@ public class PreviewActivityTest {
mWallpaperPersister.setFailNextCall(true);
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Home screen."
onView(withText(R.string.set_wallpaper_home_screen_destination)).perform(click());
@@ -276,7 +276,7 @@ public class PreviewActivityTest {
mWallpaperPersister.setFailNextCall(true);
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Lock screen."
onView(withText(R.string.set_wallpaper_lock_screen_destination)).perform(click());
@@ -316,7 +316,7 @@ public class PreviewActivityTest {
mWallpaperPersister.setFailNextCall(true);
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Both."
onView(withText(R.string.set_wallpaper_both_destination)).perform(click());
@@ -355,7 +355,7 @@ public class PreviewActivityTest {
// Scale should not have a meaningful value before clicking "set wallpaper".
assertTrue(mWallpaperPersister.getScale() < 0);
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Home screen".
onView(withText(R.string.set_wallpaper_home_screen_destination)).perform(click());
@@ -380,7 +380,7 @@ public class PreviewActivityTest {
throws Throwable {
launchActivityIntentWithMockWallpaper();
mWallpaperPersister.setFailNextCall(true);
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Home screen".
onView(withText(R.string.set_wallpaper_home_screen_destination)).perform(click());
@@ -396,7 +396,7 @@ public class PreviewActivityTest {
@Test
public void testClickSetWallpaper_ShowsDestinationDialog() {
launchActivityIntentWithMockWallpaper();
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
onView(withText(R.string.set_wallpaper_dialog_message)).check(matches(isDisplayed()));
}
@@ -451,7 +451,7 @@ public class PreviewActivityTest {
assertNotEquals(ActivityInfo.SCREEN_ORIENTATION_LOCKED, activity.getRequestedOrientation());
// Show SetWallpaperDialog.
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
assertEquals(ActivityInfo.SCREEN_ORIENTATION_LOCKED, activity.getRequestedOrientation());
@@ -468,7 +468,7 @@ public class PreviewActivityTest {
assertNotEquals(ActivityInfo.SCREEN_ORIENTATION_LOCKED, activity.getRequestedOrientation());
// Show SetWallpaperDialog.
- onView(withId(R.id.preview_attribution_pane_set_wallpaper_button)).perform(click());
+ onView(withId(R.id.action_apply)).perform(click());
// Destination dialog is shown; click "Home screen".
onView(withText(R.string.set_wallpaper_home_screen_destination)).perform(click());
@@ -486,13 +486,13 @@ public class PreviewActivityTest {
launchActivityIntentWithMockWallpaper();
PreviewActivity activity = mActivityRule.getActivity();
- TextView titleView = activity.findViewById(R.id.preview_attribution_pane_title);
+ TextView titleView = activity.findViewById(R.id.wallpaper_info_title);
assertEquals("Title", titleView.getText());
- TextView subtitle1View = activity.findViewById(R.id.preview_attribution_pane_subtitle1);
+ TextView subtitle1View = activity.findViewById(R.id.wallpaper_info_subtitle1);
assertEquals("Subtitle 1", subtitle1View.getText());
- TextView subtitle2View = activity.findViewById(R.id.preview_attribution_pane_subtitle2);
+ TextView subtitle2View = activity.findViewById(R.id.wallpaper_info_subtitle2);
assertEquals("Subtitle 2", subtitle2View.getText());
}
@@ -522,7 +522,7 @@ public class PreviewActivityTest {
mExploreIntentChecker.setViewHandlerExists(false);
launchActivityIntentWithMockWallpaper();
- onView(withId(R.id.preview_attribution_pane_explore_button)).check(
+ onView(withId(R.id.wallpaper_info_explore_button)).check(
matches(not(isDisplayed())));
}
}
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);
+ }
+ }
}
diff --git a/tests/src/com/android/wallpaper/testing/TestAsset.java b/tests/src/com/android/wallpaper/testing/TestAsset.java
index 368919a..505946a 100644
--- a/tests/src/com/android/wallpaper/testing/TestAsset.java
+++ b/tests/src/com/android/wallpaper/testing/TestAsset.java
@@ -62,7 +62,7 @@ public final class TestAsset extends Asset {
@Override
public void decodeBitmapRegion(Rect unused, int targetWidth, int targetHeight,
- BitmapReceiver receiver) {
+ boolean shouldAdjustForRtl, BitmapReceiver receiver) {
receiver.onBitmapDecoded(mBitmap);
}
diff --git a/tests/src/com/android/wallpaper/testing/TestBitmapCropper.java b/tests/src/com/android/wallpaper/testing/TestBitmapCropper.java
index 7daeeab..778561d 100644
--- a/tests/src/com/android/wallpaper/testing/TestBitmapCropper.java
+++ b/tests/src/com/android/wallpaper/testing/TestBitmapCropper.java
@@ -34,7 +34,7 @@ public class TestBitmapCropper implements BitmapCropper {
}
@Override
- public void cropAndScaleBitmap(Asset asset, float scale, Rect cropRect,
+ public void cropAndScaleBitmap(Asset asset, float scale, Rect cropRect, boolean adjustRtl,
Callback callback) {
if (mFailNextCall) {
callback.onError(null /* throwable */);
@@ -47,7 +47,7 @@ public class TestBitmapCropper implements BitmapCropper {
Math.round((float) cropRect.right / scale),
Math.round((float) cropRect.bottom / scale));
- asset.decodeBitmapRegion(scaledCropRect, cropRect.width(), cropRect.height(),
+ asset.decodeBitmapRegion(scaledCropRect, cropRect.width(), cropRect.height(), adjustRtl,
new BitmapReceiver() {
@Override
public void onBitmapDecoded(Bitmap bitmap) {
diff --git a/tests/src/com/android/wallpaper/testing/TestCategoryProvider.java b/tests/src/com/android/wallpaper/testing/TestCategoryProvider.java
index 9354958..d6fa979 100644
--- a/tests/src/com/android/wallpaper/testing/TestCategoryProvider.java
+++ b/tests/src/com/android/wallpaper/testing/TestCategoryProvider.java
@@ -93,8 +93,14 @@ public class TestCategoryProvider implements CategoryProvider {
}
@Override
- public void resetIfNeeded() {
+ public boolean resetIfNeeded() {
mCategories.clear();
+ return true;
+ }
+
+ @Override
+ public boolean isFeaturedCollectionAvailable() {
+ return false;
}
/** Returns a list of test Category objects used by this TestCategoryProvider. */
diff --git a/tests/src/com/android/wallpaper/testing/TestInjector.java b/tests/src/com/android/wallpaper/testing/TestInjector.java
index 9b7927f..fd9f68a 100644
--- a/tests/src/com/android/wallpaper/testing/TestInjector.java
+++ b/tests/src/com/android/wallpaper/testing/TestInjector.java
@@ -31,6 +31,7 @@ import com.android.wallpaper.module.DefaultLiveWallpaperInfoFactory;
import com.android.wallpaper.module.DrawableLayerResolver;
import com.android.wallpaper.module.ExploreIntentChecker;
import com.android.wallpaper.module.FormFactorChecker;
+import com.android.wallpaper.module.CustomizationSections;
import com.android.wallpaper.module.Injector;
import com.android.wallpaper.module.LiveWallpaperInfoFactory;
import com.android.wallpaper.module.LoggingOptInStatusProvider;
@@ -243,10 +244,20 @@ public class TestInjector implements Injector {
}
@Override
+ public String getDownloadableIntentAction() {
+ return null;
+ }
+
+ @Override
public PerformanceMonitor getPerformanceMonitor() {
if (mPerformanceMonitor == null) {
mPerformanceMonitor = new TestPerformanceMonitor();
}
return mPerformanceMonitor;
}
+
+ @Override
+ public CustomizationSections getCustomizationSections() {
+ return null;
+ }
}
diff --git a/tests/src/com/android/wallpaper/testing/TestUserEventLogger.java b/tests/src/com/android/wallpaper/testing/TestUserEventLogger.java
index 63ae94e..bb70e93 100644
--- a/tests/src/com/android/wallpaper/testing/TestUserEventLogger.java
+++ b/tests/src/com/android/wallpaper/testing/TestUserEventLogger.java
@@ -15,6 +15,8 @@
*/
package com.android.wallpaper.testing;
+import android.content.Intent;
+
import com.android.wallpaper.module.UserEventLogger;
import com.android.wallpaper.module.WallpaperPersister.WallpaperPosition;
@@ -66,7 +68,7 @@ public class TestUserEventLogger implements UserEventLogger {
}
@Override
- public void logAppLaunched() {
+ public void logAppLaunched(Intent launchSource) {
// Do nothing.
}
diff --git a/tests/src/com/android/wallpaper/testing/TestWallpaperInfo.java b/tests/src/com/android/wallpaper/testing/TestWallpaperInfo.java
index c0ccee6..c4328c5 100644
--- a/tests/src/com/android/wallpaper/testing/TestWallpaperInfo.java
+++ b/tests/src/com/android/wallpaper/testing/TestWallpaperInfo.java
@@ -73,6 +73,7 @@ public class TestWallpaperInfo extends WallpaperInfo {
}
private TestWallpaperInfo(Parcel in) {
+ super(in);
mPixelColor = in.readInt();
mAttributions = in.createStringArrayList();
mActionUrl = in.readString();
@@ -200,6 +201,7 @@ public class TestWallpaperInfo extends WallpaperInfo {
@Override
public void writeToParcel(Parcel parcel, int i) {
+ super.writeToParcel(parcel, i);
parcel.writeInt(mPixelColor);
parcel.writeStringList(mAttributions);
parcel.writeString(mActionUrl);