Revert^2 Adapt flicker tests to perfetto-based SurfaceFlinger tracing
- Change permissions to allow connection to perfetto trace processor
- Add flickerlib-trace_processor_shell dependency to pull trace_processor_shell
prebuilts into the apk
- Adapt test code to new perfetto trace monitor
- Remove obsolete TRACE_CRITICAL layer tracing flag in test code
Bug: b/284424740
Test: atest FlickerTestsAppClose && \
atest FlickerTestsIme && \
atest FlickerTestsQuickswitch && \
atest FlickerTestsAppLaunch && \
atest FlickerTestsOther && \
atest FlickerTestsRotation && \
atest TaskOrganizerTest
Change-Id: I9d3e645ad387ebe74ea4884d647dccab07415831
diff --git a/tests/SurfaceViewBufferTests/Android.bp b/tests/SurfaceViewBufferTests/Android.bp
index dc75f00..38313f8 100644
--- a/tests/SurfaceViewBufferTests/Android.bp
+++ b/tests/SurfaceViewBufferTests/Android.bp
@@ -23,7 +23,10 @@
android_test {
name: "SurfaceViewBufferTests",
- srcs: ["**/*.java","**/*.kt"],
+ srcs: [
+ "**/*.java",
+ "**/*.kt",
+ ],
manifest: "AndroidManifest.xml",
test_config: "AndroidTest.xml",
platform_apis: true,
@@ -41,6 +44,7 @@
"kotlin-stdlib",
"kotlinx-coroutines-android",
"flickerlib",
+ "flickerlib-trace_processor_shell",
"truth-prebuilt",
"cts-wm-util",
"CtsSurfaceValidatorLib",
@@ -60,7 +64,7 @@
"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 78415e8..798c67a 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 0000000..4bd9ca0
--- /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 a38019d..b03b733 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.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 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 @@
@Before
override fun setup() {
super.setup()
- stopLayerTrace()
+ PerfettoTraceMonitor.stopAllSessions()
addSurfaceView()
}
@@ -83,10 +82,6 @@
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 @@
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