1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings.ui
18 
19 import android.os.Flags
20 import android.platform.test.annotations.RequiresFlagsEnabled
21 import android.platform.test.flag.junit.DeviceFlagsValueProvider
22 import android.provider.Settings
23 import androidx.test.ext.junit.runners.AndroidJUnit4
24 import androidx.test.platform.app.InstrumentationRegistry
25 import androidx.test.uiautomator.UiDevice
26 import com.android.settings.ui.testutils.SettingsTestUtils.assertHasTexts
27 import com.android.settings.ui.testutils.SettingsTestUtils.startMainActivityFromHomeScreen
28 import org.junit.Before
29 import org.junit.Rule
30 import org.junit.Test
31 import org.junit.runner.RunWith
32 
33 
34 @RunWith(AndroidJUnit4::class)
35 class SecuritySettingsTest {
36     private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
37 
38     @get:Rule
39     public val mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule()
40 
41     @Before
setUpnull42     fun setUp() {
43         device.startMainActivityFromHomeScreen(Settings.ACTION_SECURITY_SETTINGS)
44     }
45 
46     @Test
hasTextsnull47     fun hasTexts() {
48         device.assertHasTexts(ON_SCREEN_TEXTS)
49     }
50 
51     @Test
52     @RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
53             android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES)
privateSpace_ifFlagONnull54     fun privateSpace_ifFlagON() {
55         device.assertHasTexts(listOf("Private Space"))
56     }
57 
58     private companion object {
59         // Items we really want to always show
60         val ON_SCREEN_TEXTS = listOf(
61             "Device unlock",
62             "Privacy",
63             "More security & privacy",
64         )
65     }
66 }
67