Loading services/tests/servicestests/src/com/android/server/wm/AnimatingAppWindowTokenRegistryTest.java +5 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -29,11 +29,9 @@ import android.platform.test.annotations.Presubmit; 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; import org.mockito.Mock; import org.mockito.MockitoAnnotations; Loading @@ -41,12 +39,11 @@ import org.mockito.MockitoAnnotations; * Tests for the {@link TaskStack} class. * * Build/Install/Run: * atest FrameworksServicesTests:com.android.server.wm.AnimatingAppWindowTokenRegistryTest * atest FrameworksServicesTests:AnimatingAppWindowTokenRegistryTest */ @SmallTest @Presubmit @FlakyTest(detail = "Promote once confirmed non-flaky") @RunWith(AndroidJUnit4.class) public class AnimatingAppWindowTokenRegistryTest extends WindowTestsBase { @Mock Loading @@ -56,14 +53,14 @@ public class AnimatingAppWindowTokenRegistryTest extends WindowTestsBase { Runnable mMockEndDeferFinishCallback1; @Mock Runnable mMockEndDeferFinishCallback2; @Before public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); } @Test public void testDeferring() throws Exception { public void testDeferring() { final AppWindowToken window1 = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken window2 = createAppWindow(window1.getTask(), ACTIVITY_TYPE_STANDARD, Loading @@ -85,7 +82,7 @@ public class AnimatingAppWindowTokenRegistryTest extends WindowTestsBase { } @Test public void testContainerRemoved() throws Exception { public void testContainerRemoved() { final AppWindowToken window1 = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken window2 = createAppWindow(window1.getTask(), ACTIVITY_TYPE_STANDARD, Loading services/tests/servicestests/src/com/android/server/wm/AppTransitionControllerTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -27,28 +27,28 @@ import android.platform.test.annotations.Presubmit; import android.view.WindowManager; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; /** * Build/Install/Run: * atest FrameworksServicesTests:AppTransitionControllerTest */ @SmallTest @Presubmit @RunWith(AndroidJUnit4.class) public class AppTransitionControllerTest extends WindowTestsBase { private AppTransitionController mAppTransitionController; @Before public void setUp() throws Exception { super.setUp(); mAppTransitionController = new AppTransitionController(sWm, mDisplayContent); mAppTransitionController = new AppTransitionController(mWm, mDisplayContent); } @Test public void testTranslucentOpen() throws Exception { synchronized (sWm.mGlobalLock) { public void testTranslucentOpen() { synchronized (mWm.mGlobalLock) { final AppWindowToken behind = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken translucentOpening = createAppWindowToken(mDisplayContent, Loading @@ -64,8 +64,8 @@ public class AppTransitionControllerTest extends WindowTestsBase { } @Test public void testTranslucentClose() throws Exception { synchronized (sWm.mGlobalLock) { public void testTranslucentClose() { synchronized (mWm.mGlobalLock) { final AppWindowToken behind = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken translucentClosing = createAppWindowToken(mDisplayContent, Loading services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java +22 −28 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -32,81 +32,75 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.spy; import android.content.Context; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.view.Display; import android.view.IApplicationToken; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; /** * Test class for {@link AppTransition}. * * atest AppTransitionTests * Build/Install/Run: * atest FrameworksServicesTests:AppTransitionTests */ @SmallTest @Presubmit @RunWith(AndroidJUnit4.class) public class AppTransitionTests extends WindowTestsBase { private DisplayContent mDc; @Before public void setUp() throws Exception { super.setUp(); final Context context = InstrumentationRegistry.getTargetContext(); mDc = sWm.getDefaultDisplayContentLocked(); mDc = mWm.getDefaultDisplayContentLocked(); // For unit test, we don't need to test performSurfacePlacement to prevent some // abnormal interaction with surfaceflinger native side. sWm.mRoot = spy(sWm.mRoot); doNothing().when(sWm.mRoot).performSurfacePlacement(anyBoolean()); mWm.mRoot = spy(mWm.mRoot); doNothing().when(mWm.mRoot).performSurfacePlacement(anyBoolean()); } @Test public void testKeyguardOverride() throws Exception { sWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); public void testKeyguardOverride() { mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mDc.mAppTransition.getAppTransition()); } @Test public void testKeyguardKeep() throws Exception { sWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); public void testKeyguardKeep() { mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mDc.mAppTransition.getAppTransition()); } @Test public void testForceOverride() throws Exception { sWm.prepareAppTransition(TRANSIT_KEYGUARD_UNOCCLUDE, false /* alwaysKeepCurrent */); public void testForceOverride() { mWm.prepareAppTransition(TRANSIT_KEYGUARD_UNOCCLUDE, false /* alwaysKeepCurrent */); mDc.getController().prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */, 0 /* flags */, true /* forceOverride */); assertEquals(TRANSIT_ACTIVITY_OPEN, mDc.mAppTransition.getAppTransition()); } @Test public void testCrashing() throws Exception { sWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); public void testCrashing() { mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_CRASHING_ACTIVITY_CLOSE, mDc.mAppTransition.getAppTransition()); } @Test public void testKeepKeyguard_withCrashing() throws Exception { sWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); public void testKeepKeyguard_withCrashing() { mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mDc.mAppTransition.getAppTransition()); } @Test public void testAppTransitionStateForMultiDisplay() throws Exception { public void testAppTransitionStateForMultiDisplay() { // Create 2 displays & presume both display the state is ON for ready to display & animate. final DisplayContent dc1 = createNewDisplayWithController(Display.STATE_ON); final DisplayContent dc2 = createNewDisplayWithController(Display.STATE_ON); Loading Loading @@ -149,7 +143,7 @@ public class AppTransitionTests extends WindowTestsBase { } @Test public void testCleanAppTransitionWhenTaskStackReparent() throws Exception { public void testCleanAppTransitionWhenTaskStackReparent() { // Create 2 displays & presume both display the state is ON for ready to display & animate. final DisplayContent dc1 = createNewDisplayWithController(Display.STATE_ON); final DisplayContent dc2 = createNewDisplayWithController(Display.STATE_ON); Loading services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java +25 −24 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.content.res.Configuration.EMPTY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading @@ -29,10 +31,8 @@ import static org.junit.Assert.fail; import android.platform.test.annotations.Presubmit; import androidx.test.InstrumentationRegistry; import androidx.test.filters.FlakyTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.server.wm.WindowTestUtils.TestTaskWindowContainerController; Loading @@ -41,16 +41,17 @@ import org.junit.Test; /** * Test class for {@link AppWindowContainerController}. * * atest FrameworksServicesTests:com.android.server.wm.AppWindowContainerControllerTests * atest FrameworksServicesTests:AppWindowContainerControllerTests */ @FlakyTest(bugId = 74078662) @SmallTest @Presubmit @FlakyTest(bugId = 74078662) @org.junit.runner.RunWith(AndroidJUnit4.class) public class AppWindowContainerControllerTests extends WindowTestsBase { private final String mPackageName = getInstrumentation().getTargetContext().getPackageName(); @Test public void testRemoveContainer() throws Exception { public void testRemoveContainer() { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); Loading @@ -68,7 +69,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testSetOrientation() throws Exception { public void testSetOrientation() { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); Loading @@ -84,7 +85,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, controller.getOrientation()); // Reset display frozen state sWm.mDisplayFrozen = false; mWm.mDisplayFrozen = false; } private void assertHasStartingWindow(AppWindowToken atoken) { Loading @@ -103,10 +104,10 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testCreateRemoveStartingWindow() throws Exception { public void testCreateRemoveStartingWindow() { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); controller.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -118,34 +119,34 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testAddRemoveRace() throws Exception { public void testAddRemoveRace() { // There was once a race condition between adding and removing starting windows for (int i = 0; i < 1000; i++) { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); controller.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); controller.removeStartingWindow(); waitUntilHandlersIdle(); assertNoStartingWindow(controller.getAppWindowToken(mDisplayContent)); controller.getAppWindowToken(mDisplayContent).getParent().getParent().removeImmediately(); controller.getAppWindowToken( mDisplayContent).getParent().getParent().removeImmediately(); } } @Test public void testTransferStartingWindow() throws Exception { public void testTransferStartingWindow() { final WindowTestUtils.TestAppWindowContainerController controller1 = createAppWindowController(); final WindowTestUtils.TestAppWindowContainerController controller2 = createAppWindowController(); controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller1.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller2.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(), true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -154,19 +155,19 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testTransferStartingWindowWhileCreating() throws Exception { public void testTransferStartingWindowWhileCreating() { final WindowTestUtils.TestAppWindowContainerController controller1 = createAppWindowController(); final WindowTestUtils.TestAppWindowContainerController controller2 = createAppWindowController(); ((TestWindowManagerPolicy) sWm.mPolicy).setRunnableWhenAddingSplashScreen(() -> { ((TestWindowManagerPolicy) mWm.mPolicy).setRunnableWhenAddingSplashScreen(() -> { // Surprise, ...! Transfer window in the middle of the creation flow. controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller2.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(), true, true, false, true, false, false); }); controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller1.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -175,7 +176,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testTryTransferStartingWindowFromHiddenAboveToken() throws Exception { public void testTryTransferStartingWindowFromHiddenAboveToken() { // Add two tasks on top of each other. TestTaskWindowContainerController taskController = Loading @@ -186,7 +187,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { createAppWindowController(taskController); // Add a starting window. controllerTop.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controllerTop.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -202,7 +203,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testReparent() throws Exception { public void testReparent() { final StackWindowController stackController = createStackControllerOnDisplay(mDisplayContent); final WindowTestUtils.TestTaskWindowContainerController taskController1 = Loading services/tests/servicestests/src/com/android/server/wm/AppWindowTokenAnimationTests.java +10 −13 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -26,15 +26,14 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import android.view.SurfaceControl; import androidx.test.filters.SmallTest; import com.android.server.wm.WindowTestUtils.TestAppWindowToken; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; Loading @@ -43,10 +42,9 @@ import org.mockito.MockitoAnnotations; * Animation related tests for the {@link AppWindowToken} class. * * Build/Install/Run: * atest FrameworksServicesTests:com.android.server.wm.AppWindowTokenAnimationTests * atest FrameworksServicesTests:AppWindowTokenAnimationTests */ @SmallTest @RunWith(AndroidJUnit4.class) public class AppWindowTokenAnimationTests extends WindowTestsBase { private TestAppWindowToken mToken; Loading @@ -56,9 +54,8 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { @Mock private AnimationAdapter mSpec; @Override @Before public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); mToken = createTestAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, Loading @@ -67,7 +64,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipAfterAnim_boundsLayerIsCreated() throws Exception { public void clipAfterAnim_boundsLayerIsCreated() { mToken.mNeedsAnimationBoundsLayer = true; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); Loading @@ -78,7 +75,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipAfterAnim_boundsLayerIsDestroyed() throws Exception { public void clipAfterAnim_boundsLayerIsDestroyed() { mToken.mNeedsAnimationBoundsLayer = true; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); final SurfaceControl leash = mToken.mSurfaceAnimator.mLeash; Loading @@ -95,7 +92,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipAfterAnimCancelled_boundsLayerIsDestroyed() throws Exception { public void clipAfterAnimCancelled_boundsLayerIsDestroyed() { mToken.mNeedsAnimationBoundsLayer = true; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); final SurfaceControl leash = mToken.mSurfaceAnimator.mLeash; Loading @@ -108,7 +105,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipNoneAnim_boundsLayerIsNotCreated() throws Exception { public void clipNoneAnim_boundsLayerIsNotCreated() { mToken.mNeedsAnimationBoundsLayer = false; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); Loading Loading
services/tests/servicestests/src/com/android/server/wm/AnimatingAppWindowTokenRegistryTest.java +5 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -29,11 +29,9 @@ import android.platform.test.annotations.Presubmit; 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; import org.mockito.Mock; import org.mockito.MockitoAnnotations; Loading @@ -41,12 +39,11 @@ import org.mockito.MockitoAnnotations; * Tests for the {@link TaskStack} class. * * Build/Install/Run: * atest FrameworksServicesTests:com.android.server.wm.AnimatingAppWindowTokenRegistryTest * atest FrameworksServicesTests:AnimatingAppWindowTokenRegistryTest */ @SmallTest @Presubmit @FlakyTest(detail = "Promote once confirmed non-flaky") @RunWith(AndroidJUnit4.class) public class AnimatingAppWindowTokenRegistryTest extends WindowTestsBase { @Mock Loading @@ -56,14 +53,14 @@ public class AnimatingAppWindowTokenRegistryTest extends WindowTestsBase { Runnable mMockEndDeferFinishCallback1; @Mock Runnable mMockEndDeferFinishCallback2; @Before public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); } @Test public void testDeferring() throws Exception { public void testDeferring() { final AppWindowToken window1 = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken window2 = createAppWindow(window1.getTask(), ACTIVITY_TYPE_STANDARD, Loading @@ -85,7 +82,7 @@ public class AnimatingAppWindowTokenRegistryTest extends WindowTestsBase { } @Test public void testContainerRemoved() throws Exception { public void testContainerRemoved() { final AppWindowToken window1 = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken window2 = createAppWindow(window1.getTask(), ACTIVITY_TYPE_STANDARD, Loading
services/tests/servicestests/src/com/android/server/wm/AppTransitionControllerTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -27,28 +27,28 @@ import android.platform.test.annotations.Presubmit; import android.view.WindowManager; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; /** * Build/Install/Run: * atest FrameworksServicesTests:AppTransitionControllerTest */ @SmallTest @Presubmit @RunWith(AndroidJUnit4.class) public class AppTransitionControllerTest extends WindowTestsBase { private AppTransitionController mAppTransitionController; @Before public void setUp() throws Exception { super.setUp(); mAppTransitionController = new AppTransitionController(sWm, mDisplayContent); mAppTransitionController = new AppTransitionController(mWm, mDisplayContent); } @Test public void testTranslucentOpen() throws Exception { synchronized (sWm.mGlobalLock) { public void testTranslucentOpen() { synchronized (mWm.mGlobalLock) { final AppWindowToken behind = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken translucentOpening = createAppWindowToken(mDisplayContent, Loading @@ -64,8 +64,8 @@ public class AppTransitionControllerTest extends WindowTestsBase { } @Test public void testTranslucentClose() throws Exception { synchronized (sWm.mGlobalLock) { public void testTranslucentClose() { synchronized (mWm.mGlobalLock) { final AppWindowToken behind = createAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); final AppWindowToken translucentClosing = createAppWindowToken(mDisplayContent, Loading
services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java +22 −28 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -32,81 +32,75 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.spy; import android.content.Context; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.view.Display; import android.view.IApplicationToken; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; /** * Test class for {@link AppTransition}. * * atest AppTransitionTests * Build/Install/Run: * atest FrameworksServicesTests:AppTransitionTests */ @SmallTest @Presubmit @RunWith(AndroidJUnit4.class) public class AppTransitionTests extends WindowTestsBase { private DisplayContent mDc; @Before public void setUp() throws Exception { super.setUp(); final Context context = InstrumentationRegistry.getTargetContext(); mDc = sWm.getDefaultDisplayContentLocked(); mDc = mWm.getDefaultDisplayContentLocked(); // For unit test, we don't need to test performSurfacePlacement to prevent some // abnormal interaction with surfaceflinger native side. sWm.mRoot = spy(sWm.mRoot); doNothing().when(sWm.mRoot).performSurfacePlacement(anyBoolean()); mWm.mRoot = spy(mWm.mRoot); doNothing().when(mWm.mRoot).performSurfacePlacement(anyBoolean()); } @Test public void testKeyguardOverride() throws Exception { sWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); public void testKeyguardOverride() { mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mDc.mAppTransition.getAppTransition()); } @Test public void testKeyguardKeep() throws Exception { sWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); public void testKeyguardKeep() { mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mDc.mAppTransition.getAppTransition()); } @Test public void testForceOverride() throws Exception { sWm.prepareAppTransition(TRANSIT_KEYGUARD_UNOCCLUDE, false /* alwaysKeepCurrent */); public void testForceOverride() { mWm.prepareAppTransition(TRANSIT_KEYGUARD_UNOCCLUDE, false /* alwaysKeepCurrent */); mDc.getController().prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */, 0 /* flags */, true /* forceOverride */); assertEquals(TRANSIT_ACTIVITY_OPEN, mDc.mAppTransition.getAppTransition()); } @Test public void testCrashing() throws Exception { sWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); public void testCrashing() { mWm.prepareAppTransition(TRANSIT_ACTIVITY_OPEN, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_CRASHING_ACTIVITY_CLOSE, mDc.mAppTransition.getAppTransition()); } @Test public void testKeepKeyguard_withCrashing() throws Exception { sWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); sWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); public void testKeepKeyguard_withCrashing() { mWm.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, false /* alwaysKeepCurrent */); mWm.prepareAppTransition(TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */); assertEquals(TRANSIT_KEYGUARD_GOING_AWAY, mDc.mAppTransition.getAppTransition()); } @Test public void testAppTransitionStateForMultiDisplay() throws Exception { public void testAppTransitionStateForMultiDisplay() { // Create 2 displays & presume both display the state is ON for ready to display & animate. final DisplayContent dc1 = createNewDisplayWithController(Display.STATE_ON); final DisplayContent dc2 = createNewDisplayWithController(Display.STATE_ON); Loading Loading @@ -149,7 +143,7 @@ public class AppTransitionTests extends WindowTestsBase { } @Test public void testCleanAppTransitionWhenTaskStackReparent() throws Exception { public void testCleanAppTransitionWhenTaskStackReparent() { // Create 2 displays & presume both display the state is ON for ready to display & animate. final DisplayContent dc1 = createNewDisplayWithController(Display.STATE_ON); final DisplayContent dc2 = createNewDisplayWithController(Display.STATE_ON); Loading
services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java +25 −24 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.content.res.Configuration.EMPTY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading @@ -29,10 +31,8 @@ import static org.junit.Assert.fail; import android.platform.test.annotations.Presubmit; import androidx.test.InstrumentationRegistry; import androidx.test.filters.FlakyTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.server.wm.WindowTestUtils.TestTaskWindowContainerController; Loading @@ -41,16 +41,17 @@ import org.junit.Test; /** * Test class for {@link AppWindowContainerController}. * * atest FrameworksServicesTests:com.android.server.wm.AppWindowContainerControllerTests * atest FrameworksServicesTests:AppWindowContainerControllerTests */ @FlakyTest(bugId = 74078662) @SmallTest @Presubmit @FlakyTest(bugId = 74078662) @org.junit.runner.RunWith(AndroidJUnit4.class) public class AppWindowContainerControllerTests extends WindowTestsBase { private final String mPackageName = getInstrumentation().getTargetContext().getPackageName(); @Test public void testRemoveContainer() throws Exception { public void testRemoveContainer() { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); Loading @@ -68,7 +69,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testSetOrientation() throws Exception { public void testSetOrientation() { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); Loading @@ -84,7 +85,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, controller.getOrientation()); // Reset display frozen state sWm.mDisplayFrozen = false; mWm.mDisplayFrozen = false; } private void assertHasStartingWindow(AppWindowToken atoken) { Loading @@ -103,10 +104,10 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testCreateRemoveStartingWindow() throws Exception { public void testCreateRemoveStartingWindow() { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); controller.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -118,34 +119,34 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testAddRemoveRace() throws Exception { public void testAddRemoveRace() { // There was once a race condition between adding and removing starting windows for (int i = 0; i < 1000; i++) { final WindowTestUtils.TestAppWindowContainerController controller = createAppWindowController(); controller.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); controller.removeStartingWindow(); waitUntilHandlersIdle(); assertNoStartingWindow(controller.getAppWindowToken(mDisplayContent)); controller.getAppWindowToken(mDisplayContent).getParent().getParent().removeImmediately(); controller.getAppWindowToken( mDisplayContent).getParent().getParent().removeImmediately(); } } @Test public void testTransferStartingWindow() throws Exception { public void testTransferStartingWindow() { final WindowTestUtils.TestAppWindowContainerController controller1 = createAppWindowController(); final WindowTestUtils.TestAppWindowContainerController controller2 = createAppWindowController(); controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller1.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller2.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(), true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -154,19 +155,19 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testTransferStartingWindowWhileCreating() throws Exception { public void testTransferStartingWindowWhileCreating() { final WindowTestUtils.TestAppWindowContainerController controller1 = createAppWindowController(); final WindowTestUtils.TestAppWindowContainerController controller2 = createAppWindowController(); ((TestWindowManagerPolicy) sWm.mPolicy).setRunnableWhenAddingSplashScreen(() -> { ((TestWindowManagerPolicy) mWm.mPolicy).setRunnableWhenAddingSplashScreen(() -> { // Surprise, ...! Transfer window in the middle of the creation flow. controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller2.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(), true, true, false, true, false, false); }); controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controller1.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -175,7 +176,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testTryTransferStartingWindowFromHiddenAboveToken() throws Exception { public void testTryTransferStartingWindowFromHiddenAboveToken() { // Add two tasks on top of each other. TestTaskWindowContainerController taskController = Loading @@ -186,7 +187,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { createAppWindowController(taskController); // Add a starting window. controllerTop.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(), controllerTop.addStartingWindow(mPackageName, android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true, false, false); waitUntilHandlersIdle(); Loading @@ -202,7 +203,7 @@ public class AppWindowContainerControllerTests extends WindowTestsBase { } @Test public void testReparent() throws Exception { public void testReparent() { final StackWindowController stackController = createStackControllerOnDisplay(mDisplayContent); final WindowTestUtils.TestTaskWindowContainerController taskController1 = Loading
services/tests/servicestests/src/com/android/server/wm/AppWindowTokenAnimationTests.java +10 −13 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -26,15 +26,14 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import android.view.SurfaceControl; import androidx.test.filters.SmallTest; import com.android.server.wm.WindowTestUtils.TestAppWindowToken; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; Loading @@ -43,10 +42,9 @@ import org.mockito.MockitoAnnotations; * Animation related tests for the {@link AppWindowToken} class. * * Build/Install/Run: * atest FrameworksServicesTests:com.android.server.wm.AppWindowTokenAnimationTests * atest FrameworksServicesTests:AppWindowTokenAnimationTests */ @SmallTest @RunWith(AndroidJUnit4.class) public class AppWindowTokenAnimationTests extends WindowTestsBase { private TestAppWindowToken mToken; Loading @@ -56,9 +54,8 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { @Mock private AnimationAdapter mSpec; @Override @Before public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); mToken = createTestAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN, Loading @@ -67,7 +64,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipAfterAnim_boundsLayerIsCreated() throws Exception { public void clipAfterAnim_boundsLayerIsCreated() { mToken.mNeedsAnimationBoundsLayer = true; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); Loading @@ -78,7 +75,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipAfterAnim_boundsLayerIsDestroyed() throws Exception { public void clipAfterAnim_boundsLayerIsDestroyed() { mToken.mNeedsAnimationBoundsLayer = true; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); final SurfaceControl leash = mToken.mSurfaceAnimator.mLeash; Loading @@ -95,7 +92,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipAfterAnimCancelled_boundsLayerIsDestroyed() throws Exception { public void clipAfterAnimCancelled_boundsLayerIsDestroyed() { mToken.mNeedsAnimationBoundsLayer = true; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); final SurfaceControl leash = mToken.mSurfaceAnimator.mLeash; Loading @@ -108,7 +105,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { } @Test public void clipNoneAnim_boundsLayerIsNotCreated() throws Exception { public void clipNoneAnim_boundsLayerIsNotCreated() { mToken.mNeedsAnimationBoundsLayer = false; mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */); Loading