/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsRotateAndEnterAppPairsMode.kt

https://github.com/android/platform_frameworks_base · Kotlin · 116 lines · 86 code · 11 blank · 19 comment · 0 complexity · 46f335a0bc59c974598420828d40c9ff MD5 · raw file

  1. /*
  2. * Copyright (C) 2021 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.android.wm.shell.flicker.apppairs
  17. import android.os.SystemClock
  18. import android.platform.test.annotations.Presubmit
  19. import android.view.Surface
  20. import androidx.test.filters.FlakyTest
  21. import androidx.test.filters.RequiresDevice
  22. import com.android.server.wm.flicker.FlickerParametersRunnerFactory
  23. import com.android.server.wm.flicker.FlickerTestParameter
  24. import com.android.server.wm.flicker.FlickerTestParameterFactory
  25. import com.android.server.wm.flicker.annotation.Group1
  26. import com.android.server.wm.flicker.dsl.FlickerBuilder
  27. import com.android.server.wm.flicker.endRotation
  28. import com.android.server.wm.flicker.helpers.setRotation
  29. import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
  30. import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
  31. import com.android.wm.shell.flicker.appPairsDividerIsVisible
  32. import com.android.wm.shell.flicker.appPairsPrimaryBoundsIsVisible
  33. import com.android.wm.shell.flicker.appPairsSecondaryBoundsIsVisible
  34. import com.android.wm.shell.flicker.helpers.AppPairsHelper
  35. import com.android.wm.shell.flicker.helpers.SplitScreenHelper
  36. import org.junit.FixMethodOrder
  37. import org.junit.Test
  38. import org.junit.runner.RunWith
  39. import org.junit.runners.MethodSorters
  40. import org.junit.runners.Parameterized
  41. /**
  42. * Test open apps to app pairs and rotate.
  43. * To run this test: `atest WMShellFlickerTests:RotateTwoLaunchedAppsRotateAndEnterAppPairsMode`
  44. */
  45. @RequiresDevice
  46. @RunWith(Parameterized::class)
  47. @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
  48. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  49. @Group1
  50. class RotateTwoLaunchedAppsRotateAndEnterAppPairsMode(
  51. testSpec: FlickerTestParameter
  52. ) : RotateTwoLaunchedAppsTransition(testSpec) {
  53. override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
  54. get() = {
  55. super.transition(this, it)
  56. transitions {
  57. this.setRotation(testSpec.config.endRotation)
  58. executeShellCommand(
  59. composePairsCommand(primaryTaskId, secondaryTaskId, pair = true))
  60. SystemClock.sleep(AppPairsHelper.TIMEOUT_MS)
  61. }
  62. }
  63. @Presubmit
  64. @Test
  65. fun appPairsDividerIsVisible() = testSpec.appPairsDividerIsVisible()
  66. @Presubmit
  67. @Test
  68. override fun navBarWindowIsAlwaysVisible() = testSpec.navBarWindowIsAlwaysVisible()
  69. @Presubmit
  70. @Test
  71. override fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible()
  72. @FlakyTest
  73. @Test
  74. override fun statusBarLayerIsAlwaysVisible() {
  75. super.statusBarLayerIsAlwaysVisible()
  76. }
  77. @Presubmit
  78. @Test
  79. fun bothAppWindowsVisible() {
  80. testSpec.assertWmEnd {
  81. isVisible(primaryApp.defaultWindowName)
  82. isVisible(secondaryApp.defaultWindowName)
  83. }
  84. }
  85. @FlakyTest(bugId = 172776659)
  86. @Test
  87. fun appPairsPrimaryBoundsIsVisible() =
  88. testSpec.appPairsPrimaryBoundsIsVisible(testSpec.config.endRotation,
  89. primaryApp.defaultWindowName)
  90. @FlakyTest(bugId = 172776659)
  91. @Test
  92. fun appPairsSecondaryBoundsIsVisible() =
  93. testSpec.appPairsSecondaryBoundsIsVisible(testSpec.config.endRotation,
  94. secondaryApp.defaultWindowName)
  95. companion object {
  96. @Parameterized.Parameters(name = "{0}")
  97. @JvmStatic
  98. fun getParams(): Collection<FlickerTestParameter> {
  99. return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests(
  100. repetitions = SplitScreenHelper.TEST_REPETITIONS,
  101. supportedRotations = listOf(Surface.ROTATION_90, Surface.ROTATION_270)
  102. )
  103. }
  104. }
  105. }