Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/config/DefaultLetterboxDependenciesHelperTest.kt +4 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import com.android.wm.shell.ShellTestCase import com.android.wm.shell.desktopmode.DesktopRepository import com.android.wm.shell.util.testLetterboxDependenciesHelper import java.util.function.Consumer import kotlin.test.assertFalse import kotlin.test.assertTrue import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any Loading @@ -45,7 +47,7 @@ class DefaultLetterboxDependenciesHelperTest : ShellTestCase() { inputChange { } r.configureDesktopRepository(isAnyDeskActive = false) validateIsDesktopWindowingAction { shouldDestroy -> assert(!shouldDestroy) assertFalse(shouldDestroy) } } } Loading @@ -58,7 +60,7 @@ class DefaultLetterboxDependenciesHelperTest : ShellTestCase() { inputChange { } r.configureDesktopRepository(isAnyDeskActive = true) validateIsDesktopWindowingAction { shouldDestroy -> assert(shouldDestroy) assertTrue(shouldDestroy) } } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/MultiLetterboxLifecycleEventFactoryTest.kt +23 −19 Original line number Diff line number Diff line Loading @@ -22,9 +22,14 @@ import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.compatui.letterbox.lifecycle.FakeLetterboxLifecycleEventFactory.Companion.FAKE_EVENT import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import java.util.function.Consumer import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue import org.junit.Test import org.junit.runner.RunWith import java.util.function.Consumer /** * Tests for [MultiLetterboxLifecycleEventFactory]. Loading @@ -47,15 +52,15 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCanHandle { canHandler -> assert(canHandler == true) assertTrue(canHandler) r.assertOnCandidate(0) { f -> assert(f.canHandleInvokeTimes == 1) assertEquals(1, f.canHandleInvokeTimes) } r.assertOnCandidate(1) { f -> assert(f.canHandleInvokeTimes == 1) assertEquals(1, f.canHandleInvokeTimes) } r.assertOnCandidate(2) { f -> assert(f.canHandleInvokeTimes == 0) assertEquals(0, f.canHandleInvokeTimes) } } } Loading @@ -73,7 +78,7 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCanHandle { canHandler -> assert(canHandler == false) assertFalse(canHandler) } } } Loading @@ -90,11 +95,11 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCreateLifecycleEvent { event -> assert(event == null) assertNull(event) for (pos in 0..2) { r.assertOnCandidate(pos) { f -> assert(f.canHandleInvokeTimes == 1) assert(f.createLifecycleEventInvokeTimes == 0) assertEquals(1, f.canHandleInvokeTimes) assertEquals(0, f.createLifecycleEventInvokeTimes) } } } Loading @@ -119,21 +124,21 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCreateLifecycleEvent { event -> assert(event != null) assertNotNull(event) r.assertOnCandidate(0) { f -> assert(f.canHandleInvokeTimes == 1) assert(f.createLifecycleEventInvokeTimes == 0) assertEquals(1, f.canHandleInvokeTimes) assertEquals(0, f.createLifecycleEventInvokeTimes) } r.assertOnCandidate(1) { f -> assert(f.canHandleInvokeTimes == 1) assert(f.createLifecycleEventInvokeTimes == 1) assertEquals(1, f.canHandleInvokeTimes) assertEquals(1, f.createLifecycleEventInvokeTimes) } r.assertOnCandidate(2) { f -> assert(f.canHandleInvokeTimes == 0) assert(f.createLifecycleEventInvokeTimes == 0) assertEquals(0, f.canHandleInvokeTimes) assertEquals(0, f.createLifecycleEventInvokeTimes) } assert(event?.taskId == 30) assert(event?.taskBounds == Rect(1, 2, 3, 4)) assertEquals(30, event.taskId) assertEquals(Rect(1, 2, 3, 4), event.taskBounds) } } } Loading @@ -152,7 +157,6 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { */ class LetterboxLifecycleControllerImplRobotTest { private val candidates = mutableListOf<FakeLetterboxLifecycleEventFactory>() fun getLetterboxLifecycleEventFactory(): () -> LetterboxLifecycleEventFactory = { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactoryTest.kt +13 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import java.util.function.Consumer import kotlin.test.assertFalse import kotlin.test.assertNull import kotlin.test.assertTrue import org.junit.Test import org.junit.runner.RunWith Loading @@ -44,10 +47,10 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { mode = TRANSIT_CLOSE } validateCanHandle { canHandle -> assert(canHandle) assertTrue(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) assertNull(event) } } } Loading @@ -64,38 +67,37 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } validateCanHandle { canHandle -> assert(canHandle) assertTrue(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) assertNull(event) } } } } @Test fun `Factory is skipped when Change is not closing for a Task which is NOT a leaf`() { fun `Factory is active when Change is not closing for a Task which is NOT a leaf`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { mode = TRANSIT_OPEN runningTaskInfo { ti -> ti.appCompatTaskInfo.setIsLeafTask(true) ti.appCompatTaskInfo.setIsLeafTask(false) } } validateCanHandle { canHandle -> assert(!canHandle) assertTrue(canHandle) } validateCreateLifecycleEvent { event -> assert(event != null) assert(event?.type == LetterboxLifecycleEventType.NONE) assertNull(event) } } } } @Test fun `Factory is skipped when Change is not closing for an Activity Transition`() { fun `Factory is NOT active when Change is not closing for an Activity Transition`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { Loading @@ -105,11 +107,7 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } validateCanHandle { canHandle -> assert(!canHandle) } validateCreateLifecycleEvent { event -> assert(event != null) assert(event?.type == LetterboxLifecycleEventType.NONE) assertFalse(canHandle) } } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/state/LetterboxTaskListenerAdapterTest.kt +7 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.util.testTaskAppearedListener import com.android.wm.shell.util.testTaskVanishedListener import java.util.function.Consumer import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any Loading Loading @@ -78,8 +81,8 @@ class LetterboxTaskListenerAdapterTest : ShellTestCase() { leash { leashTest } validateOnTaskAppeared { r.validateItem(10) { item -> assert(item?.containerLeash == leashTest) assert(item?.containerToken == tokenTest) assertEquals(leashTest, item?.containerLeash) assertEquals(tokenTest, item?.containerToken) } } } Loading @@ -99,7 +102,7 @@ class LetterboxTaskListenerAdapterTest : ShellTestCase() { leash { leashTest } validateOnTaskAppeared { r.validateItem(10) { item -> assert(item != null) assertNotNull(item) } } } Loading @@ -110,7 +113,7 @@ class LetterboxTaskListenerAdapterTest : ShellTestCase() { } validateOnTaskVanished { r.validateItem(10) { item -> assert(item == null) assertNull(item) } } } Loading Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/config/DefaultLetterboxDependenciesHelperTest.kt +4 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import com.android.wm.shell.ShellTestCase import com.android.wm.shell.desktopmode.DesktopRepository import com.android.wm.shell.util.testLetterboxDependenciesHelper import java.util.function.Consumer import kotlin.test.assertFalse import kotlin.test.assertTrue import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any Loading @@ -45,7 +47,7 @@ class DefaultLetterboxDependenciesHelperTest : ShellTestCase() { inputChange { } r.configureDesktopRepository(isAnyDeskActive = false) validateIsDesktopWindowingAction { shouldDestroy -> assert(!shouldDestroy) assertFalse(shouldDestroy) } } } Loading @@ -58,7 +60,7 @@ class DefaultLetterboxDependenciesHelperTest : ShellTestCase() { inputChange { } r.configureDesktopRepository(isAnyDeskActive = true) validateIsDesktopWindowingAction { shouldDestroy -> assert(shouldDestroy) assertTrue(shouldDestroy) } } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/MultiLetterboxLifecycleEventFactoryTest.kt +23 −19 Original line number Diff line number Diff line Loading @@ -22,9 +22,14 @@ import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.compatui.letterbox.lifecycle.FakeLetterboxLifecycleEventFactory.Companion.FAKE_EVENT import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import java.util.function.Consumer import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue import org.junit.Test import org.junit.runner.RunWith import java.util.function.Consumer /** * Tests for [MultiLetterboxLifecycleEventFactory]. Loading @@ -47,15 +52,15 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCanHandle { canHandler -> assert(canHandler == true) assertTrue(canHandler) r.assertOnCandidate(0) { f -> assert(f.canHandleInvokeTimes == 1) assertEquals(1, f.canHandleInvokeTimes) } r.assertOnCandidate(1) { f -> assert(f.canHandleInvokeTimes == 1) assertEquals(1, f.canHandleInvokeTimes) } r.assertOnCandidate(2) { f -> assert(f.canHandleInvokeTimes == 0) assertEquals(0, f.canHandleInvokeTimes) } } } Loading @@ -73,7 +78,7 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCanHandle { canHandler -> assert(canHandler == false) assertFalse(canHandler) } } } Loading @@ -90,11 +95,11 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCreateLifecycleEvent { event -> assert(event == null) assertNull(event) for (pos in 0..2) { r.assertOnCandidate(pos) { f -> assert(f.canHandleInvokeTimes == 1) assert(f.createLifecycleEventInvokeTimes == 0) assertEquals(1, f.canHandleInvokeTimes) assertEquals(0, f.createLifecycleEventInvokeTimes) } } } Loading @@ -119,21 +124,21 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { // No specific Change initialization required. } validateCreateLifecycleEvent { event -> assert(event != null) assertNotNull(event) r.assertOnCandidate(0) { f -> assert(f.canHandleInvokeTimes == 1) assert(f.createLifecycleEventInvokeTimes == 0) assertEquals(1, f.canHandleInvokeTimes) assertEquals(0, f.createLifecycleEventInvokeTimes) } r.assertOnCandidate(1) { f -> assert(f.canHandleInvokeTimes == 1) assert(f.createLifecycleEventInvokeTimes == 1) assertEquals(1, f.canHandleInvokeTimes) assertEquals(1, f.createLifecycleEventInvokeTimes) } r.assertOnCandidate(2) { f -> assert(f.canHandleInvokeTimes == 0) assert(f.createLifecycleEventInvokeTimes == 0) assertEquals(0, f.canHandleInvokeTimes) assertEquals(0, f.createLifecycleEventInvokeTimes) } assert(event?.taskId == 30) assert(event?.taskBounds == Rect(1, 2, 3, 4)) assertEquals(30, event.taskId) assertEquals(Rect(1, 2, 3, 4), event.taskBounds) } } } Loading @@ -152,7 +157,6 @@ class MultiLetterboxLifecycleEventFactoryTest : ShellTestCase() { */ class LetterboxLifecycleControllerImplRobotTest { private val candidates = mutableListOf<FakeLetterboxLifecycleEventFactory>() fun getLetterboxLifecycleEventFactory(): () -> LetterboxLifecycleEventFactory = { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/lifecycle/SkipLetterboxLifecycleEventFactoryTest.kt +13 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ import androidx.test.filters.SmallTest import com.android.wm.shell.ShellTestCase import com.android.wm.shell.util.testLetterboxLifecycleEventFactory import java.util.function.Consumer import kotlin.test.assertFalse import kotlin.test.assertNull import kotlin.test.assertTrue import org.junit.Test import org.junit.runner.RunWith Loading @@ -44,10 +47,10 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { mode = TRANSIT_CLOSE } validateCanHandle { canHandle -> assert(canHandle) assertTrue(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) assertNull(event) } } } Loading @@ -64,38 +67,37 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } validateCanHandle { canHandle -> assert(canHandle) assertTrue(canHandle) } validateCreateLifecycleEvent { event -> assert(event == null) assertNull(event) } } } } @Test fun `Factory is skipped when Change is not closing for a Task which is NOT a leaf`() { fun `Factory is active when Change is not closing for a Task which is NOT a leaf`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { mode = TRANSIT_OPEN runningTaskInfo { ti -> ti.appCompatTaskInfo.setIsLeafTask(true) ti.appCompatTaskInfo.setIsLeafTask(false) } } validateCanHandle { canHandle -> assert(!canHandle) assertTrue(canHandle) } validateCreateLifecycleEvent { event -> assert(event != null) assert(event?.type == LetterboxLifecycleEventType.NONE) assertNull(event) } } } } @Test fun `Factory is skipped when Change is not closing for an Activity Transition`() { fun `Factory is NOT active when Change is not closing for an Activity Transition`() { runTestScenario { r -> testLetterboxLifecycleEventFactory(r.getLetterboxLifecycleEventFactory()) { inputChange { Loading @@ -105,11 +107,7 @@ class SkipLetterboxLifecycleEventFactoryTest : ShellTestCase() { } } validateCanHandle { canHandle -> assert(!canHandle) } validateCreateLifecycleEvent { event -> assert(event != null) assert(event?.type == LetterboxLifecycleEventType.NONE) assertFalse(canHandle) } } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/letterbox/state/LetterboxTaskListenerAdapterTest.kt +7 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.util.testTaskAppearedListener import com.android.wm.shell.util.testTaskVanishedListener import java.util.function.Consumer import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any Loading Loading @@ -78,8 +81,8 @@ class LetterboxTaskListenerAdapterTest : ShellTestCase() { leash { leashTest } validateOnTaskAppeared { r.validateItem(10) { item -> assert(item?.containerLeash == leashTest) assert(item?.containerToken == tokenTest) assertEquals(leashTest, item?.containerLeash) assertEquals(tokenTest, item?.containerToken) } } } Loading @@ -99,7 +102,7 @@ class LetterboxTaskListenerAdapterTest : ShellTestCase() { leash { leashTest } validateOnTaskAppeared { r.validateItem(10) { item -> assert(item != null) assertNotNull(item) } } } Loading @@ -110,7 +113,7 @@ class LetterboxTaskListenerAdapterTest : ShellTestCase() { } validateOnTaskVanished { r.validateItem(10) { item -> assert(item == null) assertNull(item) } } } Loading