Merge "Adding Winscope Launcher trace artifact" into sc-v2-dev am: e7e282b80b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15780473 Change-Id: I68709c13fa08990793d230e37191c66f5f02982b
This commit is contained in:
commit
cc2ddb817c
1 file changed
+20
@@ -2,6 +2,7 @@ package com.android.launcher3.util.rule;
|
|||||||
|
|
||||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.os.FileUtils;
|
import android.os.FileUtils;
|
||||||
import android.os.ParcelFileDescriptor.AutoCloseInputStream;
|
import android.os.ParcelFileDescriptor.AutoCloseInputStream;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -45,11 +46,30 @@ public class FailureWatcher extends TestWatcher {
|
|||||||
return new Statement() {
|
return new Statement() {
|
||||||
@Override
|
@Override
|
||||||
public void evaluate() throws Throwable {
|
public void evaluate() throws Throwable {
|
||||||
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
Log.d("b/196820244", "Before evaluate");
|
Log.d("b/196820244", "Before evaluate");
|
||||||
|
mDevice.executeShellCommand("cmd statusbar tracing start");
|
||||||
FailureWatcher.super.apply(base, description).evaluate();
|
FailureWatcher.super.apply(base, description).evaluate();
|
||||||
Log.d("b/196820244", "After evaluate");
|
Log.d("b/196820244", "After evaluate");
|
||||||
|
success = true;
|
||||||
} finally {
|
} finally {
|
||||||
|
// Save artifact for Launcher Winscope trace.
|
||||||
|
mDevice.executeShellCommand("cmd statusbar tracing stop");
|
||||||
|
final Context nexusLauncherContext =
|
||||||
|
getInstrumentation().getTargetContext()
|
||||||
|
.createPackageContext("com.google.android.apps.nexuslauncher",
|
||||||
|
0);
|
||||||
|
final File launcherTrace =
|
||||||
|
new File(nexusLauncherContext.getFilesDir(), "launcher_trace.pb");
|
||||||
|
if (success) {
|
||||||
|
mDevice.executeShellCommand("rm " + launcherTrace);
|
||||||
|
} else {
|
||||||
|
mDevice.executeShellCommand("mv " + launcherTrace + " "
|
||||||
|
+ diagFile(description, "LauncherWinscope", "pb"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect touch events coming from physical screen.
|
||||||
if (mLauncher.hadNontestEvents()) {
|
if (mLauncher.hadNontestEvents()) {
|
||||||
throw new AssertionError(
|
throw new AssertionError(
|
||||||
"Launcher received events not sent by the test. This may mean "
|
"Launcher received events not sent by the test. This may mean "
|
||||||
|
|||||||
Reference in new issue
Block a user