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.content.pm.PackageManager.FEATURE_WATCH; 20 21 import static androidx.test.InstrumentationRegistry.getInstrumentation; 22 23 import static org.junit.Assert.assertEquals; 24 import static org.junit.Assume.assumeTrue; 25 26 import android.app.Activity; 27 import android.platform.test.annotations.Presubmit; 28 29 import androidx.test.rule.ActivityTestRule; 30 31 import org.junit.Rule; 32 import org.junit.Test; 33 34 /** 35 * Build/Install/Run: 36 * atest CtsWindowManagerSdk28TestCases:AspectRatioSdk28Tests 37 */ 38 @Presubmit 39 public class AspectRatioSdk28Tests extends AspectRatioTestsBase { 40 41 // The minimum supported device aspect ratio for watches. 42 private static final float MIN_WATCH_DEVICE_ASPECT_RATIO = 1.0f; 43 44 45 // Test target activity that has targetSdk="28" and resizeableActivity="false". 46 public static class Sdk28MinAspectRatioActivity extends Activity { 47 } 48 49 @Rule 50 public ActivityTestRule<?> mSdk28MinAspectRatioActivity = new ActivityTestRule<>( 51 Sdk28MinAspectRatioActivity.class, false /* initialTouchMode */, 52 false /* launchActivity */); 53 54 /** 55 * Device implementations with the Configuration.uiMode set as UI_MODE_TYPE_WATCH MUST have an 56 * aspect ratio value set as 1.0 57 */ 58 @Test testMinAspectRatioPreQActivityOnWatch()59 public void testMinAspectRatioPreQActivityOnWatch() { 60 // Only test for watch. 61 assumeTrue(getInstrumentation().getContext().getPackageManager() 62 .hasSystemFeature(FEATURE_WATCH)); 63 64 runAspectRatioTest(mSdk28MinAspectRatioActivity, 65 (actual, displayId, activitySize, displaySize) -> 66 assertEquals(actual, MIN_WATCH_DEVICE_ASPECT_RATIO, 0.0f)); 67 } 68 } 69