Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a108459 authored by Jacky Wang's avatar Jacky Wang Committed by Android (Google) Code Review
Browse files

Merge "Add test case for Firmware version and Legal screens" into main

parents 451dc11e 2ce3671e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
    }

+1 −0
Original line number Diff line number Diff line
@@ -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",
+28 −0
Original line number Diff line number Diff line
/*
 * 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
}
+1 −1
Original line number Diff line number Diff line
@@ -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(
+7 −26
Original line number Diff line number Diff line
@@ -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() {

    @Test
    fun screenKey_exist() {
        assertThat(TextUtils.equals(legalSettingsScreen.key, LegalSettingsScreen.KEY)).isTrue()
    }
    override val preferenceScreenCreator = LegalSettingsScreen()

    @Test
    @EnableFlags(Flags.FLAG_CATALYST_LEGAL_INFORMATION)
    fun isFlagEnabled_returnTrue() {
        assertThat(legalSettingsScreen.isFlagEnabled(context)).isTrue()
    }
    override val flagName: String
        get() = Flags.FLAG_CATALYST_LEGAL_INFORMATION

    @Test
    @DisableFlags(Flags.FLAG_CATALYST_LEGAL_INFORMATION)
    fun isFlagDisabled_returnTrue() {
        assertThat(legalSettingsScreen.isFlagEnabled(context)).isFalse()
    fun key() {
        assertThat(preferenceScreenCreator.key).isEqualTo(LegalSettingsScreen.KEY)
    }
}