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

https://github.com/android/platform_frameworks_base · Kotlin · 119 lines · 84 code · 12 blank · 23 comment · 1 complexity · 4a9127ad1e2b3f49751a05c4219b8e67 MD5 · raw file

  1. /*
  2. * Copyright (C) 2020 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 androidx.test.filters.FlakyTest
  20. import androidx.test.filters.RequiresDevice
  21. import com.android.server.wm.flicker.FlickerParametersRunnerFactory
  22. import com.android.server.wm.flicker.FlickerTestParameter
  23. import com.android.server.wm.flicker.FlickerTestParameterFactory
  24. import com.android.server.wm.flicker.annotation.Group1
  25. import com.android.server.wm.flicker.dsl.FlickerBuilder
  26. import com.android.wm.shell.flicker.appPairsDividerIsInvisible
  27. import com.android.wm.shell.flicker.helpers.AppPairsHelper
  28. import com.android.wm.shell.flicker.helpers.MultiWindowHelper.Companion.resetMultiWindowConfig
  29. import com.android.wm.shell.flicker.helpers.MultiWindowHelper.Companion.setSupportsNonResizableMultiWindow
  30. import org.junit.After
  31. import org.junit.Before
  32. import org.junit.FixMethodOrder
  33. import org.junit.Test
  34. import org.junit.runner.RunWith
  35. import org.junit.runners.MethodSorters
  36. import org.junit.runners.Parameterized
  37. /**
  38. * Test cold launch app from launcher. When the device doesn't support non-resizable in multi window
  39. * {@link Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW}, app pairs should not pair
  40. * non-resizable apps.
  41. *
  42. * To run this test: `atest WMShellFlickerTests:AppPairsTestCannotPairNonResizeableApps`
  43. */
  44. @RequiresDevice
  45. @RunWith(Parameterized::class)
  46. @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
  47. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  48. @Group1
  49. class AppPairsTestCannotPairNonResizeableApps(
  50. testSpec: FlickerTestParameter
  51. ) : AppPairsTransition(testSpec) {
  52. override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
  53. get() = {
  54. super.transition(this, it)
  55. transitions {
  56. nonResizeableApp?.launchViaIntent(wmHelper)
  57. // TODO pair apps through normal UX flow
  58. executeShellCommand(
  59. composePairsCommand(primaryTaskId, nonResizeableTaskId, pair = true))
  60. SystemClock.sleep(AppPairsHelper.TIMEOUT_MS)
  61. }
  62. }
  63. @Before
  64. override fun setup() {
  65. super.setup()
  66. setSupportsNonResizableMultiWindow(instrumentation, -1)
  67. }
  68. @After
  69. override fun teardown() {
  70. super.teardown()
  71. resetMultiWindowConfig(instrumentation)
  72. }
  73. @FlakyTest
  74. @Test
  75. override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
  76. @FlakyTest
  77. @Test
  78. override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
  79. @FlakyTest
  80. @Test
  81. override fun navBarLayerIsAlwaysVisible() {
  82. super.navBarLayerIsAlwaysVisible()
  83. }
  84. @Presubmit
  85. @Test
  86. fun appPairsDividerIsInvisible() = testSpec.appPairsDividerIsInvisible()
  87. @Presubmit
  88. @Test
  89. fun onlyResizeableAppWindowVisible() {
  90. val nonResizeableApp = nonResizeableApp
  91. require(nonResizeableApp != null) {
  92. "Non resizeable app not initialized"
  93. }
  94. testSpec.assertWmEnd {
  95. isVisible(nonResizeableApp.defaultWindowName)
  96. isInvisible(primaryApp.defaultWindowName)
  97. }
  98. }
  99. companion object {
  100. @Parameterized.Parameters(name = "{0}")
  101. @JvmStatic
  102. fun getParams(): List<FlickerTestParameter> {
  103. return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests(
  104. repetitions = AppPairsHelper.TEST_REPETITIONS)
  105. }
  106. }
  107. }