diff options
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProviderTest.kt | 76 |
1 files changed, 49 insertions, 27 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProviderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProviderTest.kt index e32260d4c42b..1759fb794bd6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProviderTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProviderTest.kt @@ -19,9 +19,9 @@ package com.android.systemui.statusbar.phone import android.content.Context import android.content.res.Configuration import android.graphics.Rect -import android.test.suitebuilder.annotation.SmallTest import android.view.Display import android.view.DisplayCutout +import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.policy.ConfigurationController @@ -463,16 +463,10 @@ class StatusBarContentInsetsProviderTest : SysuiTestCase() { val provider = StatusBarContentInsetsProvider(contextMock, configurationController, mock(DumpManager::class.java)) - givenDisplay( - screenBounds = Rect(0, 0, 1080, 2160), - displayUniqueId = "1" - ) + configuration.windowConfiguration.maxBounds = Rect(0, 0, 1080, 2160) val firstDisplayInsets = provider.getStatusBarContentAreaForRotation(ROTATION_NONE) - givenDisplay( - screenBounds = Rect(0, 0, 800, 600), - displayUniqueId = "2" - ) - configurationController.onConfigurationChanged(configuration) + + configuration.windowConfiguration.maxBounds = Rect(0, 0, 800, 600) // WHEN: get insets on the second display val secondDisplayInsets = provider.getStatusBarContentAreaForRotation(ROTATION_NONE) @@ -487,23 +481,15 @@ class StatusBarContentInsetsProviderTest : SysuiTestCase() { // get insets and switch back val provider = StatusBarContentInsetsProvider(contextMock, configurationController, mock(DumpManager::class.java)) - givenDisplay( - screenBounds = Rect(0, 0, 1080, 2160), - displayUniqueId = "1" - ) + + configuration.windowConfiguration.maxBounds = Rect(0, 0, 1080, 2160) val firstDisplayInsetsFirstCall = provider .getStatusBarContentAreaForRotation(ROTATION_NONE) - givenDisplay( - screenBounds = Rect(0, 0, 800, 600), - displayUniqueId = "2" - ) - configurationController.onConfigurationChanged(configuration) + + configuration.windowConfiguration.maxBounds = Rect(0, 0, 800, 600) provider.getStatusBarContentAreaForRotation(ROTATION_NONE) - givenDisplay( - screenBounds = Rect(0, 0, 1080, 2160), - displayUniqueId = "1" - ) - configurationController.onConfigurationChanged(configuration) + + configuration.windowConfiguration.maxBounds = Rect(0, 0, 1080, 2160) // WHEN: get insets on the first display again val firstDisplayInsetsSecondCall = provider @@ -538,9 +524,45 @@ class StatusBarContentInsetsProviderTest : SysuiTestCase() { assertThat(listener.triggered).isTrue() } - private fun givenDisplay(screenBounds: Rect, displayUniqueId: String) { - `when`(display.uniqueId).thenReturn(displayUniqueId) - configuration.windowConfiguration.maxBounds = screenBounds + @Test + fun onDensityOrFontScaleChanged_listenerNotified() { + configuration.densityDpi = 12 + val provider = StatusBarContentInsetsProvider(contextMock, configurationController, + mock(DumpManager::class.java)) + val listener = object : StatusBarContentInsetsChangedListener { + var triggered = false + + override fun onStatusBarContentInsetsChanged() { + triggered = true + } + } + provider.addCallback(listener) + + // WHEN the config is updated + configuration.densityDpi = 20 + configurationController.onConfigurationChanged(configuration) + + // THEN the listener is notified + assertThat(listener.triggered).isTrue() + } + + @Test + fun onThemeChanged_listenerNotified() { + val provider = StatusBarContentInsetsProvider(contextMock, configurationController, + mock(DumpManager::class.java)) + val listener = object : StatusBarContentInsetsChangedListener { + var triggered = false + + override fun onStatusBarContentInsetsChanged() { + triggered = true + } + } + provider.addCallback(listener) + + configurationController.notifyThemeChanged() + + // THEN the listener is notified + assertThat(listener.triggered).isTrue() } private fun assertRects( |