diff options
6 files changed, 86 insertions, 0 deletions
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java index 70e5ee71b448..683fca46923f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java @@ -209,6 +209,7 @@ public class AppWindowTokenTests extends WindowTestsBase { } @Test + @FlakyTest(bugId = 149760957) public void testSizeCompatBounds() { // Disable the real configuration resolving because we only simulate partial flow. // TODO: Have test use full flow. diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaPolicyBuilderTest.java b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaPolicyBuilderTest.java index 8ac1d24333be..cc9173ad12ad 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaPolicyBuilderTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaPolicyBuilderTest.java @@ -40,6 +40,8 @@ import static java.util.stream.Collectors.toList; import android.platform.test.annotations.Presubmit; import android.view.SurfaceControl; +import androidx.test.filters.FlakyTest; + import org.hamcrest.CustomTypeSafeMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; @@ -65,6 +67,7 @@ public class DisplayAreaPolicyBuilderTest { private TestWindowManagerPolicy mPolicy = new TestWindowManagerPolicy(null, null); @Test + @FlakyTest(bugId = 149760939) public void testBuilder() { WindowManagerService wms = mSystemServices.getWindowManagerService(); DisplayArea.Root root = new SurfacelessDisplayAreaRoot(wms); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java index c19312debce3..ba577454f9d5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java @@ -599,6 +599,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase { } @Test + @FlakyTest(bugId = 149760800) public void layoutWindowLw_withLongEdgeDisplayCutout() { addLongEdgeDisplayCutout(); @@ -618,6 +619,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase { } @Test + @FlakyTest(bugId = 149760800) public void layoutWindowLw_withLongEdgeDisplayCutout_never() { addLongEdgeDisplayCutout(); diff --git a/services/tests/wmtests/src/com/android/server/wm/StubTransaction.java b/services/tests/wmtests/src/com/android/server/wm/StubTransaction.java index eda1fb8839a5..b5663bd7e26b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/StubTransaction.java +++ b/services/tests/wmtests/src/com/android/server/wm/StubTransaction.java @@ -255,4 +255,9 @@ public class StubTransaction extends SurfaceControl.Transaction { int priority) { return this; } + + @Override + public SurfaceControl.Transaction unsetColor(SurfaceControl sc) { + return this; + } } diff --git a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java index 8ad75053060f..55d12dbd0abb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java +++ b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java @@ -137,6 +137,7 @@ public class SystemServicesTestRule implements TestRule { } throw t; } + if (throwable != null) throw throwable; } } }; diff --git a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRuleTest.java b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRuleTest.java new file mode 100644 index 000000000000..4056c7195c9b --- /dev/null +++ b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRuleTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2020 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 static junit.framework.Assert.assertTrue; + +import android.platform.test.annotations.Presubmit; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runners.model.Statement; + +import java.io.IOException; + +@Presubmit +public class SystemServicesTestRuleTest { + @Rule + public ExpectedException mExpectedException = ExpectedException.none(); + + @Test + public void testRule_rethrows_unchecked_exceptions() throws Throwable { + final SystemServicesTestRule mWmsRule = new SystemServicesTestRule(); + Statement statement = new Statement() { + @Override + public void evaluate() throws Throwable { + throw new RuntimeException("A failing test!"); + } + }; + mExpectedException.expect(RuntimeException.class); + mWmsRule.apply(statement, null /* Description*/).evaluate(); + } + + @Test + public void testRule_rethrows_checked_exceptions() throws Throwable { + final SystemServicesTestRule mWmsRule = new SystemServicesTestRule(); + Statement statement = new Statement() { + @Override + public void evaluate() throws Throwable { + throw new IOException("A failing test!"); + } + }; + mExpectedException.expect(IOException.class); + mWmsRule.apply(statement, null /* Description*/).evaluate(); + } + + @Test + public void testRule_ranSuccessfully() throws Throwable { + final boolean[] testRan = {false}; + final SystemServicesTestRule mWmsRule = new SystemServicesTestRule(); + Statement statement = new Statement() { + @Override + public void evaluate() throws Throwable { + testRan[0] = true; + } + }; + mWmsRule.apply(statement, null /* Description*/).evaluate(); + assertTrue(testRan[0]); + } +} |