/* * 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.accessibility.textreading.ui import android.app.settings.SettingsEnums import android.content.ComponentName import android.content.Context import androidx.test.core.app.ApplicationProvider import com.android.settings.R import com.android.settings.Settings import com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY import com.android.settings.accessibility.TextReadingPreferenceFragment import com.android.settings.flags.Flags import com.android.settings.testutils2.SettingsCatalystTestCase import com.google.common.truth.Truth.assertThat import org.junit.Test /** Tests for [TextReadingScreen]. */ class TextReadingScreenTest : SettingsCatalystTestCase() { private val context: Context = ApplicationProvider.getApplicationContext() override val preferenceScreenCreator = TextReadingScreen() override val flagName: String get() = Flags.FLAG_CATALYST_TEXT_READING_SCREEN @Test override fun migration() {} @Test fun key() { assertThat(preferenceScreenCreator.key).isEqualTo(TextReadingScreen.KEY) } @Test fun isIndexable() { assertThat(preferenceScreenCreator.indexable).isTrue() } @Test fun getTitle() { assertThat(preferenceScreenCreator.title) .isEqualTo(R.string.accessibility_text_reading_options_title) } @Test fun getSummary() { assertThat(preferenceScreenCreator.summary) .isEqualTo(R.string.accessibility_text_reading_options_subtext) } @Test fun getMetricsCategory() { assertThat(preferenceScreenCreator.metricsCategory) .isEqualTo(SettingsEnums.ACCESSIBILITY_TEXT_READING_OPTIONS) } @Test fun getHighlightMenuKey() { assertThat(preferenceScreenCreator.highlightMenuKey).isEqualTo(R.string.menu_key_display) } @Test fun getLaunchIntent() { val expectedComponent = ComponentName(context, Settings.TextReadingSettingsActivity::class.java) val launchIntent = preferenceScreenCreator.getLaunchIntent(context, preferenceScreenCreator) assertThat(launchIntent).isNotNull() assertThat(launchIntent!!.component).isEqualTo(expectedComponent) assertThat(launchIntent.getStringExtra(EXTRA_FRAGMENT_ARG_KEY)) .isEqualTo(TextReadingScreen.KEY) } @Test fun getEntryPoint() { assertThat(preferenceScreenCreator.entryPoint) .isEqualTo(TextReadingPreferenceFragment.EntryPoint.DISPLAY_SETTINGS) } @Test fun getIcon() { assertThat(preferenceScreenCreator.icon).isEqualTo(0) } }