diff options
| author | Xin Li <delphij@google.com> | 2021-10-06 22:54:01 +0000 |
|---|---|---|
| committer | Xin Li <delphij@google.com> | 2021-10-06 22:54:01 +0000 |
| commit | 87db83485149dc09bdd380baeb408596dd48be86 (patch) | |
| tree | 2ddfa698a449abb3ed320ebd46c1ccecc213209a /tests/src/com/android | |
| parent | 9f16f41671262aea445c727f8571142d1213284a (diff) | |
| parent | 4cd48dfca4871c129ab6a55b3232662d18253d47 (diff) | |
| download | platform_packages_apps_ThemePicker-master.tar.gz platform_packages_apps_ThemePicker-master.tar.bz2 platform_packages_apps_ThemePicker-master.zip | |
Bug: 202323961
Merged-In: I90187609ee9ba51bca7036a89ce46f1c08bbf1b3
Change-Id: I8fc8724cd6a74ff828fcc1b46c9916b9f5a93d03
Diffstat (limited to 'tests/src/com/android')
| -rw-r--r-- | tests/src/com/android/customization/picker/CustomizationPickerActivityTest.java | 160 | ||||
| -rw-r--r-- | tests/src/com/android/customization/testing/TestThemesUserEventLogger.java | 5 |
2 files changed, 5 insertions, 160 deletions
diff --git a/tests/src/com/android/customization/picker/CustomizationPickerActivityTest.java b/tests/src/com/android/customization/picker/CustomizationPickerActivityTest.java deleted file mode 100644 index dd1581a..0000000 --- a/tests/src/com/android/customization/picker/CustomizationPickerActivityTest.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.android.customization.picker; - -import static android.content.Intent.ACTION_SET_WALLPAPER; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.intent.matcher.IntentMatchers.filterEquals; -import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.isSelected; -import static androidx.test.espresso.matcher.ViewMatchers.withId; - -import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_FLAVOR_EXTRA; -import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_FOCUS; -import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_ONLY; - -import static org.junit.Assert.assertTrue; - -import android.content.Intent; -import android.text.TextUtils; - -import androidx.fragment.app.Fragment; -import androidx.test.espresso.intent.Intents; -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; -import androidx.test.rule.ActivityTestRule; - -import com.android.customization.picker.theme.ThemeFragment; -import com.android.customization.testing.TestCustomizationInjector; -import com.android.customization.testing.TestThemeManager; -import com.android.wallpaper.R; -import com.android.wallpaper.module.InjectorProvider; -import com.android.wallpaper.picker.CategoryFragment; -import com.android.wallpaper.picker.TopLevelPickerActivity; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * Tests for {@link CustomizationPickerActivity}. - */ -@RunWith(AndroidJUnit4ClassRunner.class) -public class CustomizationPickerActivityTest { - - @Rule - public ActivityTestRule<CustomizationPickerActivity> mActivityRule = - new ActivityTestRule<>(CustomizationPickerActivity.class, false, false); - - @Before - public void setUp() { - Intents.init(); - } - - @After - public void tearDown() { - mActivityRule.finishActivity(); - Intents.release(); - } - - @Test - public void launchActivity_doesNotSupportCustomization_launchesTopLevelPickerActivity() { - TestThemeManager.setAvailable(false); - - launchActivity(); - - Intents.intended(filterEquals(new Intent(mActivityRule.getActivity(), - TopLevelPickerActivity.class))); - } - - // ---------------------------------------------------------------------- - // Tests for customization supports. - // ---------------------------------------------------------------------- - - @Test - public void launchActivity_themeManagerIsAvailable_NavBarShowsStyleAndWallpaperItem() { - TestThemeManager.setAvailable(true); - - launchActivity(); - - onView(withId(R.id.nav_theme)).check(matches(isCompletelyDisplayed())); - onView(withId(R.id.nav_wallpaper)).check(matches(isCompletelyDisplayed())); - onView(withId(R.id.nav_clock)).check(doesNotExist()); - onView(withId(R.id.nav_grid)).check(doesNotExist()); - } - - @Test - public void launchActivity_navigateToTheStyleTabByDefault() { - TestThemeManager.setAvailable(true); - - launchActivity(); - - onView(withId(R.id.nav_theme)).check(matches(isSelected())); - assertTrue(getCurrentShowingFragment() instanceof ThemeFragment); - } - - @Test - public void launchActivity_withExtraWallpaperOnly_launchesTopLevelPickerActivity() { - TestThemeManager.setAvailable(true); - - launchActivityWithFlavorExtra(WALLPAPER_ONLY); - - // While receiving WALLPAPER_ONLY extra, it should launch TopLevelPickerActivity whatever it - // supports customization. - Intents.intended(filterEquals(new Intent(mActivityRule.getActivity(), - TopLevelPickerActivity.class))); - } - - @Test - public void clickStyleButton_showsThemeFragment() { - TestThemeManager.setAvailable(true); - launchActivity(); - - onView(withId(R.id.nav_theme)).perform(click()); - - onView(withId(R.id.nav_theme)).check(matches(isSelected())); - assertTrue(getCurrentShowingFragment() instanceof ThemeFragment); - } - - @Test - public void clickWallpaperButton_showsCategoryFragment() { - TestThemeManager.setAvailable(true); - launchActivity(); - - onView(withId(R.id.nav_wallpaper)).perform(click()); - - onView(withId(R.id.nav_wallpaper)).check(matches(isSelected())); - assertTrue(getCurrentShowingFragment() instanceof CategoryFragment); - } - - @Test - public void launchActivity_withExtraWallpaperFocus_navigateToTheWallpaperTab() { - TestThemeManager.setAvailable(true); - - launchActivityWithFlavorExtra(WALLPAPER_FOCUS); - - onView(withId(R.id.nav_wallpaper)).check(matches(isSelected())); - assertTrue(getCurrentShowingFragment() instanceof CategoryFragment); - } - - private void launchActivity() { - launchActivityWithFlavorExtra(""); - } - - private void launchActivityWithFlavorExtra(String extra) { - InjectorProvider.setInjector(new TestCustomizationInjector()); - Intent intent = new Intent(ACTION_SET_WALLPAPER); - if (!TextUtils.isEmpty(extra)) { - intent.putExtra(WALLPAPER_FLAVOR_EXTRA, extra); - } - mActivityRule.launchActivity(intent); - } - - private Fragment getCurrentShowingFragment() { - return mActivityRule.getActivity().getSupportFragmentManager() - .findFragmentById(R.id.fragment_container); - } -} diff --git a/tests/src/com/android/customization/testing/TestThemesUserEventLogger.java b/tests/src/com/android/customization/testing/TestThemesUserEventLogger.java index 3600192..9969e6e 100644 --- a/tests/src/com/android/customization/testing/TestThemesUserEventLogger.java +++ b/tests/src/com/android/customization/testing/TestThemesUserEventLogger.java @@ -22,6 +22,11 @@ public class TestThemesUserEventLogger extends TestUserEventLogger } @Override + public void logColorApplied(int action, int colorIndex) { + // Do nothing. + } + + @Override public void logClockSelected(Clockface clock) { // Do nothing. } |
