1 /* 2 * Copyright (C) 2018 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 android.server.am; 18 19 import static android.server.am.UiDeviceUtils.pressBackButton; 20 import static android.server.am.deprecatedsdk.Components.MAIN_ACTIVITY; 21 22 import android.support.test.runner.AndroidJUnit4; 23 24 import org.junit.After; 25 import org.junit.Test; 26 import org.junit.runner.RunWith; 27 28 /** 29 * Ensure that compatibility dialog is shown when launching an application 30 * targeting a deprecated version of SDK. 31 * <p>Build/Install/Run: 32 * atest CtsActivityManagerDeviceTestCases:DeprecatedTargetSdkTest 33 */ 34 @RunWith(AndroidJUnit4.class) 35 public class DeprecatedTargetSdkTest extends ActivityManagerTestBase { 36 37 /** @see com.android.server.am.DeprecatedTargetSdkVersionDialog */ 38 private static final String DEPRECATED_TARGET_SDK_VERSION_DIALOG = 39 "DeprecatedTargetSdkVersionDialog"; 40 41 @After 42 @Override tearDown()43 public void tearDown() throws Exception { 44 super.tearDown(); 45 46 // Ensure app process is stopped. 47 stopTestPackage(MAIN_ACTIVITY); 48 } 49 50 @Test testCompatibilityDialog()51 public void testCompatibilityDialog() throws Exception { 52 // Launch target app. 53 launchActivity(MAIN_ACTIVITY); 54 mAmWmState.assertActivityDisplayed(MAIN_ACTIVITY); 55 mAmWmState.assertWindowDisplayed(DEPRECATED_TARGET_SDK_VERSION_DIALOG); 56 57 // Go back to dismiss the warning dialog. 58 pressBackButton(); 59 60 // Go back again to formally stop the app. If we just kill the process, it'll attempt to 61 // resume rather than starting from scratch (as far as ActivityStack is concerned) and it 62 // won't invoke the warning dialog. 63 pressBackButton(); 64 } 65 } 66