summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/BottomHalfPipAppHelper.kt2
-rw-r--r--tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/BottomHalfPipActivity.java2
-rw-r--r--tests/Input/src/com/android/server/input/InputManagerServiceTests.kt152
-rw-r--r--tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt72
-rw-r--r--tests/Input/src/com/android/test/input/UinputRecordingIntegrationTests.kt6
-rw-r--r--tests/NetworkSecurityConfigTest/Android.bp3
-rw-r--r--tests/NetworkSecurityConfigTest/TEST_MAPPING7
7 files changed, 99 insertions, 145 deletions
diff --git a/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/BottomHalfPipAppHelper.kt b/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/BottomHalfPipAppHelper.kt
index fe344c9b79f2..7b8b43af18da 100644
--- a/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/BottomHalfPipAppHelper.kt
+++ b/tests/FlickerTests/test-apps/app-helpers/src/com/android/server/wm/flicker/helpers/BottomHalfPipAppHelper.kt
@@ -25,7 +25,7 @@ import com.android.server.wm.flicker.testapp.ActivityOptions.BottomHalfPip
class BottomHalfPipAppHelper(
instrumentation: Instrumentation,
private val useLaunchingActivity: Boolean = false,
- private val fillTaskOnCreate: Boolean = true,
+ private val fillTaskOnCreate: Boolean = false,
) : PipAppHelper(
instrumentation,
appName = BottomHalfPip.LABEL,
diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/BottomHalfPipActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/BottomHalfPipActivity.java
index 3bbb94515f69..1f82d674cfa7 100644
--- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/BottomHalfPipActivity.java
+++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/BottomHalfPipActivity.java
@@ -31,7 +31,7 @@ import androidx.annotation.NonNull;
public class BottomHalfPipActivity extends PipActivity {
- private boolean mUseBottomHalfLayout;
+ private boolean mUseBottomHalfLayout = true;
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt b/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt
index d75a8f433af8..40f4f1ab0791 100644
--- a/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt
+++ b/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt
@@ -314,7 +314,17 @@ class InputManagerServiceTests {
}
}
- private fun createVirtualDisplays(count: Int): List<VirtualDisplay> {
+ private class AutoClosingVirtualDisplays(val displays: List<VirtualDisplay>) : AutoCloseable {
+ operator fun get(i: Int): VirtualDisplay = displays[i]
+
+ override fun close() {
+ for (display in displays) {
+ display.release()
+ }
+ }
+ }
+
+ private fun createVirtualDisplays(count: Int): AutoClosingVirtualDisplays {
val displayManager: DisplayManager = context.getSystemService(
DisplayManager::class.java
) as DisplayManager
@@ -329,7 +339,7 @@ class InputManagerServiceTests {
/* flags= */ 0
))
}
- return virtualDisplays
+ return AutoClosingVirtualDisplays(virtualDisplays)
}
// Helper function that creates a KeyEvent with Keycode A with the given action
@@ -374,50 +384,51 @@ class InputManagerServiceTests {
val mockSurfaceHolder2 = mock(SurfaceHolder::class.java)
`when`(mockSurfaceView2.holder).thenReturn(mockSurfaceHolder2)
- val virtualDisplays = createVirtualDisplays(2)
+ createVirtualDisplays(2).use { virtualDisplays ->
+ // Simulate an InputDevice
+ val inputDevice = createInputDevice()
- // Simulate an InputDevice
- val inputDevice = createInputDevice()
-
- // Associate input device with display
- service.addUniqueIdAssociationByDescriptor(
- inputDevice.descriptor,
- virtualDisplays[0].display.displayId.toString()
- )
+ // Associate input device with display
+ service.addUniqueIdAssociationByDescriptor(
+ inputDevice.descriptor,
+ virtualDisplays[0].display.displayId.toString()
+ )
- // Simulate 2 different KeyEvents
- val downEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_DOWN)
- val upEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_UP)
+ // Simulate 2 different KeyEvents
+ val downEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_DOWN)
+ val upEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_UP)
- // Create a mock OnKeyListener object
- val mockOnKeyListener = mock(OnKeyListener::class.java)
+ // Create a mock OnKeyListener object
+ val mockOnKeyListener = mock(OnKeyListener::class.java)
- // Verify that the event went to Display 1 not Display 2
- service.injectInputEvent(downEvent, InputEventInjectionSync.NONE)
+ // Verify that the event went to Display 1 not Display 2
+ service.injectInputEvent(downEvent, InputEventInjectionSync.NONE)
- // Call the onKey method on the mock OnKeyListener object
- mockOnKeyListener.onKey(mockSurfaceView1, /* keyCode= */ KeyEvent.KEYCODE_A, downEvent)
- mockOnKeyListener.onKey(mockSurfaceView2, /* keyCode= */ KeyEvent.KEYCODE_A, upEvent)
+ // Call the onKey method on the mock OnKeyListener object
+ mockOnKeyListener.onKey(mockSurfaceView1, /* keyCode= */ KeyEvent.KEYCODE_A, downEvent)
+ mockOnKeyListener.onKey(mockSurfaceView2, /* keyCode= */ KeyEvent.KEYCODE_A, upEvent)
- // Verify that the onKey method was called with the expected arguments
- verify(mockOnKeyListener).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, downEvent)
- verify(mockOnKeyListener, never()).onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, downEvent)
+ // Verify that the onKey method was called with the expected arguments
+ verify(mockOnKeyListener).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, downEvent)
+ verify(mockOnKeyListener, never())
+ .onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, downEvent)
- // Remove association
- service.removeUniqueIdAssociationByDescriptor(inputDevice.descriptor)
+ // Remove association
+ service.removeUniqueIdAssociationByDescriptor(inputDevice.descriptor)
- // Associate with Display 2
- service.addUniqueIdAssociationByDescriptor(
- inputDevice.descriptor,
- virtualDisplays[1].display.displayId.toString()
- )
+ // Associate with Display 2
+ service.addUniqueIdAssociationByDescriptor(
+ inputDevice.descriptor,
+ virtualDisplays[1].display.displayId.toString()
+ )
- // Simulate a KeyEvent
- service.injectInputEvent(upEvent, InputEventInjectionSync.NONE)
+ // Simulate a KeyEvent
+ service.injectInputEvent(upEvent, InputEventInjectionSync.NONE)
- // Verify that the event went to Display 2 not Display 1
- verify(mockOnKeyListener).onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, upEvent)
- verify(mockOnKeyListener, never()).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, upEvent)
+ // Verify that the event went to Display 2 not Display 1
+ verify(mockOnKeyListener).onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, upEvent)
+ verify(mockOnKeyListener, never()).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, upEvent)
+ }
}
@Test
@@ -436,50 +447,51 @@ class InputManagerServiceTests {
val mockSurfaceHolder2 = mock(SurfaceHolder::class.java)
`when`(mockSurfaceView2.holder).thenReturn(mockSurfaceHolder2)
- val virtualDisplays = createVirtualDisplays(2)
+ createVirtualDisplays(2).use { virtualDisplays ->
+ // Simulate an InputDevice
+ val inputDevice = createInputDevice()
- // Simulate an InputDevice
- val inputDevice = createInputDevice()
-
- // Associate input device with display
- service.addUniqueIdAssociationByPort(
- inputDevice.name,
- virtualDisplays[0].display.displayId.toString()
- )
+ // Associate input device with display
+ service.addUniqueIdAssociationByPort(
+ inputDevice.name,
+ virtualDisplays[0].display.displayId.toString()
+ )
- // Simulate 2 different KeyEvents
- val downEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_DOWN)
- val upEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_UP)
+ // Simulate 2 different KeyEvents
+ val downEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_DOWN)
+ val upEvent = createKeycodeAEvent(inputDevice, KeyEvent.ACTION_UP)
- // Create a mock OnKeyListener object
- val mockOnKeyListener = mock(OnKeyListener::class.java)
+ // Create a mock OnKeyListener object
+ val mockOnKeyListener = mock(OnKeyListener::class.java)
- // Verify that the event went to Display 1 not Display 2
- service.injectInputEvent(downEvent, InputEventInjectionSync.NONE)
+ // Verify that the event went to Display 1 not Display 2
+ service.injectInputEvent(downEvent, InputEventInjectionSync.NONE)
- // Call the onKey method on the mock OnKeyListener object
- mockOnKeyListener.onKey(mockSurfaceView1, /* keyCode= */ KeyEvent.KEYCODE_A, downEvent)
- mockOnKeyListener.onKey(mockSurfaceView2, /* keyCode= */ KeyEvent.KEYCODE_A, upEvent)
+ // Call the onKey method on the mock OnKeyListener object
+ mockOnKeyListener.onKey(mockSurfaceView1, /* keyCode= */ KeyEvent.KEYCODE_A, downEvent)
+ mockOnKeyListener.onKey(mockSurfaceView2, /* keyCode= */ KeyEvent.KEYCODE_A, upEvent)
- // Verify that the onKey method was called with the expected arguments
- verify(mockOnKeyListener).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, downEvent)
- verify(mockOnKeyListener, never()).onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, downEvent)
+ // Verify that the onKey method was called with the expected arguments
+ verify(mockOnKeyListener).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, downEvent)
+ verify(mockOnKeyListener, never())
+ .onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, downEvent)
- // Remove association
- service.removeUniqueIdAssociationByPort(inputDevice.name)
+ // Remove association
+ service.removeUniqueIdAssociationByPort(inputDevice.name)
- // Associate with Display 2
- service.addUniqueIdAssociationByPort(
- inputDevice.name,
- virtualDisplays[1].display.displayId.toString()
- )
+ // Associate with Display 2
+ service.addUniqueIdAssociationByPort(
+ inputDevice.name,
+ virtualDisplays[1].display.displayId.toString()
+ )
- // Simulate a KeyEvent
- service.injectInputEvent(upEvent, InputEventInjectionSync.NONE)
+ // Simulate a KeyEvent
+ service.injectInputEvent(upEvent, InputEventInjectionSync.NONE)
- // Verify that the event went to Display 2 not Display 1
- verify(mockOnKeyListener).onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, upEvent)
- verify(mockOnKeyListener, never()).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, upEvent)
+ // Verify that the event went to Display 2 not Display 1
+ verify(mockOnKeyListener).onKey(mockSurfaceView2, KeyEvent.KEYCODE_A, upEvent)
+ verify(mockOnKeyListener, never()).onKey(mockSurfaceView1, KeyEvent.KEYCODE_A, upEvent)
+ }
}
@Test
diff --git a/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt b/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt
index 8c04f647fb2f..e0532633d40b 100644
--- a/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt
+++ b/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt
@@ -736,30 +736,6 @@ class KeyGestureControllerTests {
intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
),
TestData(
- "META + ALT + '-' -> Magnification Zoom Out",
- intArrayOf(
- KeyEvent.KEYCODE_META_LEFT,
- KeyEvent.KEYCODE_ALT_LEFT,
- KeyEvent.KEYCODE_MINUS
- ),
- KeyGestureEvent.KEY_GESTURE_TYPE_MAGNIFICATION_ZOOM_OUT,
- intArrayOf(KeyEvent.KEYCODE_MINUS),
- KeyEvent.META_META_ON or KeyEvent.META_ALT_ON,
- intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
- ),
- TestData(
- "META + ALT + '=' -> Magnification Zoom In",
- intArrayOf(
- KeyEvent.KEYCODE_META_LEFT,
- KeyEvent.KEYCODE_ALT_LEFT,
- KeyEvent.KEYCODE_EQUALS
- ),
- KeyGestureEvent.KEY_GESTURE_TYPE_MAGNIFICATION_ZOOM_IN,
- intArrayOf(KeyEvent.KEYCODE_EQUALS),
- KeyEvent.META_META_ON or KeyEvent.META_ALT_ON,
- intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
- ),
- TestData(
"META + ALT + M -> Toggle Magnification",
intArrayOf(
KeyEvent.KEYCODE_META_LEFT,
@@ -784,54 +760,6 @@ class KeyGestureControllerTests {
intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
),
TestData(
- "META + ALT + 'Down' -> Magnification Pan Down",
- intArrayOf(
- KeyEvent.KEYCODE_META_LEFT,
- KeyEvent.KEYCODE_ALT_LEFT,
- KeyEvent.KEYCODE_DPAD_DOWN
- ),
- KeyGestureEvent.KEY_GESTURE_TYPE_MAGNIFICATION_PAN_DOWN,
- intArrayOf(KeyEvent.KEYCODE_DPAD_DOWN),
- KeyEvent.META_META_ON or KeyEvent.META_ALT_ON,
- intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
- ),
- TestData(
- "META + ALT + 'Up' -> Magnification Pan Up",
- intArrayOf(
- KeyEvent.KEYCODE_META_LEFT,
- KeyEvent.KEYCODE_ALT_LEFT,
- KeyEvent.KEYCODE_DPAD_UP
- ),
- KeyGestureEvent.KEY_GESTURE_TYPE_MAGNIFICATION_PAN_UP,
- intArrayOf(KeyEvent.KEYCODE_DPAD_UP),
- KeyEvent.META_META_ON or KeyEvent.META_ALT_ON,
- intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
- ),
- TestData(
- "META + ALT + 'Left' -> Magnification Pan Left",
- intArrayOf(
- KeyEvent.KEYCODE_META_LEFT,
- KeyEvent.KEYCODE_ALT_LEFT,
- KeyEvent.KEYCODE_DPAD_LEFT
- ),
- KeyGestureEvent.KEY_GESTURE_TYPE_MAGNIFICATION_PAN_LEFT,
- intArrayOf(KeyEvent.KEYCODE_DPAD_LEFT),
- KeyEvent.META_META_ON or KeyEvent.META_ALT_ON,
- intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
- ),
- TestData(
- "META + ALT + 'Right' -> Magnification Pan Right",
- intArrayOf(
- KeyEvent.KEYCODE_META_LEFT,
- KeyEvent.KEYCODE_ALT_LEFT,
- KeyEvent.KEYCODE_DPAD_RIGHT
- ),
- KeyGestureEvent.KEY_GESTURE_TYPE_MAGNIFICATION_PAN_RIGHT,
- intArrayOf(KeyEvent.KEYCODE_DPAD_RIGHT),
- KeyEvent.META_META_ON or KeyEvent.META_ALT_ON,
- intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
- ),
- TestData(
"META + ALT + 'V' -> Toggle Voice Access",
intArrayOf(
KeyEvent.KEYCODE_META_LEFT,
diff --git a/tests/Input/src/com/android/test/input/UinputRecordingIntegrationTests.kt b/tests/Input/src/com/android/test/input/UinputRecordingIntegrationTests.kt
index 9e0f7347943d..bc0b7a5c816c 100644
--- a/tests/Input/src/com/android/test/input/UinputRecordingIntegrationTests.kt
+++ b/tests/Input/src/com/android/test/input/UinputRecordingIntegrationTests.kt
@@ -29,6 +29,7 @@ import android.view.MotionEvent
import androidx.test.platform.app.InstrumentationRegistry
import com.android.cts.input.BatchedEventSplitter
import com.android.cts.input.CaptureEventActivity
+import com.android.cts.input.DebugInputRule
import com.android.cts.input.InputJsonParser
import com.android.cts.input.VirtualDisplayActivityScenario
import com.android.cts.input.inputeventmatchers.isResampled
@@ -97,6 +98,10 @@ class UinputRecordingIntegrationTests {
private lateinit var instrumentation: Instrumentation
private lateinit var parser: InputJsonParser
+
+ @get:Rule
+ val debugInputRule = DebugInputRule()
+
@get:Rule
val testName = TestName()
@@ -109,6 +114,7 @@ class UinputRecordingIntegrationTests {
parser = InputJsonParser(instrumentation.context)
}
+ @DebugInputRule.DebugInput(bug = 389901828)
@Test
fun testEvemuRecording() {
VirtualDisplayActivityScenario.AutoClose<CaptureEventActivity>(
diff --git a/tests/NetworkSecurityConfigTest/Android.bp b/tests/NetworkSecurityConfigTest/Android.bp
index 4c48eaa4622e..6a68f2bb7ff9 100644
--- a/tests/NetworkSecurityConfigTest/Android.bp
+++ b/tests/NetworkSecurityConfigTest/Android.bp
@@ -11,11 +11,12 @@ android_test {
name: "NetworkSecurityConfigTests",
certificate: "platform",
libs: [
- "android.test.runner.stubs.system",
"android.test.base.stubs.system",
+ "android.test.runner.stubs.system",
],
static_libs: ["junit"],
// Include all test java files.
srcs: ["src/**/*.java"],
platform_apis: true,
+ test_suites: ["general-tests"],
}
diff --git a/tests/NetworkSecurityConfigTest/TEST_MAPPING b/tests/NetworkSecurityConfigTest/TEST_MAPPING
new file mode 100644
index 000000000000..d1b9aa1e3b53
--- /dev/null
+++ b/tests/NetworkSecurityConfigTest/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "postsubmit": [
+ {
+ "name": "NetworkSecurityConfigTests"
+ }
+ ]
+}