diff options
14 files changed, 135 insertions, 31 deletions
diff --git a/libs/WindowManager/Shell/tests/flicker/Android.bp b/libs/WindowManager/Shell/tests/flicker/Android.bp index dfbadae2b853..6f73a7e4f283 100644 --- a/libs/WindowManager/Shell/tests/flicker/Android.bp +++ b/libs/WindowManager/Shell/tests/flicker/Android.bp @@ -114,6 +114,7 @@ java_defaults { "flickertestapplib", "flickerlib", "flickerlib-helpers", + "flickerlib-trace_processor_shell", "platform-test-annotations", "wm-flicker-common-app-helpers", "wm-flicker-common-assertions", diff --git a/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml b/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml index 6a87de47def4..ae130b8f6f7d 100644 --- a/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml +++ b/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml @@ -45,9 +45,13 @@ <uses-permission android:name="android.permission.MANAGE_ACTIVITY_TASKS" /> <!-- Enable bubble notification--> <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" /> + <!-- Allow the test to connect to perfetto trace processor --> + <uses-permission android:name="android.permission.INTERNET"/> - <!-- Allow the test to write directly to /sdcard/ --> - <application android:requestLegacyExternalStorage="true" android:largeHeap="true"> + <!-- Allow the test to write directly to /sdcard/ and connect to trace processor --> + <application android:requestLegacyExternalStorage="true" + android:networkSecurityConfig="@xml/network_security_config" + android:largeHeap="true"> <uses-library android:name="android.test.runner"/> <service android:name=".NotificationListener" diff --git a/libs/WindowManager/Shell/tests/flicker/res/xml/network_security_config.xml b/libs/WindowManager/Shell/tests/flicker/res/xml/network_security_config.xml new file mode 100644 index 000000000000..4bd9ca049f55 --- /dev/null +++ b/libs/WindowManager/Shell/tests/flicker/res/xml/network_security_config.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<network-security-config> + <domain-config cleartextTrafficPermitted="true"> + <domain includeSubdomains="true">localhost</domain> + </domain-config> +</network-security-config> diff --git a/tests/FlickerTests/Android.bp b/tests/FlickerTests/Android.bp index 2ccc0fa9e1e7..a2ae56eaeadc 100644 --- a/tests/FlickerTests/Android.bp +++ b/tests/FlickerTests/Android.bp @@ -95,6 +95,7 @@ java_defaults { "flickertestapplib", "flickerlib", "flickerlib-helpers", + "flickerlib-trace_processor_shell", "platform-test-annotations", "wm-flicker-common-app-helpers", "wm-shell-flicker-utils", diff --git a/tests/FlickerTests/manifests/AndroidManifest.xml b/tests/FlickerTests/manifests/AndroidManifest.xml index 1a34d9ea0f83..6bc7cbe88589 100644 --- a/tests/FlickerTests/manifests/AndroidManifest.xml +++ b/tests/FlickerTests/manifests/AndroidManifest.xml @@ -44,8 +44,12 @@ <uses-permission android:name="android.permission.MANAGE_ACTIVITY_TASKS" /> <!-- ActivityOptions.makeCustomTaskAnimation() --> <uses-permission android:name="android.permission.START_TASKS_FROM_RECENTS" /> - <!-- Allow the test to write directly to /sdcard/ --> - <application android:requestLegacyExternalStorage="true" android:largeHeap="true"> + <!-- Allow the test to connect to perfetto trace processor --> + <uses-permission android:name="android.permission.INTERNET"/> + <!-- Allow the test to write directly to /sdcard/ and connect to trace processor --> + <application android:requestLegacyExternalStorage="true" + android:networkSecurityConfig="@xml/network_security_config" + android:largeHeap="true"> <uses-library android:name="android.test.runner"/> <uses-library android:name="androidx.window.extensions" android:required="false"/> diff --git a/tests/FlickerTests/res/xml/network_security_config.xml b/tests/FlickerTests/res/xml/network_security_config.xml new file mode 100644 index 000000000000..4bd9ca049f55 --- /dev/null +++ b/tests/FlickerTests/res/xml/network_security_config.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<network-security-config> + <domain-config cleartextTrafficPermitted="true"> + <domain includeSubdomains="true">localhost</domain> + </domain-config> +</network-security-config> diff --git a/tests/SurfaceViewBufferTests/Android.bp b/tests/SurfaceViewBufferTests/Android.bp index dc75f00e7cdc..38313f85c31d 100644 --- a/tests/SurfaceViewBufferTests/Android.bp +++ b/tests/SurfaceViewBufferTests/Android.bp @@ -23,7 +23,10 @@ package { android_test { name: "SurfaceViewBufferTests", - srcs: ["**/*.java","**/*.kt"], + srcs: [ + "**/*.java", + "**/*.kt", + ], manifest: "AndroidManifest.xml", test_config: "AndroidTest.xml", platform_apis: true, @@ -41,6 +44,7 @@ android_test { "kotlin-stdlib", "kotlinx-coroutines-android", "flickerlib", + "flickerlib-trace_processor_shell", "truth-prebuilt", "cts-wm-util", "CtsSurfaceValidatorLib", @@ -60,7 +64,7 @@ cc_library_shared { "libandroid", ], include_dirs: [ - "system/core/include" + "system/core/include", ], stl: "libc++_static", cflags: [ diff --git a/tests/SurfaceViewBufferTests/AndroidManifest.xml b/tests/SurfaceViewBufferTests/AndroidManifest.xml index 78415e8641eb..798c67a320ce 100644 --- a/tests/SurfaceViewBufferTests/AndroidManifest.xml +++ b/tests/SurfaceViewBufferTests/AndroidManifest.xml @@ -29,9 +29,12 @@ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <!-- Save failed test bitmap images !--> <uses-permission android:name="android.Manifest.permission.WRITE_EXTERNAL_STORAGE"/> + <!-- Allow the test to connect to perfetto trace processor --> + <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="false" - android:supportsRtl="true"> + android:supportsRtl="true" + android:networkSecurityConfig="@xml/network_security_config"> <activity android:name=".MainActivity" android:taskAffinity="com.android.test.MainActivity" android:theme="@style/AppTheme" diff --git a/tests/SurfaceViewBufferTests/res/xml/network_security_config.xml b/tests/SurfaceViewBufferTests/res/xml/network_security_config.xml new file mode 100644 index 000000000000..4bd9ca049f55 --- /dev/null +++ b/tests/SurfaceViewBufferTests/res/xml/network_security_config.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<network-security-config> + <domain-config cleartextTrafficPermitted="true"> + <domain includeSubdomains="true">localhost</domain> + </domain-config> +</network-security-config> diff --git a/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt b/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt index a38019d67376..b03b7335b08b 100644 --- a/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt +++ b/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt @@ -21,11 +21,9 @@ import android.graphics.Color import android.graphics.Rect import android.util.Log import androidx.test.ext.junit.rules.ActivityScenarioRule -import android.tools.common.flicker.subject.layers.LayerSubject import android.tools.common.traces.surfaceflinger.LayersTrace -import android.tools.device.traces.io.ResultWriter -import android.tools.device.traces.monitors.surfaceflinger.LayersTraceMonitor import android.tools.device.traces.monitors.withSFTracing +import android.tools.device.traces.monitors.PerfettoTraceMonitor import junit.framework.Assert import org.junit.After import org.junit.Before @@ -33,6 +31,7 @@ import org.junit.Rule import java.io.FileOutputStream import java.io.IOException import java.util.concurrent.CountDownLatch +import perfetto.protos.PerfettoConfig.SurfaceFlingerLayersConfig open class SurfaceTracingTestBase(useBlastAdapter: Boolean) : SurfaceViewBufferTestBase(useBlastAdapter) { @@ -43,7 +42,7 @@ open class SurfaceTracingTestBase(useBlastAdapter: Boolean) : @Before override fun setup() { super.setup() - stopLayerTrace() + PerfettoTraceMonitor.stopAllSessions() addSurfaceView() } @@ -83,10 +82,6 @@ open class SurfaceTracingTestBase(useBlastAdapter: Boolean) : instrumentation.waitForIdleSync() } - private fun stopLayerTrace() { - LayersTraceMonitor().stop(ResultWriter()) - } - fun checkPixels(bounds: Rect, @ColorInt color: Int) { val screenshot = instrumentation.getUiAutomation().takeScreenshot() val pixels = IntArray(screenshot.width * screenshot.height) @@ -106,14 +101,19 @@ open class SurfaceTracingTestBase(useBlastAdapter: Boolean) : Log.e("SurfaceViewBufferTests", "Error writing bitmap to file", e) } } - Assert.assertEquals("Checking $bounds found mismatch $i,$j", - Color.valueOf(color), Color.valueOf(actualColor)) + Assert.assertEquals( + "Checking $bounds found mismatch $i,$j", + Color.valueOf(color), + Color.valueOf(actualColor) + ) } } } private companion object { - private const val TRACE_FLAGS = - (1 shl 0) or (1 shl 5) or (1 shl 6) // TRACE_CRITICAL | TRACE_BUFFERS | TRACE_SYNC + private val TRACE_FLAGS = listOf( + SurfaceFlingerLayersConfig.TraceFlag.TRACE_FLAG_BUFFERS, + SurfaceFlingerLayersConfig.TraceFlag.TRACE_FLAG_VIRTUAL_DISPLAYS, + ) } }
\ No newline at end of file diff --git a/tests/TaskOrganizerTest/Android.bp b/tests/TaskOrganizerTest/Android.bp index 9b72d359aae6..bf12f423f145 100644 --- a/tests/TaskOrganizerTest/Android.bp +++ b/tests/TaskOrganizerTest/Android.bp @@ -25,7 +25,10 @@ package { android_test { name: "TaskOrganizerTest", - srcs: ["**/*.java","**/*.kt"], + srcs: [ + "**/*.java", + "**/*.kt", + ], manifest: "AndroidManifest.xml", test_config: "AndroidTest.xml", platform_apis: true, @@ -39,6 +42,7 @@ android_test { "kotlin-stdlib", "kotlinx-coroutines-android", "flickerlib", + "flickerlib-trace_processor_shell", "truth-prebuilt", ], -}
\ No newline at end of file +} diff --git a/tests/TaskOrganizerTest/AndroidManifest.xml b/tests/TaskOrganizerTest/AndroidManifest.xml index 1f1bd3ef7d81..cbeb246eb86c 100644 --- a/tests/TaskOrganizerTest/AndroidManifest.xml +++ b/tests/TaskOrganizerTest/AndroidManifest.xml @@ -16,9 +16,11 @@ <uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/> <uses-permission android:name="android.permission.MANAGE_ACTIVITY_TASKS"/> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/> + <!-- Allow the test to connect to perfetto trace processor --> + <uses-permission android:name="android.permission.INTERNET"/> <!-- Enable / Disable tracing !--> <uses-permission android:name="android.permission.DUMP" /> - <application> + <application android:networkSecurityConfig="@xml/network_security_config"> <activity android:name="TaskOrganizerMultiWindowTest" android:label="TaskOrganizer MW Test" android:exported="true" diff --git a/tests/TaskOrganizerTest/res/xml/network_security_config.xml b/tests/TaskOrganizerTest/res/xml/network_security_config.xml new file mode 100644 index 000000000000..e450a993da28 --- /dev/null +++ b/tests/TaskOrganizerTest/res/xml/network_security_config.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +~ Copyright (C) 2023 The Android Open Source Project +~ +~ Licensed under the Apache License, Version 2.0 (the "License"); +~ you may not use this file except in compliance with the License. +~ You may obtain a copy of the License at +~ +~ http://www.apache.org/licenses/LICENSE-2.0 +~ +~ Unless required by applicable law or agreed to in writing, software +~ distributed under the License is distributed on an "AS IS" BASIS, +~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~ See the License for the specific language governing permissions and +~ limitations under the License. +--> +<network-security-config> + <domain-config cleartextTrafficPermitted="true"> + <domain includeSubdomains="true">localhost</domain> + </domain-config> +</network-security-config>
\ No newline at end of file diff --git a/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt b/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt index 6f4f7b13af66..2c7905d552f1 100644 --- a/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt +++ b/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt @@ -22,8 +22,6 @@ import androidx.test.platform.app.InstrumentationRegistry import androidx.test.runner.AndroidJUnit4 import android.tools.common.datatypes.Size import android.tools.common.flicker.subject.layers.LayersTraceSubject -import android.tools.device.traces.io.ResultWriter -import android.tools.device.traces.monitors.surfaceflinger.LayersTraceMonitor import android.tools.device.traces.monitors.withSFTracing import org.junit.After import org.junit.Before @@ -41,16 +39,13 @@ class ResizeTasksSyncTest { @get:Rule var scenarioRule: ActivityScenarioRule<TaskOrganizerMultiWindowTest> = ActivityScenarioRule<TaskOrganizerMultiWindowTest>( - TaskOrganizerMultiWindowTest::class.java) + TaskOrganizerMultiWindowTest::class.java + ) protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() @Before fun setup() { - val monitor = LayersTraceMonitor() - if (monitor.isEnabled) { - monitor.stop(ResultWriter()) - } val firstTaskBounds = Rect(0, 0, 1080, 1000) val secondTaskBounds = Rect(0, 1000, 1080, 2000) @@ -71,7 +66,7 @@ class ResizeTasksSyncTest { val firstBounds = Rect(0, 0, 1080, 800) val secondBounds = Rect(0, 1000, 1080, 1800) - val trace = withSFTracing(TRACE_FLAGS) { + val trace = withSFTracing() { lateinit var resizeReadyLatch: CountDownLatch scenarioRule.getScenario().onActivity { resizeReadyLatch = it.resizeTaskView(firstBounds, secondBounds) @@ -106,7 +101,6 @@ class ResizeTasksSyncTest { } companion object { - private const val TRACE_FLAGS = 0x1 // TRACE_CRITICAL private const val FIRST_ACTIVITY = "Activity1" private const val SECOND_ACTIVITY = "Activity2" } |