blob: 2f417adb707722e5952ca0d476672cea0310e17f [file] [log] [blame]
jackqdyulei8accac92016-09-13 15:07:42 -07001/*
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
17package com.android.settingslib.drawer;
18
Fan Zhang34106dd2017-04-21 10:06:21 -070019import static android.support.test.espresso.Espresso.onView;
20import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
Fan Zhang34106dd2017-04-21 10:06:21 -070021import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
22
Fan Zhang6abd12972016-09-16 08:46:09 -070023import android.app.Instrumentation;
24import android.content.Intent;
25import android.support.test.InstrumentationRegistry;
jackqdyulei8accac92016-09-13 15:07:42 -070026import android.support.test.filters.SmallTest;
27import android.support.test.rule.ActivityTestRule;
28import android.support.test.runner.AndroidJUnit4;
Fan Zhang6abd12972016-09-16 08:46:09 -070029
jackqdyulei8accac92016-09-13 15:07:42 -070030import org.junit.Before;
31import org.junit.Rule;
32import org.junit.Test;
33import org.junit.runner.RunWith;
jackqdyulei8accac92016-09-13 15:07:42 -070034import org.mockito.MockitoAnnotations;
35
36@RunWith(AndroidJUnit4.class)
37@SmallTest
38public class SettingsDrawerActivityTest {
Fan Zhang11b65072016-10-31 16:45:00 -070039
jackqdyulei8accac92016-09-13 15:07:42 -070040 @Rule
41 public ActivityTestRule<TestActivity> mActivityRule =
42 new ActivityTestRule<>(TestActivity.class, true, true);
43
jackqdyulei8accac92016-09-13 15:07:42 -070044 @Before
45 public void setUp() throws Exception {
46 MockitoAnnotations.initMocks(this);
jackqdyulei8accac92016-09-13 15:07:42 -070047 }
48
Fan Zhang6abd12972016-09-16 08:46:09 -070049 @Test
Fan Zhang92a26132018-02-06 14:24:18 -080050 public void startActivity_doNotShowNavUp() {
51 final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
52 final Intent intent = new Intent(instrumentation.getTargetContext(), TestActivity.class)
53 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Fan Zhang6abd12972016-09-16 08:46:09 -070054 instrumentation.startActivitySync(intent);
55
Fan Zhangcf439c02017-01-03 13:06:11 -080056 onView(withContentDescription(com.android.internal.R.string.action_bar_up_description))
Fan Zhang6abd12972016-09-16 08:46:09 -070057 .check(doesNotExist());
58 }
59
jackqdyulei8accac92016-09-13 15:07:42 -070060 /**
61 * Test Activity in this test.
62 *
63 * Use this activity because SettingsDrawerActivity hasn't been registered in its
64 * AndroidManifest.xml
65 */
Fan Zhang92a26132018-02-06 14:24:18 -080066 public static class TestActivity extends SettingsDrawerActivity {
67 }
jackqdyulei8accac92016-09-13 15:07:42 -070068}