diff options
author | 2018-11-03 06:48:34 +0000 | |
---|---|---|
committer | 2018-11-03 06:48:34 +0000 | |
commit | 260307b3c32b3effe88b517d8edaabd2578f42f9 (patch) | |
tree | 1e4a006ebb731ce839406984fa801e9d7ec2703f | |
parent | dd0e346a4fcd346c66d62c594bb77c787acbde6d (diff) | |
parent | a65212d4fac9a2798c86890b897c66168c98954c (diff) |
Merge "Move simple WindowManager tests to WmTests"
-rw-r--r-- | services/tests/wmtests/AndroidManifest.xml | 5 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/ConfigurationContainerTests.java (renamed from services/tests/servicestests/src/com/android/server/wm/ConfigurationContainerTests.java) | 23 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/DummyWmTests.java | 46 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/ScreenDecorWindowTests.java (renamed from services/tests/servicestests/src/com/android/server/wm/ScreenDecorWindowTests.java) | 51 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java (renamed from services/tests/servicestests/src/com/android/server/wm/WindowAnimationSpecTest.java) | 8 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/utils/CoordinateTransformsTest.java (renamed from services/tests/servicestests/src/com/android/server/wm/utils/CoordinateTransformsTest.java) | 8 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/utils/DisplayRotationUtilTest.java (renamed from services/tests/servicestests/src/com/android/server/wm/utils/DisplayRotationUtilTest.java) | 43 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/utils/InsetUtilsTest.java (renamed from services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java) | 11 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/utils/RotationCacheTest.java (renamed from services/tests/servicestests/src/com/android/server/wm/utils/RotationCacheTest.java) | 17 | ||||
-rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java (renamed from services/tests/servicestests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java) | 16 |
10 files changed, 86 insertions, 142 deletions
diff --git a/services/tests/wmtests/AndroidManifest.xml b/services/tests/wmtests/AndroidManifest.xml index 32c4d4a77263..bfc775dc01e7 100644 --- a/services/tests/wmtests/AndroidManifest.xml +++ b/services/tests/wmtests/AndroidManifest.xml @@ -30,6 +30,10 @@ <uses-permission android:name="android.permission.STORAGE_INTERNAL" /> <uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" /> <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" /> + <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> + <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" /> + <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> <application android:testOnly="true"> <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityA" /> @@ -37,6 +41,7 @@ <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityRequestedOrientationChange" /> <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityTaskChangeCallbacks" /> <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityTaskDescriptionChange" /> + <activity android:name="com.android.server.wm.ScreenDecorWindowTests$TestActivity" /> </application> <instrumentation diff --git a/services/tests/servicestests/src/com/android/server/wm/ConfigurationContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/ConfigurationContainerTests.java index 2b8214d162c9..82a200bc207f 100644 --- a/services/tests/servicestests/src/com/android/server/wm/ConfigurationContainerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ConfigurationContainerTests.java @@ -11,13 +11,12 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ package com.android.server.wm; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; @@ -36,10 +35,8 @@ import android.content.res.Configuration; import android.platform.test.annotations.Presubmit; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.Test; -import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.List; @@ -48,15 +45,14 @@ import java.util.List; * Test class for {@link ConfigurationContainer}. * * Build/Install/Run: - * bit FrameworksServicesTests:com.android.server.wm.ConfigurationContainerTests + * atest WmTests:ConfigurationContainerTests */ @SmallTest @Presubmit -@RunWith(AndroidJUnit4.class) public class ConfigurationContainerTests { @Test - public void testConfigurationInit() throws Exception { + public void testConfigurationInit() { // Check root container initial config. final TestConfigurationContainer root = new TestConfigurationContainer(); assertEquals(EMPTY, root.getOverrideConfiguration()); @@ -93,7 +89,7 @@ public class ConfigurationContainerTests { } @Test - public void testConfigurationChangeOnAddRemove() throws Exception { + public void testConfigurationChangeOnAddRemove() { // Init root's config. final TestConfigurationContainer root = new TestConfigurationContainer(); final Configuration rootOverrideConfig = new Configuration(); @@ -135,7 +131,7 @@ public class ConfigurationContainerTests { } @Test - public void testConfigurationChangePropagation() throws Exception { + public void testConfigurationChangePropagation() { // Builds 3-level vertical hierarchy with one configuration container on each level. // In addition to different overrides on each level, everyone in hierarchy will have one // common overridden value - orientation; @@ -212,7 +208,7 @@ public class ConfigurationContainerTests { } @Test - public void testSetWindowingMode() throws Exception { + public void testSetWindowingMode() { final TestConfigurationContainer root = new TestConfigurationContainer(); root.setWindowingMode(WINDOWING_MODE_UNDEFINED); final TestConfigurationContainer child = root.addChild(); @@ -226,7 +222,7 @@ public class ConfigurationContainerTests { } @Test - public void testSetActivityType() throws Exception { + public void testSetActivityType() { final TestConfigurationContainer root = new TestConfigurationContainer(); root.setActivityType(ACTIVITY_TYPE_UNDEFINED); final TestConfigurationContainer child = root.addChild(); @@ -272,7 +268,7 @@ public class ConfigurationContainerTests { } @Test - public void testRegisterConfigurationChangeListener() throws Exception { + public void testRegisterConfigurationChangeListener() { final TestConfigurationContainer container = new TestConfigurationContainer(); final TestConfigurationChangeListener listener = new TestConfigurationChangeListener(); final Configuration config = new Configuration(); @@ -328,10 +324,11 @@ public class ConfigurationContainerTests { } } - private class TestConfigurationChangeListener implements ConfigurationContainerListener { + private static class TestConfigurationChangeListener implements ConfigurationContainerListener { final Configuration mOverrideConfiguration = new Configuration(); + @Override public void onOverrideConfigurationChanged(Configuration overrideConfiguration) { mOverrideConfiguration.setTo(overrideConfiguration); } diff --git a/services/tests/wmtests/src/com/android/server/wm/DummyWmTests.java b/services/tests/wmtests/src/com/android/server/wm/DummyWmTests.java deleted file mode 100644 index aecb2783badd..000000000000 --- a/services/tests/wmtests/src/com/android/server/wm/DummyWmTests.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.wm; - -import android.platform.test.annotations.Presubmit; - -import org.junit.Test; - -import androidx.test.filters.FlakyTest; - -/** - * Dummy test for com.android.server.wm - * TODO(b/113800711): Remove this class once the actual tests are moved from servicestests. - */ -public class DummyWmTests { - - @Presubmit - @Test - public void preSubmitTest() {} - - @FlakyTest - @Presubmit - @Test - public void flakyPreSubmitTest() {} - - @Test - public void postSubmitTest() {} - - @FlakyTest - @Test - public void flakyPostSubmitTest() {} -} diff --git a/services/tests/servicestests/src/com/android/server/wm/ScreenDecorWindowTests.java b/services/tests/wmtests/src/com/android/server/wm/ScreenDecorWindowTests.java index ae40f7e7d235..36eccd1892a7 100644 --- a/services/tests/servicestests/src/com/android/server/wm/ScreenDecorWindowTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ScreenDecorWindowTests.java @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ package com.android.server.wm; @@ -33,6 +33,8 @@ import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; +import static com.google.common.truth.Truth.assertThat; + import static org.junit.Assert.assertEquals; import android.app.Activity; @@ -46,6 +48,7 @@ import android.hardware.display.DisplayManager; import android.hardware.display.VirtualDisplay; import android.media.ImageReader; import android.os.Handler; +import android.os.SystemClock; import android.platform.test.annotations.Presubmit; import android.util.Pair; import android.view.Display; @@ -57,13 +60,10 @@ import android.widget.TextView; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.function.BooleanSupplier; @@ -72,13 +72,12 @@ import java.util.function.BooleanSupplier; * Tests for the {@link android.view.WindowManager.LayoutParams#PRIVATE_FLAG_IS_SCREEN_DECOR} flag. * * Build/Install/Run: - * atest FrameworksServicesTests:com.android.server.wm.ScreenDecorWindowTests + * atest WmTests:ScreenDecorWindowTests */ // TODO: Add test for FLAG_FULLSCREEN which hides the status bar and also other flags. // TODO: Test non-Activity windows. @SmallTest @Presubmit -@RunWith(AndroidJUnit4.class) public class ScreenDecorWindowTests { private final Context mContext = InstrumentationRegistry.getTargetContext(); @@ -120,7 +119,7 @@ public class ScreenDecorWindowTests { } @Test - public void testScreenSides() throws Exception { + public void testScreenSides() { // Decor on top final View decorWindow = createDecorWindow(TOP, MATCH_PARENT, mDecorThickness); assertInsetGreaterOrEqual(mTestActivity, TOP, mDecorThickness); @@ -139,7 +138,7 @@ public class ScreenDecorWindowTests { } @Test - public void testMultipleDecors() throws Exception { + public void testMultipleDecors() { // Test 2 decor windows on-top. createDecorWindow(TOP, MATCH_PARENT, mHalfDecorThickness); assertInsetGreaterOrEqual(mTestActivity, TOP, mHalfDecorThickness); @@ -153,7 +152,7 @@ public class ScreenDecorWindowTests { } @Test - public void testFlagChange() throws Exception { + public void testFlagChange() { WindowInsets initialInsets = getInsets(mTestActivity); final View decorWindow = createDecorWindow(TOP, MATCH_PARENT, mDecorThickness); @@ -174,7 +173,7 @@ public class ScreenDecorWindowTests { } @Test - public void testRemoval() throws Exception { + public void testRemoval() { WindowInsets initialInsets = getInsets(mTestActivity); final View decorWindow = createDecorWindow(TOP, MATCH_PARENT, mDecorThickness); @@ -256,7 +255,7 @@ public class ScreenDecorWindowTests { /** * Asserts the top inset of {@param activity} is equal to {@param expected} waiting as needed. */ - private void assertTopInsetEquals(Activity activity, int expected) throws Exception { + private void assertTopInsetEquals(Activity activity, int expected) { waitForTopInsetEqual(activity, expected); assertEquals(expected, getInsets(activity).getSystemWindowInsetTop()); } @@ -269,16 +268,23 @@ public class ScreenDecorWindowTests { * Asserts the inset at {@param side} of {@param activity} is equal to {@param expected} * waiting as needed. */ - private void assertInsetGreaterOrEqual(Activity activity, int side, int expected) - throws Exception { + private void assertInsetGreaterOrEqual(Activity activity, int side, int expected) { waitForInsetGreaterOrEqual(activity, side, expected); final WindowInsets insets = getInsets(activity); switch (side) { - case TOP: assertGreaterOrEqual(insets.getSystemWindowInsetTop(), expected); break; - case BOTTOM: assertGreaterOrEqual(insets.getSystemWindowInsetBottom(), expected); break; - case LEFT: assertGreaterOrEqual(insets.getSystemWindowInsetLeft(), expected); break; - case RIGHT: assertGreaterOrEqual(insets.getSystemWindowInsetRight(), expected); break; + case TOP: + assertThat(insets.getSystemWindowInsetTop()).isAtLeast(expected); + break; + case BOTTOM: + assertThat(insets.getSystemWindowInsetBottom()).isAtLeast(expected); + break; + case LEFT: + assertThat(insets.getSystemWindowInsetLeft()).isAtLeast(expected); + break; + case RIGHT: + assertThat(insets.getSystemWindowInsetRight()).isAtLeast(expected); + break; } } @@ -295,22 +301,13 @@ public class ScreenDecorWindowTests { }); } - /** Asserts that the first entry is greater than or equal to the second entry. */ - private void assertGreaterOrEqual(int first, int second) throws Exception { - Assert.assertTrue("Excepted " + first + " >= " + second, first >= second); - } - private void waitFor(BooleanSupplier waitCondition) { int retriesLeft = 5; do { if (waitCondition.getAsBoolean()) { break; } - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // Well I guess we are not waiting... - } + SystemClock.sleep(500); } while (retriesLeft-- > 0); } diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowAnimationSpecTest.java b/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java index 827d938aa73e..21e5d991b63b 100644 --- a/services/tests/servicestests/src/com/android/server/wm/WindowAnimationSpecTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ package com.android.server.wm; @@ -33,19 +33,17 @@ import android.view.animation.Animation; import android.view.animation.ClipRectAnimation; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.Test; -import org.junit.runner.RunWith; /** * Tests for the {@link WindowAnimationSpec} class. * - * atest FrameworksServicesTests:com.android.server.wm.WindowAnimationSpecTest + * Build/Install/Run: + * atest WmTests:WindowAnimationSpecTest */ @SmallTest @Presubmit -@RunWith(AndroidJUnit4.class) public class WindowAnimationSpecTest { private final SurfaceControl mSurfaceControl = mock(SurfaceControl.class); private final SurfaceControl.Transaction mTransaction = mock(SurfaceControl.Transaction.class); diff --git a/services/tests/servicestests/src/com/android/server/wm/utils/CoordinateTransformsTest.java b/services/tests/wmtests/src/com/android/server/wm/utils/CoordinateTransformsTest.java index f82b01224f96..649b785c992b 100644 --- a/services/tests/servicestests/src/com/android/server/wm/utils/CoordinateTransformsTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/utils/CoordinateTransformsTest.java @@ -23,8 +23,6 @@ import static android.view.Surface.ROTATION_90; import static com.android.server.wm.utils.CoordinateTransforms.transformLogicalToPhysicalCoordinates; import static com.android.server.wm.utils.CoordinateTransforms.transformPhysicalToLogicalCoordinates; - - import static com.android.server.wm.utils.CoordinateTransforms.transformToRotation; import static org.hamcrest.Matchers.is; @@ -40,6 +38,10 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ErrorCollector; +/** + * Build/Install/Run: + * atest WmTests:CoordinateTransformsTest + */ public class CoordinateTransformsTest { private static final int W = 200; @@ -202,4 +204,4 @@ public class CoordinateTransformsTest { public interface TransformPointAssertable { void transformsTo(int x, int y); } -}
\ No newline at end of file +} diff --git a/services/tests/servicestests/src/com/android/server/wm/utils/DisplayRotationUtilTest.java b/services/tests/wmtests/src/com/android/server/wm/utils/DisplayRotationUtilTest.java index ba8869b1692d..926153db58d6 100644 --- a/services/tests/servicestests/src/com/android/server/wm/utils/DisplayRotationUtilTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/utils/DisplayRotationUtilTest.java @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ package com.android.server.wm.utils; @@ -24,6 +24,7 @@ import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; + import static com.android.server.wm.utils.DisplayRotationUtil.getBoundIndexFromRotation; import static org.hamcrest.Matchers.equalTo; @@ -32,24 +33,20 @@ import static org.junit.Assert.assertThat; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; -import org.junit.Test; -import org.junit.runner.RunWith; - import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - +import org.junit.Test; /** * Tests for {@link DisplayRotationUtil} * - * Run with: atest DisplayRotationUtilTest + * Build/Install/Run: + * atest WmTests:DisplayRotationUtilTest */ -@RunWith(AndroidJUnit4.class) @SmallTest @Presubmit public class DisplayRotationUtilTest { - private static Rect ZERO_RECT = new Rect(); + private static final Rect ZERO_RECT = new Rect(); @Test public void testGetBoundIndexFromRotation_rot0() { @@ -103,7 +100,7 @@ public class DisplayRotationUtilTest { @Test public void testGetRotatedBounds_top_rot0() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { ZERO_RECT, new Rect(50,0,150,10), ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {ZERO_RECT, new Rect(50, 0, 150, 10), ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_0, 200, 300), equalTo(bounds)); } @@ -111,31 +108,31 @@ public class DisplayRotationUtilTest { @Test public void testGetRotatedBounds_top_rot90() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { ZERO_RECT, new Rect(50,0,150,10), ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {ZERO_RECT, new Rect(50, 0, 150, 10), ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_90, 200, 300), - equalTo(new Rect[] { new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT })); + equalTo(new Rect[] {new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT})); } @Test public void testGetRotatedBounds_top_rot180() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { ZERO_RECT, new Rect(50,0,150,10), ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {ZERO_RECT, new Rect(50, 0, 150, 10), ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_180, 200, 300), - equalTo(new Rect[] { ZERO_RECT, ZERO_RECT, ZERO_RECT, new Rect(50, 290, 150, 300) })); + equalTo(new Rect[] {ZERO_RECT, ZERO_RECT, ZERO_RECT, new Rect(50, 290, 150, 300)})); } @Test public void testGetRotatedBounds_top_rot270() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { ZERO_RECT, new Rect(50,0,150,10), ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {ZERO_RECT, new Rect(50, 0, 150, 10), ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_270, 200, 300), - equalTo(new Rect[] { ZERO_RECT, ZERO_RECT, new Rect(290, 50, 300, 150), ZERO_RECT })); + equalTo(new Rect[] {ZERO_RECT, ZERO_RECT, new Rect(290, 50, 300, 150), ZERO_RECT})); } @Test public void testGetRotatedBounds_left_rot0() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_0, 300, 200), equalTo(bounds)); } @@ -143,24 +140,24 @@ public class DisplayRotationUtilTest { @Test public void testGetRotatedBounds_left_rot90() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_90, 300, 200), - equalTo(new Rect[]{ ZERO_RECT, ZERO_RECT, ZERO_RECT, new Rect(50, 290, 150, 300) })); + equalTo(new Rect[] {ZERO_RECT, ZERO_RECT, ZERO_RECT, new Rect(50, 290, 150, 300)})); } @Test public void testGetRotatedBounds_left_rot180() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_180, 300, 200), - equalTo(new Rect[]{ ZERO_RECT, ZERO_RECT, new Rect(290, 50, 300, 150), ZERO_RECT })); + equalTo(new Rect[] {ZERO_RECT, ZERO_RECT, new Rect(290, 50, 300, 150), ZERO_RECT})); } @Test public void testGetRotatedBounds_left_rot270() { DisplayRotationUtil util = new DisplayRotationUtil(); - Rect[] bounds = new Rect[] { new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT }; + Rect[] bounds = new Rect[] {new Rect(0, 50, 10, 150), ZERO_RECT, ZERO_RECT, ZERO_RECT}; assertThat(util.getRotatedBounds(bounds, ROTATION_270, 300, 200), - equalTo(new Rect[]{ ZERO_RECT, new Rect(50, 0, 150, 10), ZERO_RECT, ZERO_RECT })); + equalTo(new Rect[] {ZERO_RECT, new Rect(50, 0, 150, 10), ZERO_RECT, ZERO_RECT})); } } diff --git a/services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java b/services/tests/wmtests/src/com/android/server/wm/utils/InsetUtilsTest.java index 3364aef25bd0..089e908cbd5a 100644 --- a/services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/utils/InsetUtilsTest.java @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ package com.android.server.wm.utils; @@ -27,18 +27,19 @@ import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(AndroidJUnit4.class) +/** + * Build/Install/Run: + * atest WmTests:InsetUtilsTest + */ @SmallTest @Presubmit public class InsetUtilsTest { @Test - public void testAdd() throws Exception { + public void testAdd() { final Rect rect1 = new Rect(10, 20, 30, 40); final Rect rect2 = new Rect(50, 60, 70, 80); InsetUtils.addInsets(rect1, rect2); diff --git a/services/tests/servicestests/src/com/android/server/wm/utils/RotationCacheTest.java b/services/tests/wmtests/src/com/android/server/wm/utils/RotationCacheTest.java index 5d08920b43d0..33f34b465576 100644 --- a/services/tests/servicestests/src/com/android/server/wm/utils/RotationCacheTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/utils/RotationCacheTest.java @@ -28,13 +28,14 @@ import android.util.Pair; import androidx.test.filters.FlakyTest; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(AndroidJUnit4.class) +/** + * Build/Install/Run: + * atest WmTests:RotationCacheTest + */ @SmallTest @FlakyTest(bugId = 74078662) @Presubmit @@ -53,7 +54,7 @@ public class RotationCacheTest { } @Test - public void getOrCompute_computes() throws Exception { + public void getOrCompute_computes() { assertThat(mCache.getOrCompute("hello", 0), equalTo(create("hello", 0))); assertThat(mCache.getOrCompute("hello", 1), equalTo(create("hello", 1))); assertThat(mCache.getOrCompute("hello", 2), equalTo(create("hello", 2))); @@ -61,7 +62,7 @@ public class RotationCacheTest { } @Test - public void getOrCompute_sameParam_sameRot_hitsCache() throws Exception { + public void getOrCompute_sameParam_sameRot_hitsCache() { assertNotNull(mCache.getOrCompute("hello", 1)); mComputationCalled = false; @@ -70,7 +71,7 @@ public class RotationCacheTest { } @Test - public void getOrCompute_sameParam_hitsCache_forAllRots() throws Exception { + public void getOrCompute_sameParam_hitsCache_forAllRots() { assertNotNull(mCache.getOrCompute("hello", 3)); assertNotNull(mCache.getOrCompute("hello", 2)); assertNotNull(mCache.getOrCompute("hello", 1)); @@ -85,14 +86,14 @@ public class RotationCacheTest { } @Test - public void getOrCompute_changingParam_recomputes() throws Exception { + public void getOrCompute_changingParam_recomputes() { assertNotNull(mCache.getOrCompute("hello", 1)); assertThat(mCache.getOrCompute("world", 1), equalTo(create("world", 1))); } @Test - public void getOrCompute_changingParam_clearsCacheForDifferentRots() throws Exception { + public void getOrCompute_changingParam_clearsCacheForDifferentRots() { assertNotNull(mCache.getOrCompute("hello", 1)); assertNotNull(mCache.getOrCompute("world", 2)); diff --git a/services/tests/servicestests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java b/services/tests/wmtests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java index c5e35e7304c4..fb8ba7bffd4c 100644 --- a/services/tests/servicestests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java @@ -16,12 +16,11 @@ package com.android.server.wm.utils; - -import static android.view.DisplayCutout.NO_CUTOUT; import static android.view.DisplayCutout.BOUNDS_POSITION_BOTTOM; import static android.view.DisplayCutout.BOUNDS_POSITION_LEFT; import static android.view.DisplayCutout.BOUNDS_POSITION_RIGHT; import static android.view.DisplayCutout.BOUNDS_POSITION_TOP; +import static android.view.DisplayCutout.NO_CUTOUT; import static android.view.DisplayCutout.fromBoundingRect; import static org.hamcrest.Matchers.equalTo; @@ -29,7 +28,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThat; - import android.graphics.Insets; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; @@ -37,24 +35,18 @@ import android.util.Size; import android.view.DisplayCutout; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.Arrays; /** * Tests for {@link WmDisplayCutout} * - * Run with: atest WmDisplayCutoutTest + * Build/Install/Run: + * atest WmTests:WmDisplayCutoutTest */ -@RunWith(AndroidJUnit4.class) @SmallTest @Presubmit public class WmDisplayCutoutTest { - private static final Rect ZERO_RECT = new Rect(); - private final DisplayCutout mCutoutTop = new DisplayCutout( Insets.of(0, 100, 0, 0), null /* boundLeft */, new Rect(50, 0, 75, 100) /* boundTop */, @@ -165,4 +157,4 @@ public class WmDisplayCutoutTest { assertEquals(new WmDisplayCutout(mCutoutTop, new Size(1, 2)).hashCode(), new WmDisplayCutout(mCutoutTop, new Size(1, 2)).hashCode()); } -}
\ No newline at end of file +} |