1 /* 2 * Copyright (C) 2017 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.notification; 18 19 import android.app.Instrumentation; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.provider.Settings; 23 import android.support.test.InstrumentationRegistry; 24 import android.support.test.espresso.matcher.ViewMatchers; 25 import android.support.test.filters.SmallTest; 26 import android.support.test.runner.AndroidJUnit4; 27 28 import com.android.settings.R; 29 30 import org.junit.Before; 31 import org.junit.Test; 32 import org.junit.runner.RunWith; 33 34 import static android.support.test.espresso.Espresso.onView; 35 import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist; 36 import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; 37 import static android.support.test.espresso.matcher.ViewMatchers.withId; 38 import static org.hamcrest.Matchers.allOf; 39 40 @RunWith(AndroidJUnit4.class) 41 @SmallTest 42 public class AppNotificationSettingsTest { 43 44 private Context mTargetContext; 45 private Instrumentation mInstrumentation; 46 47 @Before setUp()48 public void setUp() { 49 mInstrumentation = InstrumentationRegistry.getInstrumentation(); 50 mTargetContext = mInstrumentation.getTargetContext(); 51 } 52 53 @Test launchNotificationSetting_shouldNotHaveAppInfoLink()54 public void launchNotificationSetting_shouldNotHaveAppInfoLink() { 55 final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS) 56 .putExtra(Settings.EXTRA_APP_PACKAGE, mTargetContext.getPackageName()); 57 58 mInstrumentation.startActivitySync(intent); 59 60 onView(allOf(withId(R.id.left_button), 61 withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) 62 .check(doesNotExist()); 63 } 64 65 } 66