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