1 /* 2 * Copyright (C) 2018 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.RemoteException; 20 import android.provider.Settings; 21 import android.support.test.uiautomator.UiDevice; 22 import android.system.helpers.SettingsHelper; 23 24 import androidx.test.InstrumentationRegistry; 25 import androidx.test.filters.MediumTest; 26 import androidx.test.runner.AndroidJUnit4; 27 28 import com.android.settings.ui.testutils.SettingsTestUtils; 29 30 import org.junit.After; 31 import org.junit.Before; 32 import org.junit.Test; 33 import org.junit.runner.RunWith; 34 35 @MediumTest 36 @RunWith(AndroidJUnit4.class) 37 public class SecuritySettingsLaunchTest { 38 39 // Items we really want to always show 40 private static final String[] CATEGORIES = new String[]{ 41 "Security status", 42 "Device security", 43 "Privacy", 44 }; 45 46 private UiDevice mDevice; 47 private SettingsHelper mHelper; 48 49 @Before setUp()50 public void setUp() throws Exception { 51 mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); 52 mHelper = SettingsHelper.getInstance(); 53 try { 54 mDevice.setOrientationNatural(); 55 } catch (RemoteException e) { 56 throw new RuntimeException("failed to freeze device orientaion", e); 57 } 58 } 59 60 @After tearDown()61 public void tearDown() throws Exception { 62 // Go back to home for next test. 63 mDevice.pressHome(); 64 } 65 66 @Test launchSecuritySettings()67 public void launchSecuritySettings() throws Exception { 68 // Launch Settings 69 SettingsHelper.launchSettingsPage( 70 InstrumentationRegistry.getTargetContext(), Settings.ACTION_SECURITY_SETTINGS); 71 mHelper.scrollVert(false); 72 for (String category : CATEGORIES) { 73 SettingsTestUtils.assertTitleMatch(mDevice, category); 74 } 75 } 76 } 77