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 
17 package android.server.am;
18 
19 import static org.junit.Assert.fail;
20 
21 import android.app.Activity;
22 import android.platform.test.annotations.Presubmit;
23 import android.support.test.rule.ActivityTestRule;
24 import android.support.test.runner.AndroidJUnit4;
25 
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 
30 /**
31  * Build: mmma -j32 cts/tests/framework/base/activitymanager
32  * Run: cts/tests/framework/base/activitymanager/util/run-test CtsActivityManagerDeviceSdk25TestCases android.server.am.AspectRatioSdk25Tests
33  */
34 @RunWith(AndroidJUnit4.class)
35 @Presubmit
36 public class AspectRatioSdk25Tests extends AspectRatioTestsBase {
37 
38     // Max supported aspect ratio for pre-O apps.
39     private static final float MAX_PRE_O_ASPECT_RATIO = 1.86f;
40 
41     // Test target activity that has targetSdk="25" and resizeableActivity="false".
42     public static class Sdk25MaxAspectRatioActivity extends Activity {
43     }
44 
45     @Rule
46     public ActivityTestRule<Sdk25MaxAspectRatioActivity> mSdk25MaxAspectRatioActivity =
47             new ActivityTestRule<>(Sdk25MaxAspectRatioActivity.class,
48                     false /* initialTouchMode */, false /* launchActivity */);
49 
50     @Test
testMaxAspectRatioPreOActivity()51     public void testMaxAspectRatioPreOActivity() throws Exception {
52         runAspectRatioTest(mSdk25MaxAspectRatioActivity, actual -> {
53             if (aspectRatioLessThanEqual(actual, MAX_PRE_O_ASPECT_RATIO)) return;
54             fail("actual=" + actual + " is greater than expected=" + MAX_PRE_O_ASPECT_RATIO);
55         });
56     }
57 }
58