Loading packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialog.kt +16 −6 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.R import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.settings.SecureSettings Loading @@ -48,6 +49,7 @@ class FontScalingDialog( private val systemSettings: SystemSettings, private val secureSettings: SecureSettings, private val systemClock: SystemClock, private val userTracker: UserTracker, @Main mainHandler: Handler, @Background private val backgroundDelayableExecutor: DelayableExecutor ) : SystemUIDialog(context) { Loading Loading @@ -98,7 +100,8 @@ class FontScalingDialog( seekBarWithIconButtonsView.setMax((strEntryValues).size - 1) val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, 1.0f) val currentScale = systemSettings.getFloatForUser(Settings.System.FONT_SCALE, 1.0f, userTracker.userId) lastProgress.set(fontSizeValueToIndex(currentScale)) seekBarWithIconButtonsView.setProgress(lastProgress.get()) Loading Loading @@ -195,18 +198,25 @@ class FontScalingDialog( @WorkerThread fun updateFontScale() { systemSettings.putString(Settings.System.FONT_SCALE, strEntryValues[lastProgress.get()]) systemSettings.putStringForUser( Settings.System.FONT_SCALE, strEntryValues[lastProgress.get()], userTracker.userId ) } @WorkerThread fun updateSecureSettingsIfNeeded() { if ( secureSettings.getString(Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED) != ON secureSettings.getStringForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, userTracker.userId ) != ON ) { secureSettings.putString( secureSettings.putStringForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, ON ON, userTracker.userId ) } } Loading packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt +21 −3 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.SystemSettings Loading @@ -57,11 +59,13 @@ constructor( statusBarStateController: StatusBarStateController, activityStarter: ActivityStarter, qsLogger: QSLogger, private val keyguardStateController: KeyguardStateController, private val dialogLaunchAnimator: DialogLaunchAnimator, private val systemSettings: SystemSettings, private val secureSettings: SecureSettings, private val systemClock: SystemClock, private val featureFlags: FeatureFlags, private val userTracker: UserTracker, @Background private val backgroundDelayableExecutor: DelayableExecutor ) : QSTileImpl<QSTile.State?>( Loading @@ -86,26 +90,40 @@ constructor( } override fun handleClick(view: View?) { mUiHandler.post { // We animate from the touched view only if we are not on the keyguard val animateFromView: Boolean = view != null && !keyguardStateController.isShowing val runnable = Runnable { val dialog: SystemUIDialog = FontScalingDialog( mContext, systemSettings, secureSettings, systemClock, userTracker, mainHandler, backgroundDelayableExecutor ) if (view != null) { if (animateFromView) { dialogLaunchAnimator.showFromView( dialog, view, view!!, DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG) ) } else { dialog.show() } } mainHandler.post { mActivityStarter.executeRunnableDismissingKeyguard( runnable, /* cancelAction= */ null, /* dismissShade= */ true, /* afterKeyguardGone= */ true, /* deferred= */ false ) } } override fun handleUpdateState(state: QSTile.State?, arg: Any?) { Loading packages/SystemUI/tests/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogTest.kt +43 −9 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import androidx.test.filters.SmallTest import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView import com.android.systemui.settings.UserTracker import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.whenever Loading @@ -38,6 +39,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.spy import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations Loading @@ -63,6 +65,7 @@ class FontScalingDialogTest : SysuiTestCase() { .getResources() .getStringArray(com.android.settingslib.R.array.entryvalues_font_size) @Mock private lateinit var userTracker: UserTracker @Captor private lateinit var seekBarChangeCaptor: ArgumentCaptor<SeekBar.OnSeekBarChangeListener> Loading @@ -72,7 +75,7 @@ class FontScalingDialogTest : SysuiTestCase() { val mainHandler = Handler(TestableLooper.get(this).getLooper()) systemSettings = FakeSettings() // Guarantee that the systemSettings always starts with the default font scale. systemSettings.putFloat(Settings.System.FONT_SCALE, 1.0f) systemSettings.putFloatForUser(Settings.System.FONT_SCALE, 1.0f, userTracker.userId) secureSettings = FakeSettings() systemClock = FakeSystemClock() backgroundDelayableExecutor = FakeExecutor(systemClock) Loading @@ -82,6 +85,7 @@ class FontScalingDialogTest : SysuiTestCase() { systemSettings, secureSettings, systemClock, userTracker, mainHandler, backgroundDelayableExecutor ) Loading @@ -93,7 +97,12 @@ class FontScalingDialogTest : SysuiTestCase() { val seekBar: SeekBar = fontScalingDialog.findViewById<SeekBar>(R.id.seekbar)!! val progress: Int = seekBar.getProgress() val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(currentScale).isEqualTo(fontSizeValueArray[progress].toFloat()) Loading @@ -119,7 +128,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.advanceClockToNext() backgroundDelayableExecutor.runAllReady() val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(seekBar.getProgress()).isEqualTo(1) assertThat(currentScale).isEqualTo(fontSizeValueArray[1].toFloat()) Loading @@ -145,7 +159,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.advanceClockToNext() backgroundDelayableExecutor.runAllReady() val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(seekBar.getProgress()).isEqualTo(fontSizeValueArray.size - 2) assertThat(currentScale) .isEqualTo(fontSizeValueArray[fontSizeValueArray.size - 2].toFloat()) Loading @@ -159,16 +178,21 @@ class FontScalingDialogTest : SysuiTestCase() { val seekBarWithIconButtonsView: SeekBarWithIconButtonsView = fontScalingDialog.findViewById(R.id.font_scaling_slider)!! secureSettings.putInt(Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, OFF) secureSettings.putIntForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, OFF, userTracker.userId ) // Default seekbar progress for font size is 1, set it to another progress 0 seekBarWithIconButtonsView.setProgress(0) backgroundDelayableExecutor.runAllReady() val currentSettings = secureSettings.getInt( secureSettings.getIntForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, /* def = */ OFF /* def = */ OFF, userTracker.userId ) assertThat(currentSettings).isEqualTo(ON) Loading Loading @@ -199,7 +223,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.runAllReady() // Verify that the scale of font size remains the default value 1.0f. var systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) var systemScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(systemScale).isEqualTo(1.0f) // Simulate releasing the finger from the seekbar. Loading @@ -209,7 +238,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.runAllReady() // Verify that the scale of font size has been updated. systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) systemScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(systemScale).isEqualTo(fontSizeValueArray[0].toFloat()) fontScalingDialog.dismiss() Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt +42 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq Loading @@ -44,8 +46,11 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.anyBoolean import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations Loading @@ -61,6 +66,8 @@ class FontScalingTileTest : SysuiTestCase() { @Mock private lateinit var qsLogger: QSLogger @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator @Mock private lateinit var uiEventLogger: QsEventLogger @Mock private lateinit var userTracker: UserTracker @Mock private lateinit var keyguardStateController: KeyguardStateController private lateinit var testableLooper: TestableLooper private lateinit var systemClock: FakeSystemClock Loading @@ -69,6 +76,8 @@ class FontScalingTileTest : SysuiTestCase() { val featureFlags = FakeFeatureFlags() @Captor private lateinit var argumentCaptor: ArgumentCaptor<Runnable> @Before fun setUp() { MockitoAnnotations.initMocks(this) Loading @@ -88,11 +97,13 @@ class FontScalingTileTest : SysuiTestCase() { statusBarStateController, activityStarter, qsLogger, keyguardStateController, dialogLaunchAnimator, FakeSettings(), FakeSettings(), FakeSystemClock(), featureFlags, userTracker, backgroundDelayableExecutor, ) fontScalingTile.initialize() Loading Loading @@ -124,14 +135,44 @@ class FontScalingTileTest : SysuiTestCase() { } @Test fun clickTile_showDialog() { fun clickTile_screenUnlocked_showDialogAnimationFromView() { `when`(keyguardStateController.isShowing).thenReturn(false) val view = View(context) fontScalingTile.click(view) testableLooper.processAllMessages() verify(activityStarter) .executeRunnableDismissingKeyguard( argumentCaptor.capture(), eq(null), eq(true), eq(true), eq(false) ) argumentCaptor.value.run() verify(dialogLaunchAnimator).showFromView(any(), eq(view), nullable(), anyBoolean()) } @Test fun clickTile_onLockScreen_neverShowDialogAnimationFromView() { `when`(keyguardStateController.isShowing).thenReturn(true) val view = View(context) fontScalingTile.click(view) testableLooper.processAllMessages() verify(activityStarter) .executeRunnableDismissingKeyguard( argumentCaptor.capture(), eq(null), eq(true), eq(true), eq(false) ) argumentCaptor.value.run() verify(dialogLaunchAnimator, never()) .showFromView(any(), eq(view), nullable(), anyBoolean()) } @Test fun getLongClickIntent_getExpectedIntent() { val intent: Intent? = fontScalingTile.getLongClickIntent() Loading Loading
packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialog.kt +16 −6 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.R import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.settings.SecureSettings Loading @@ -48,6 +49,7 @@ class FontScalingDialog( private val systemSettings: SystemSettings, private val secureSettings: SecureSettings, private val systemClock: SystemClock, private val userTracker: UserTracker, @Main mainHandler: Handler, @Background private val backgroundDelayableExecutor: DelayableExecutor ) : SystemUIDialog(context) { Loading Loading @@ -98,7 +100,8 @@ class FontScalingDialog( seekBarWithIconButtonsView.setMax((strEntryValues).size - 1) val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, 1.0f) val currentScale = systemSettings.getFloatForUser(Settings.System.FONT_SCALE, 1.0f, userTracker.userId) lastProgress.set(fontSizeValueToIndex(currentScale)) seekBarWithIconButtonsView.setProgress(lastProgress.get()) Loading Loading @@ -195,18 +198,25 @@ class FontScalingDialog( @WorkerThread fun updateFontScale() { systemSettings.putString(Settings.System.FONT_SCALE, strEntryValues[lastProgress.get()]) systemSettings.putStringForUser( Settings.System.FONT_SCALE, strEntryValues[lastProgress.get()], userTracker.userId ) } @WorkerThread fun updateSecureSettingsIfNeeded() { if ( secureSettings.getString(Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED) != ON secureSettings.getStringForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, userTracker.userId ) != ON ) { secureSettings.putString( secureSettings.putStringForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, ON ON, userTracker.userId ) } } Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt +21 −3 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.SystemUIDialog import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.SystemSettings Loading @@ -57,11 +59,13 @@ constructor( statusBarStateController: StatusBarStateController, activityStarter: ActivityStarter, qsLogger: QSLogger, private val keyguardStateController: KeyguardStateController, private val dialogLaunchAnimator: DialogLaunchAnimator, private val systemSettings: SystemSettings, private val secureSettings: SecureSettings, private val systemClock: SystemClock, private val featureFlags: FeatureFlags, private val userTracker: UserTracker, @Background private val backgroundDelayableExecutor: DelayableExecutor ) : QSTileImpl<QSTile.State?>( Loading @@ -86,26 +90,40 @@ constructor( } override fun handleClick(view: View?) { mUiHandler.post { // We animate from the touched view only if we are not on the keyguard val animateFromView: Boolean = view != null && !keyguardStateController.isShowing val runnable = Runnable { val dialog: SystemUIDialog = FontScalingDialog( mContext, systemSettings, secureSettings, systemClock, userTracker, mainHandler, backgroundDelayableExecutor ) if (view != null) { if (animateFromView) { dialogLaunchAnimator.showFromView( dialog, view, view!!, DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG) ) } else { dialog.show() } } mainHandler.post { mActivityStarter.executeRunnableDismissingKeyguard( runnable, /* cancelAction= */ null, /* dismissShade= */ true, /* afterKeyguardGone= */ true, /* deferred= */ false ) } } override fun handleUpdateState(state: QSTile.State?, arg: Any?) { Loading
packages/SystemUI/tests/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogTest.kt +43 −9 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import androidx.test.filters.SmallTest import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView import com.android.systemui.settings.UserTracker import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.whenever Loading @@ -38,6 +39,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.spy import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations Loading @@ -63,6 +65,7 @@ class FontScalingDialogTest : SysuiTestCase() { .getResources() .getStringArray(com.android.settingslib.R.array.entryvalues_font_size) @Mock private lateinit var userTracker: UserTracker @Captor private lateinit var seekBarChangeCaptor: ArgumentCaptor<SeekBar.OnSeekBarChangeListener> Loading @@ -72,7 +75,7 @@ class FontScalingDialogTest : SysuiTestCase() { val mainHandler = Handler(TestableLooper.get(this).getLooper()) systemSettings = FakeSettings() // Guarantee that the systemSettings always starts with the default font scale. systemSettings.putFloat(Settings.System.FONT_SCALE, 1.0f) systemSettings.putFloatForUser(Settings.System.FONT_SCALE, 1.0f, userTracker.userId) secureSettings = FakeSettings() systemClock = FakeSystemClock() backgroundDelayableExecutor = FakeExecutor(systemClock) Loading @@ -82,6 +85,7 @@ class FontScalingDialogTest : SysuiTestCase() { systemSettings, secureSettings, systemClock, userTracker, mainHandler, backgroundDelayableExecutor ) Loading @@ -93,7 +97,12 @@ class FontScalingDialogTest : SysuiTestCase() { val seekBar: SeekBar = fontScalingDialog.findViewById<SeekBar>(R.id.seekbar)!! val progress: Int = seekBar.getProgress() val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(currentScale).isEqualTo(fontSizeValueArray[progress].toFloat()) Loading @@ -119,7 +128,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.advanceClockToNext() backgroundDelayableExecutor.runAllReady() val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(seekBar.getProgress()).isEqualTo(1) assertThat(currentScale).isEqualTo(fontSizeValueArray[1].toFloat()) Loading @@ -145,7 +159,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.advanceClockToNext() backgroundDelayableExecutor.runAllReady() val currentScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) val currentScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(seekBar.getProgress()).isEqualTo(fontSizeValueArray.size - 2) assertThat(currentScale) .isEqualTo(fontSizeValueArray[fontSizeValueArray.size - 2].toFloat()) Loading @@ -159,16 +178,21 @@ class FontScalingDialogTest : SysuiTestCase() { val seekBarWithIconButtonsView: SeekBarWithIconButtonsView = fontScalingDialog.findViewById(R.id.font_scaling_slider)!! secureSettings.putInt(Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, OFF) secureSettings.putIntForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, OFF, userTracker.userId ) // Default seekbar progress for font size is 1, set it to another progress 0 seekBarWithIconButtonsView.setProgress(0) backgroundDelayableExecutor.runAllReady() val currentSettings = secureSettings.getInt( secureSettings.getIntForUser( Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, /* def = */ OFF /* def = */ OFF, userTracker.userId ) assertThat(currentSettings).isEqualTo(ON) Loading Loading @@ -199,7 +223,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.runAllReady() // Verify that the scale of font size remains the default value 1.0f. var systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) var systemScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(systemScale).isEqualTo(1.0f) // Simulate releasing the finger from the seekbar. Loading @@ -209,7 +238,12 @@ class FontScalingDialogTest : SysuiTestCase() { backgroundDelayableExecutor.runAllReady() // Verify that the scale of font size has been updated. systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f) systemScale = systemSettings.getFloatForUser( Settings.System.FONT_SCALE, /* def= */ 1.0f, userTracker.userId ) assertThat(systemScale).isEqualTo(fontSizeValueArray[0].toFloat()) fontScalingDialog.dismiss() Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt +42 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq Loading @@ -44,8 +46,11 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.anyBoolean import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations Loading @@ -61,6 +66,8 @@ class FontScalingTileTest : SysuiTestCase() { @Mock private lateinit var qsLogger: QSLogger @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator @Mock private lateinit var uiEventLogger: QsEventLogger @Mock private lateinit var userTracker: UserTracker @Mock private lateinit var keyguardStateController: KeyguardStateController private lateinit var testableLooper: TestableLooper private lateinit var systemClock: FakeSystemClock Loading @@ -69,6 +76,8 @@ class FontScalingTileTest : SysuiTestCase() { val featureFlags = FakeFeatureFlags() @Captor private lateinit var argumentCaptor: ArgumentCaptor<Runnable> @Before fun setUp() { MockitoAnnotations.initMocks(this) Loading @@ -88,11 +97,13 @@ class FontScalingTileTest : SysuiTestCase() { statusBarStateController, activityStarter, qsLogger, keyguardStateController, dialogLaunchAnimator, FakeSettings(), FakeSettings(), FakeSystemClock(), featureFlags, userTracker, backgroundDelayableExecutor, ) fontScalingTile.initialize() Loading Loading @@ -124,14 +135,44 @@ class FontScalingTileTest : SysuiTestCase() { } @Test fun clickTile_showDialog() { fun clickTile_screenUnlocked_showDialogAnimationFromView() { `when`(keyguardStateController.isShowing).thenReturn(false) val view = View(context) fontScalingTile.click(view) testableLooper.processAllMessages() verify(activityStarter) .executeRunnableDismissingKeyguard( argumentCaptor.capture(), eq(null), eq(true), eq(true), eq(false) ) argumentCaptor.value.run() verify(dialogLaunchAnimator).showFromView(any(), eq(view), nullable(), anyBoolean()) } @Test fun clickTile_onLockScreen_neverShowDialogAnimationFromView() { `when`(keyguardStateController.isShowing).thenReturn(true) val view = View(context) fontScalingTile.click(view) testableLooper.processAllMessages() verify(activityStarter) .executeRunnableDismissingKeyguard( argumentCaptor.capture(), eq(null), eq(true), eq(true), eq(false) ) argumentCaptor.value.run() verify(dialogLaunchAnimator, never()) .showFromView(any(), eq(view), nullable(), anyBoolean()) } @Test fun getLongClickIntent_getExpectedIntent() { val intent: Intent? = fontScalingTile.getLongClickIntent() Loading