Loading quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt +30 −16 Original line number Diff line number Diff line Loading @@ -20,9 +20,18 @@ import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.launcher3.LauncherPrefs import com.android.launcher3.LauncherPrefs.Companion.THEMED_ICONS import com.android.launcher3.LauncherPrefs.Companion.backedUpItem import com.android.launcher3.logging.InstanceId import com.android.launcher3.logging.StatsLogManager import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ADD_NEW_APPS_TO_HOME_SCREEN_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALL_APPS_SUGGESTIONS_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_ROTATION_DISABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_ROTATION_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NOTIFICATION_DOT_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_THEMED_ICON_DISABLED import com.google.common.truth.Truth.assertThat import org.junit.After import org.junit.Before Loading Loading @@ -52,18 +61,24 @@ class SettingsChangeLoggerTest { @Captor private lateinit var mEventCaptor: ArgumentCaptor<StatsLogManager.EventEnum> private var mDefaultThemedIcons = false @Before fun setUp() { MockitoAnnotations.initMocks(this) whenever(mStatsLogManager.logger()).doReturn(mMockLogger) whenever(mStatsLogManager.logger().withInstanceId(any())).doReturn(mMockLogger) mDefaultThemedIcons = LauncherPrefs.get(mContext).get(THEMED_ICONS) // To match the default value of THEMED_ICONS LauncherPrefs.get(mContext).put(THEMED_ICONS, false) mSystemUnderTest = SettingsChangeLogger(mContext, mStatsLogManager) } @After fun tearDown() { LauncherPrefs.get(mContext).put(THEMED_ICONS, mDefaultThemedIcons) mSystemUnderTest.close() } Loading @@ -87,7 +102,8 @@ class SettingsChangeLoggerTest { assertThat(capturedEvents.isNotEmpty()).isTrue() verifyDefaultEvent(capturedEvents) // pref_allowRotation false assertThat(capturedEvents.any { it.id == 616 }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_HOME_SCREEN_ROTATION_DISABLED.id }) .isTrue() } @Test Loading @@ -108,24 +124,22 @@ class SettingsChangeLoggerTest { val capturedEvents = mEventCaptor.allValues assertThat(capturedEvents.isNotEmpty()).isTrue() verifyDefaultEvent(capturedEvents) // pref_allowRotation true assertThat(capturedEvents.any { it.id == 615 }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_HOME_SCREEN_ROTATION_ENABLED.id }) .isTrue() } private fun verifyDefaultEvent(capturedEvents: MutableList<StatsLogManager.EventEnum>) { // LAUNCHER_NOTIFICATION_DOT_ENABLED assertThat(capturedEvents.any { it.id == 611 }).isTrue() // LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON assertThat(capturedEvents.any { it.id == 625 }).isTrue() // LAUNCHER_THEMED_ICON_DISABLED assertThat(capturedEvents.any { it.id == 837 }).isTrue() // pref_add_icon_to_home true assertThat(capturedEvents.any { it.id == 613 }).isTrue() // pref_overview_action_suggestions true assertThat(capturedEvents.any { it.id == 619 }).isTrue() // pref_smartspace_home_screen true assertThat(capturedEvents.any { it.id == 621 }).isTrue() // pref_enable_minus_one true assertThat(capturedEvents.any { it.id == LAUNCHER_NOTIFICATION_DOT_ENABLED.id }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON.id }) .isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_THEMED_ICON_DISABLED.id }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_ADD_NEW_APPS_TO_HOME_SCREEN_ENABLED.id }) .isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_ALL_APPS_SUGGESTIONS_ENABLED.id }) .isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED.id }) .isTrue() // LAUNCHER_GOOGLE_APP_SWIPE_LEFT_ENABLED assertThat(capturedEvents.any { it.id == 617 }).isTrue() } } tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt +14 −8 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.android.launcher3.LauncherPrefs import com.android.launcher3.LauncherPrefs.Companion.THEMED_ICONS import com.android.launcher3.LauncherPrefs.Companion.get import com.android.launcher3.icons.BaseIconFactory import com.android.launcher3.icons.FastBitmapDrawable Loading Loading @@ -51,6 +51,8 @@ class PreviewItemManagerTest { private lateinit var modelHelper: LauncherModelHelper private lateinit var folderIcon: FolderIcon private var defaultThemedIcons = false @Before fun setup() { getInstrumentation().runOnMainSync { Loading Loading @@ -127,16 +129,20 @@ class PreviewItemManagerTest { previewItemManager.mIconSize ) ) defaultThemedIcons = get(context).get(THEMED_ICONS) } @After @Throws(Exception::class) fun tearDown() { get(context).put(THEMED_ICONS, defaultThemedIcons) modelHelper.destroy() } @Test fun checkThemedIconWithThemingOn_iconShouldBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[0]) Loading @@ -146,7 +152,7 @@ class PreviewItemManagerTest { @Test fun checkThemedIconWithThemingOff_iconShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, false) get(context).put(THEMED_ICONS, false) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[0]) Loading @@ -156,7 +162,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithThemingOn_iconShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[1]) Loading @@ -166,7 +172,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithThemingOff_iconShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, false) get(context).put(THEMED_ICONS, false) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[1]) Loading @@ -176,7 +182,7 @@ class PreviewItemManagerTest { @Test fun checkThemedIconWithBadgeWithThemingOn_iconAndBadgeShouldBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[2]) Loading @@ -189,7 +195,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithBadgeWithThemingOn_badgeShouldBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[3]) Loading @@ -202,7 +208,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithBadgeWithThemingOff_iconAndBadgeShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, false) get(context).put(THEMED_ICONS, false) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[3]) Loading Loading
quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt +30 −16 Original line number Diff line number Diff line Loading @@ -20,9 +20,18 @@ import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.launcher3.LauncherPrefs import com.android.launcher3.LauncherPrefs.Companion.THEMED_ICONS import com.android.launcher3.LauncherPrefs.Companion.backedUpItem import com.android.launcher3.logging.InstanceId import com.android.launcher3.logging.StatsLogManager import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ADD_NEW_APPS_TO_HOME_SCREEN_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALL_APPS_SUGGESTIONS_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_ROTATION_DISABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_ROTATION_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NOTIFICATION_DOT_ENABLED import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_THEMED_ICON_DISABLED import com.google.common.truth.Truth.assertThat import org.junit.After import org.junit.Before Loading Loading @@ -52,18 +61,24 @@ class SettingsChangeLoggerTest { @Captor private lateinit var mEventCaptor: ArgumentCaptor<StatsLogManager.EventEnum> private var mDefaultThemedIcons = false @Before fun setUp() { MockitoAnnotations.initMocks(this) whenever(mStatsLogManager.logger()).doReturn(mMockLogger) whenever(mStatsLogManager.logger().withInstanceId(any())).doReturn(mMockLogger) mDefaultThemedIcons = LauncherPrefs.get(mContext).get(THEMED_ICONS) // To match the default value of THEMED_ICONS LauncherPrefs.get(mContext).put(THEMED_ICONS, false) mSystemUnderTest = SettingsChangeLogger(mContext, mStatsLogManager) } @After fun tearDown() { LauncherPrefs.get(mContext).put(THEMED_ICONS, mDefaultThemedIcons) mSystemUnderTest.close() } Loading @@ -87,7 +102,8 @@ class SettingsChangeLoggerTest { assertThat(capturedEvents.isNotEmpty()).isTrue() verifyDefaultEvent(capturedEvents) // pref_allowRotation false assertThat(capturedEvents.any { it.id == 616 }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_HOME_SCREEN_ROTATION_DISABLED.id }) .isTrue() } @Test Loading @@ -108,24 +124,22 @@ class SettingsChangeLoggerTest { val capturedEvents = mEventCaptor.allValues assertThat(capturedEvents.isNotEmpty()).isTrue() verifyDefaultEvent(capturedEvents) // pref_allowRotation true assertThat(capturedEvents.any { it.id == 615 }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_HOME_SCREEN_ROTATION_ENABLED.id }) .isTrue() } private fun verifyDefaultEvent(capturedEvents: MutableList<StatsLogManager.EventEnum>) { // LAUNCHER_NOTIFICATION_DOT_ENABLED assertThat(capturedEvents.any { it.id == 611 }).isTrue() // LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON assertThat(capturedEvents.any { it.id == 625 }).isTrue() // LAUNCHER_THEMED_ICON_DISABLED assertThat(capturedEvents.any { it.id == 837 }).isTrue() // pref_add_icon_to_home true assertThat(capturedEvents.any { it.id == 613 }).isTrue() // pref_overview_action_suggestions true assertThat(capturedEvents.any { it.id == 619 }).isTrue() // pref_smartspace_home_screen true assertThat(capturedEvents.any { it.id == 621 }).isTrue() // pref_enable_minus_one true assertThat(capturedEvents.any { it.id == LAUNCHER_NOTIFICATION_DOT_ENABLED.id }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON.id }) .isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_THEMED_ICON_DISABLED.id }).isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_ADD_NEW_APPS_TO_HOME_SCREEN_ENABLED.id }) .isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_ALL_APPS_SUGGESTIONS_ENABLED.id }) .isTrue() assertThat(capturedEvents.any { it.id == LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED.id }) .isTrue() // LAUNCHER_GOOGLE_APP_SWIPE_LEFT_ENABLED assertThat(capturedEvents.any { it.id == 617 }).isTrue() } }
tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt +14 −8 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.android.launcher3.LauncherPrefs import com.android.launcher3.LauncherPrefs.Companion.THEMED_ICONS import com.android.launcher3.LauncherPrefs.Companion.get import com.android.launcher3.icons.BaseIconFactory import com.android.launcher3.icons.FastBitmapDrawable Loading Loading @@ -51,6 +51,8 @@ class PreviewItemManagerTest { private lateinit var modelHelper: LauncherModelHelper private lateinit var folderIcon: FolderIcon private var defaultThemedIcons = false @Before fun setup() { getInstrumentation().runOnMainSync { Loading Loading @@ -127,16 +129,20 @@ class PreviewItemManagerTest { previewItemManager.mIconSize ) ) defaultThemedIcons = get(context).get(THEMED_ICONS) } @After @Throws(Exception::class) fun tearDown() { get(context).put(THEMED_ICONS, defaultThemedIcons) modelHelper.destroy() } @Test fun checkThemedIconWithThemingOn_iconShouldBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[0]) Loading @@ -146,7 +152,7 @@ class PreviewItemManagerTest { @Test fun checkThemedIconWithThemingOff_iconShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, false) get(context).put(THEMED_ICONS, false) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[0]) Loading @@ -156,7 +162,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithThemingOn_iconShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[1]) Loading @@ -166,7 +172,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithThemingOff_iconShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, false) get(context).put(THEMED_ICONS, false) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[1]) Loading @@ -176,7 +182,7 @@ class PreviewItemManagerTest { @Test fun checkThemedIconWithBadgeWithThemingOn_iconAndBadgeShouldBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[2]) Loading @@ -189,7 +195,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithBadgeWithThemingOn_badgeShouldBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, true) get(context).put(THEMED_ICONS, true) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[3]) Loading @@ -202,7 +208,7 @@ class PreviewItemManagerTest { @Test fun checkUnthemedIconWithBadgeWithThemingOff_iconAndBadgeShouldNotBeThemed() { get(context).put(LauncherPrefs.THEMED_ICONS, false) get(context).put(THEMED_ICONS, false) val drawingParams = PreviewItemDrawingParams(0f, 0f, 0f) previewItemManager.setDrawable(drawingParams, folderItems[3]) Loading