jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 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.settingslib.drawer; |
| 18 | |
Fan Zhang | 34106dd | 2017-04-21 10:06:21 -0700 | [diff] [blame] | 19 | import static android.support.test.espresso.Espresso.onView; |
| 20 | import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist; |
Fan Zhang | 34106dd | 2017-04-21 10:06:21 -0700 | [diff] [blame] | 21 | import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription; |
| 22 | |
Fan Zhang | 6abd1297 | 2016-09-16 08:46:09 -0700 | [diff] [blame] | 23 | import android.app.Instrumentation; |
| 24 | import android.content.Intent; |
| 25 | import android.support.test.InstrumentationRegistry; |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 26 | import android.support.test.filters.SmallTest; |
| 27 | import android.support.test.rule.ActivityTestRule; |
| 28 | import android.support.test.runner.AndroidJUnit4; |
Fan Zhang | 6abd1297 | 2016-09-16 08:46:09 -0700 | [diff] [blame] | 29 | |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 30 | import org.junit.Before; |
| 31 | import org.junit.Rule; |
| 32 | import org.junit.Test; |
| 33 | import org.junit.runner.RunWith; |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 34 | import org.mockito.MockitoAnnotations; |
| 35 | |
| 36 | @RunWith(AndroidJUnit4.class) |
| 37 | @SmallTest |
| 38 | public class SettingsDrawerActivityTest { |
Fan Zhang | 11b6507 | 2016-10-31 16:45:00 -0700 | [diff] [blame] | 39 | |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 40 | @Rule |
| 41 | public ActivityTestRule<TestActivity> mActivityRule = |
| 42 | new ActivityTestRule<>(TestActivity.class, true, true); |
| 43 | |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 44 | @Before |
| 45 | public void setUp() throws Exception { |
| 46 | MockitoAnnotations.initMocks(this); |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Fan Zhang | 6abd1297 | 2016-09-16 08:46:09 -0700 | [diff] [blame] | 49 | @Test |
Fan Zhang | 92a2613 | 2018-02-06 14:24:18 -0800 | [diff] [blame] | 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); |
Fan Zhang | 6abd1297 | 2016-09-16 08:46:09 -0700 | [diff] [blame] | 54 | instrumentation.startActivitySync(intent); |
| 55 | |
Fan Zhang | cf439c0 | 2017-01-03 13:06:11 -0800 | [diff] [blame] | 56 | onView(withContentDescription(com.android.internal.R.string.action_bar_up_description)) |
Fan Zhang | 6abd1297 | 2016-09-16 08:46:09 -0700 | [diff] [blame] | 57 | .check(doesNotExist()); |
| 58 | } |
| 59 | |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 60 | /** |
| 61 | * Test Activity in this test. |
| 62 | * |
| 63 | * Use this activity because SettingsDrawerActivity hasn't been registered in its |
| 64 | * AndroidManifest.xml |
| 65 | */ |
Fan Zhang | 92a2613 | 2018-02-06 14:24:18 -0800 | [diff] [blame] | 66 | public static class TestActivity extends SettingsDrawerActivity { |
| 67 | } |
jackqdyulei | 8accac9 | 2016-09-13 15:07:42 -0700 | [diff] [blame] | 68 | } |