Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipBoundsStateTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import java.util.function.Consumer; /** * Tests for {@link PipBoundsState}. */ Loading Loading @@ -178,4 +180,20 @@ public class PipBoundsStateTest extends ShellTestCase { mPipBoundsState.setOverrideMinSize(new Size(15, 10)); assertEquals(10, mPipBoundsState.getOverrideMinEdgeSize()); } @Test public void testSetBounds_updatesPipExclusionBounds() { final Consumer<Rect> callback = mock(Consumer.class); final Rect currentBounds = new Rect(10, 10, 20, 15); final Rect newBounds = new Rect(50, 50, 100, 75); mPipBoundsState.setBounds(currentBounds); mPipBoundsState.setPipExclusionBoundsChangeCallback(callback); // Setting the listener immediately calls back with the current bounds. verify(callback).accept(currentBounds); mPipBoundsState.setBounds(newBounds); // Updating the bounds makes the listener call back back with the new rect. verify(callback).accept(newBounds); } } libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipTaskOrganizerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.pip; import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; Loading @@ -31,6 +32,7 @@ import android.app.ActivityManager; import android.app.PictureInPictureParams; import android.content.ComponentName; import android.content.pm.ActivityInfo; import android.graphics.Rect; import android.os.RemoteException; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; Loading Loading @@ -221,6 +223,16 @@ public class PipTaskOrganizerTest extends ShellTestCase { assertEquals(minSize, mPipBoundsState.getOverrideMinSize()); } @Test public void onTaskVanished_clearsPipBounds() { mSpiedPipTaskOrganizer.onTaskAppeared(createTaskInfo(mComponent1, createPipParams(null)), null /* leash */); mPipBoundsState.setBounds(new Rect(100, 100, 200, 150)); mSpiedPipTaskOrganizer.onTaskVanished(createTaskInfo(mComponent1, createPipParams(null))); assertTrue(mPipBoundsState.getBounds().isEmpty()); } private void preparePipTaskOrg() { final DisplayInfo info = new DisplayInfo(); mPipBoundsState.setDisplayLayout(new DisplayLayout(info, Loading Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipBoundsStateTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import java.util.function.Consumer; /** * Tests for {@link PipBoundsState}. */ Loading Loading @@ -178,4 +180,20 @@ public class PipBoundsStateTest extends ShellTestCase { mPipBoundsState.setOverrideMinSize(new Size(15, 10)); assertEquals(10, mPipBoundsState.getOverrideMinEdgeSize()); } @Test public void testSetBounds_updatesPipExclusionBounds() { final Consumer<Rect> callback = mock(Consumer.class); final Rect currentBounds = new Rect(10, 10, 20, 15); final Rect newBounds = new Rect(50, 50, 100, 75); mPipBoundsState.setBounds(currentBounds); mPipBoundsState.setPipExclusionBoundsChangeCallback(callback); // Setting the listener immediately calls back with the current bounds. verify(callback).accept(currentBounds); mPipBoundsState.setBounds(newBounds); // Updating the bounds makes the listener call back back with the new rect. verify(callback).accept(newBounds); } }
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipTaskOrganizerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.pip; import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; Loading @@ -31,6 +32,7 @@ import android.app.ActivityManager; import android.app.PictureInPictureParams; import android.content.ComponentName; import android.content.pm.ActivityInfo; import android.graphics.Rect; import android.os.RemoteException; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; Loading Loading @@ -221,6 +223,16 @@ public class PipTaskOrganizerTest extends ShellTestCase { assertEquals(minSize, mPipBoundsState.getOverrideMinSize()); } @Test public void onTaskVanished_clearsPipBounds() { mSpiedPipTaskOrganizer.onTaskAppeared(createTaskInfo(mComponent1, createPipParams(null)), null /* leash */); mPipBoundsState.setBounds(new Rect(100, 100, 200, 150)); mSpiedPipTaskOrganizer.onTaskVanished(createTaskInfo(mComponent1, createPipParams(null))); assertTrue(mPipBoundsState.getBounds().isEmpty()); } private void preparePipTaskOrg() { final DisplayInfo info = new DisplayInfo(); mPipBoundsState.setDisplayLayout(new DisplayLayout(info, Loading