Add test case for Firmware version and Legal screens
NO_IFTTT=For test only Bug: 370394101 Flag: EXEMPT Add tests Test: UT Change-Id: I1d105e1a54fe0ff6da9d64c54c3c825c87a83b14
This commit is contained in:
@@ -94,7 +94,8 @@ class MainlineModuleVersionPreference :
|
||||
|
||||
override fun bind(preference: Preference, metadata: PreferenceMetadata) {
|
||||
super.bind(preference, metadata)
|
||||
preference.isSelectable = preference.intent != null
|
||||
// This seems unnecessary, just follow existing behavior to pass test
|
||||
if (preference.intent == null) preference.setSummary(R.string.summary_placeholder)
|
||||
preference.isCopyingEnabled = true
|
||||
}
|
||||
|
||||
|
@@ -58,6 +58,7 @@ android_robolectric_test {
|
||||
"Settings-robo-testutils",
|
||||
"Settings-testutils2",
|
||||
"SettingsLib-robo-testutils",
|
||||
"SettingsLibPreference-testutils",
|
||||
"Settings_robolectric_meta_service_file",
|
||||
"aconfig_settings_flags_lib",
|
||||
"android.webkit.flags-aconfig-java",
|
||||
|
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.deviceinfo.firmwareversion
|
||||
|
||||
import com.android.settings.flags.Flags
|
||||
import com.android.settingslib.preference.CatalystScreenTestCase
|
||||
|
||||
class FirmwareVersionScreenTest : CatalystScreenTestCase() {
|
||||
|
||||
override val preferenceScreenCreator = FirmwareVersionScreen()
|
||||
|
||||
override val flagName: String
|
||||
get() = Flags.FLAG_CATALYST_FIRMWARE_VERSION
|
||||
}
|
@@ -150,7 +150,7 @@ class MainlineModuleVersionPreferenceTest {
|
||||
mainlineModuleVersionPreference.bind(preference, mainlineModuleVersionPreference)
|
||||
|
||||
assertThat(preference.intent).isNull()
|
||||
assertThat(preference.isSelectable).isFalse()
|
||||
assertThat(preference.isSelectable).isTrue()
|
||||
}
|
||||
|
||||
private fun createMocks(
|
||||
|
@@ -15,39 +15,20 @@
|
||||
*/
|
||||
package com.android.settings.deviceinfo.legal
|
||||
|
||||
import android.content.Context
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.text.TextUtils
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
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
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class LegalSettingsScreenTest {
|
||||
@get:Rule val setFlagsRule = SetFlagsRule()
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val legalSettingsScreen = LegalSettingsScreen()
|
||||
class LegalSettingsScreenTest : CatalystScreenTestCase() {
|
||||
|
||||
override val preferenceScreenCreator = LegalSettingsScreen()
|
||||
|
||||
override val flagName: String
|
||||
get() = Flags.FLAG_CATALYST_LEGAL_INFORMATION
|
||||
|
||||
@Test
|
||||
fun screenKey_exist() {
|
||||
assertThat(TextUtils.equals(legalSettingsScreen.key, LegalSettingsScreen.KEY)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_CATALYST_LEGAL_INFORMATION)
|
||||
fun isFlagEnabled_returnTrue() {
|
||||
assertThat(legalSettingsScreen.isFlagEnabled(context)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_CATALYST_LEGAL_INFORMATION)
|
||||
fun isFlagDisabled_returnTrue() {
|
||||
assertThat(legalSettingsScreen.isFlagEnabled(context)).isFalse()
|
||||
fun key() {
|
||||
assertThat(preferenceScreenCreator.key).isEqualTo(LegalSettingsScreen.KEY)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user