1 /* 2 * Copyright (C) 2016 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.dashboard; 18 19 import static androidx.test.espresso.Espresso.onView; 20 import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; 21 import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; 22 import static androidx.test.espresso.matcher.ViewMatchers.withId; 23 24 import static org.hamcrest.Matchers.allOf; 25 26 import android.app.Instrumentation; 27 import android.content.Context; 28 import android.content.Intent; 29 30 import androidx.test.InstrumentationRegistry; 31 import androidx.test.espresso.matcher.ViewMatchers.Visibility; 32 import androidx.test.filters.SmallTest; 33 import androidx.test.runner.AndroidJUnit4; 34 35 import com.android.settings.R; 36 37 import org.junit.Before; 38 import org.junit.Test; 39 import org.junit.runner.RunWith; 40 41 @RunWith(AndroidJUnit4.class) 42 @SmallTest 43 public class PreferenceThemeTest { 44 45 private Instrumentation mInstrumentation; 46 private Context mTargetContext; 47 private String mTargetPackage; 48 49 @Before setUp()50 public void setUp() throws Exception { 51 mInstrumentation = InstrumentationRegistry.getInstrumentation(); 52 mTargetContext = mInstrumentation.getTargetContext(); 53 mTargetPackage = mTargetContext.getPackageName(); 54 } 55 56 @Test startSetupWizardLockScreen_preferenceIconSpaceNotReserved()57 public void startSetupWizardLockScreen_preferenceIconSpaceNotReserved() { 58 launchSetupWizardLockScreen(); 59 // Icons should not be shown, and the frame should not occupy extra space. 60 onView(allOf(withId(R.id.icon_frame), withEffectiveVisibility(Visibility.VISIBLE))) 61 .check(doesNotExist()); 62 onView(withId(R.id.icon_container)).check(doesNotExist()); 63 } 64 launchSetupWizardLockScreen()65 private void launchSetupWizardLockScreen() { 66 final Intent settingsIntent = new Intent("com.android.settings.SETUP_LOCK_SCREEN") 67 .addCategory(Intent.CATEGORY_DEFAULT) 68 .setPackage(mTargetPackage) 69 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 70 InstrumentationRegistry.getInstrumentation().startActivitySync(settingsIntent); 71 } 72 } 73