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
17package com.android.settingslib.drawer;
18
19import static android.support.test.espresso.Espresso.onView;
20import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
21import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
22
23import android.app.Instrumentation;
24import android.content.Intent;
25import android.support.test.InstrumentationRegistry;
26import android.support.test.filters.SmallTest;
27import android.support.test.rule.ActivityTestRule;
28import android.support.test.runner.AndroidJUnit4;
29
30import org.junit.Before;
31import org.junit.Rule;
32import org.junit.Test;
33import org.junit.runner.RunWith;
34import org.mockito.MockitoAnnotations;
35
36@RunWith(AndroidJUnit4.class)
37@SmallTest
38public class SettingsDrawerActivityTest {
39
40    @Rule
41    public ActivityTestRule<TestActivity> mActivityRule =
42            new ActivityTestRule<>(TestActivity.class, true, true);
43
44    @Before
45    public void setUp() throws Exception {
46        MockitoAnnotations.initMocks(this);
47    }
48
49    @Test
50    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);
54        instrumentation.startActivitySync(intent);
55
56        onView(withContentDescription(com.android.internal.R.string.action_bar_up_description))
57                .check(doesNotExist());
58    }
59
60    /**
61     * Test Activity in this test.
62     *
63     * Use this activity because SettingsDrawerActivity hasn't been registered in its
64     * AndroidManifest.xml
65     */
66    public static class TestActivity extends SettingsDrawerActivity {
67    }
68}
69