Including go/tapl in error messages
Bug: 110103162
Test: making a test fail, checking a link
Change-Id: If64948a6656214c5065150803b2a1a7020fb82c5
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index d5b2c87..84fd908 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -16,8 +16,6 @@
package com.android.launcher3.tapl;
-import static org.junit.Assert.assertTrue;
-
import androidx.annotation.NonNull;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.Direction;
@@ -62,7 +60,8 @@
int attempts = 0;
while (!allAppsContainer.hasObject(appIconSelector) &&
allAppsContainer.scroll(Direction.DOWN, 0.8f)) {
- assertTrue("Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
+ LauncherInstrumentation.assertTrue(
+ "Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
++attempts <= MAX_SCROLL_ATTEMPTS);
verifyActiveContainer();
}
@@ -85,9 +84,10 @@
for (int scroll = getScroll(allAppsContainer);
scroll != 0;
scroll = getScroll(allAppsContainer)) {
- assertTrue("Negative scroll position", scroll > 0);
+ LauncherInstrumentation.assertTrue("Negative scroll position", scroll > 0);
- assertTrue("Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
+ LauncherInstrumentation.assertTrue(
+ "Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
++attempts <= MAX_SCROLL_ATTEMPTS);
allAppsContainer.scroll(Direction.UP, 1);
diff --git a/tests/tapl/com/android/launcher3/tapl/AppIcon.java b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
index a0f32a4..17bf5fc 100644
--- a/tests/tapl/com/android/launcher3/tapl/AppIcon.java
+++ b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
@@ -16,13 +16,12 @@
package com.android.launcher3.tapl;
-import static org.junit.Assert.assertTrue;
+import android.widget.TextView;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
-import android.widget.TextView;
/**
* App icon, whether in all apps or in workspace/
@@ -44,7 +43,8 @@
* Clicks the icon to launch its app.
*/
public Background launch() {
- assertTrue("Launching an app didn't open a new window: " + mIcon.getText(),
+ LauncherInstrumentation.assertTrue(
+ "Launching an app didn't open a new window: " + mIcon.getText(),
mIcon.clickAndWait(Until.newWindow(), LauncherInstrumentation.WAIT_TIME_MS));
return new Background(mLauncher);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 99dd914..434e421 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -18,10 +18,6 @@
import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.UiAutomation;
@@ -40,6 +36,8 @@
import com.android.launcher3.TestProtocol;
import com.android.quickstep.SwipeUpSetting;
+import org.junit.Assert;
+
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeoutException;
@@ -121,6 +119,30 @@
return mSwipeUpEnabledOverride != null ? mSwipeUpEnabledOverride : mSwipeUpEnabled;
}
+ private static void fail(String message) {
+ Assert.fail("http://go/tapl : " + message);
+ }
+
+ static void assertTrue(String message, boolean condition) {
+ if (!condition) {
+ fail(message);
+ }
+ }
+
+ static void assertNotNull(String message, Object object) {
+ assertTrue(message, object != null);
+ }
+
+ static private void failEquals(String message, Object actual) {
+ fail(message + ". " + "Actual: " + actual);
+ }
+
+ static void assertNotEquals(String message, int unexpected, int actual) {
+ if (unexpected == actual) {
+ failEquals(message, actual);
+ }
+ }
+
private UiObject2 verifyContainerType(ContainerType containerType) {
switch (containerType) {
case WORKSPACE: {
diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java
index be1d219..db0e6c5 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -16,8 +16,6 @@
package com.android.launcher3.tapl;
-import static org.junit.Assert.assertNotEquals;
-
import android.graphics.Point;
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
@@ -73,7 +71,7 @@
verifyActiveContainer();
final List<UiObject2> taskViews = mLauncher.getDevice().findObjects(
LauncherInstrumentation.getLauncherObjectSelector("snapshot"));
- assertNotEquals("Unable to find a task", 0, taskViews.size());
+ LauncherInstrumentation.assertNotEquals("Unable to find a task", 0, taskViews.size());
// taskViews contains up to 3 task views: the 'main' (having the widest visible
// part) one in the center, and parts of its right and left siblings. Find the
diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
index ecad768..2b67cc0 100644
--- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
+++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
@@ -16,8 +16,6 @@
package com.android.launcher3.tapl;
-import static org.junit.Assert.assertTrue;
-
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
@@ -56,7 +54,7 @@
*/
public Background open() {
verifyActiveContainer();
- assertTrue("Launching task didn't open a new window: " +
+ LauncherInstrumentation.assertTrue("Launching task didn't open a new window: " +
mTask.getParent().getContentDescription(),
mTask.clickAndWait(Until.newWindow(), LauncherInstrumentation.WAIT_TIME_MS));
return new Background(mLauncher);