Merge changes from topic "catalyst" into main
* changes: [Catalyst] Use hybrid mode for sound screen [Catalyst] Use hybrid mode for display screen [Catalyst] Support hybrid mode
This commit is contained in:
@@ -17,24 +17,32 @@ package com.android.settings.display
|
||||
|
||||
import android.content.ContextWrapper
|
||||
import android.content.res.Resources
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.internal.widget.LockPatternUtils
|
||||
import com.android.settings.flags.Flags
|
||||
import com.android.settings.testutils.FakeFeatureFactory
|
||||
import com.android.settingslib.preference.CatalystScreenTestCase
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.stub
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class DisplayScreenTest {
|
||||
val preferenceScreenCreator = DisplayScreen()
|
||||
class DisplayScreenTest : CatalystScreenTestCase() {
|
||||
|
||||
override val preferenceScreenCreator = DisplayScreen()
|
||||
|
||||
override val flagName: String
|
||||
get() = Flags.FLAG_CATALYST_DISPLAY_SETTINGS_SCREEN
|
||||
|
||||
private val mockResources = mock<Resources>()
|
||||
|
||||
private val context =
|
||||
object : ContextWrapper(ApplicationProvider.getApplicationContext()) {
|
||||
private val contextWrapper =
|
||||
object : ContextWrapper(context) {
|
||||
override fun getResources(): Resources = mockResources
|
||||
}
|
||||
|
||||
@@ -47,13 +55,25 @@ class DisplayScreenTest {
|
||||
fun isAvailable_configTrue_shouldReturnTrue() {
|
||||
mockResources.stub { on { getBoolean(anyInt()) } doReturn true }
|
||||
|
||||
assertThat(preferenceScreenCreator.isAvailable(context)).isTrue()
|
||||
assertThat(preferenceScreenCreator.isAvailable(contextWrapper)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isAvailable_configFalse_shouldReturnFalse() {
|
||||
mockResources.stub { on { getBoolean(anyInt()) } doReturn false }
|
||||
|
||||
assertThat(preferenceScreenCreator.isAvailable(context)).isFalse()
|
||||
assertThat(preferenceScreenCreator.isAvailable(contextWrapper)).isFalse()
|
||||
}
|
||||
|
||||
override fun migration() {
|
||||
// avoid UnsupportedOperationException when getDisplay from context
|
||||
System.setProperty("robolectric.createActivityContexts", "true")
|
||||
|
||||
val lockPatternUtils = mock<LockPatternUtils> { on { isSecure(anyInt()) } doReturn true }
|
||||
FakeFeatureFactory.setupForTest().securityFeatureProvider.stub {
|
||||
on { getLockPatternUtils(any()) } doReturn lockPatternUtils
|
||||
}
|
||||
|
||||
super.migration()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,39 +15,23 @@
|
||||
*/
|
||||
package com.android.settings.notification
|
||||
|
||||
import android.content.Context
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.settings.flags.Flags
|
||||
import com.android.settingslib.preference.CatalystScreenTestCase
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class SoundScreenTest {
|
||||
@get:Rule val setFlagsRule = SetFlagsRule()
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val soundScreen = SoundScreen()
|
||||
class SoundScreenTest : CatalystScreenTestCase() {
|
||||
|
||||
override val preferenceScreenCreator = SoundScreen()
|
||||
|
||||
override val flagName: String
|
||||
get() = Flags.FLAG_CATALYST_SOUND_SCREEN
|
||||
|
||||
@Test
|
||||
fun key() {
|
||||
assertThat(soundScreen.key).isEqualTo(SoundScreen.KEY)
|
||||
assertThat(preferenceScreenCreator.key).isEqualTo(SoundScreen.KEY)
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_CATALYST_SOUND_SCREEN)
|
||||
fun isFlagEnabled_returnTrue() {
|
||||
assertThat(soundScreen.isFlagEnabled(context)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_CATALYST_SOUND_SCREEN)
|
||||
fun isFlagEnabled_returnFalse() {
|
||||
assertThat(soundScreen.isFlagEnabled(context)).isFalse()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user