From 77ca70fea6caf94108ecaed593d71c9db5716cff Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 11 Apr 2019 12:25:12 -0700 Subject: [PATCH] Tapl: also logging contexts Contexts were added for better diags when an assert happens, but they are also useful for tracing the test execution. Change-Id: I1512f3f7e02a373096bab4f0b390b1febfc96334 --- .../launcher3/tapl/LauncherInstrumentation.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 3a45e93424..08f2681ea5 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -201,13 +201,19 @@ public final class LauncherInstrumentation { Closable addContextLayer(String piece) { mDiagnosticContext.addLast(piece); - return () -> mDiagnosticContext.removeLast(); + log("Added context: " + getContextDescription()); + return () -> { + log("Removing context: " + getContextDescription()); + mDiagnosticContext.removeLast(); + }; } private void fail(String message) { - final String ctxt = mDiagnosticContext.isEmpty() ? "" : String.join(", ", - mDiagnosticContext) + "; "; - Assert.fail("http://go/tapl : " + ctxt + message); + Assert.fail("http://go/tapl : " + getContextDescription() + message); + } + + private String getContextDescription() { + return mDiagnosticContext.isEmpty() ? "" : String.join(", ", mDiagnosticContext) + "; "; } void assertTrue(String message, boolean condition) {