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