summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2019-04-04 00:33:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-04-04 00:33:38 +0000
commit7e4efe3f66bfc801af124053afc91af02a3533ec (patch)
tree33ecf41d584ee29e3e472dff1eb067ff79515aa4 /tests
parent9e84e0c1c1e375e11ea6fa81b448dfe1cddd8b20 (diff)
parent19f996d7d7825e5919690d3b8fef74470d25d9de (diff)
downloadandroid_packages_apps_Trebuchet-7e4efe3f66bfc801af124053afc91af02a3533ec.tar.gz
android_packages_apps_Trebuchet-7e4efe3f66bfc801af124053afc91af02a3533ec.tar.bz2
android_packages_apps_Trebuchet-7e4efe3f66bfc801af124053afc91af02a3533ec.zip
Merge "Exiting tests after a test fails to deinitialize" into ub-launcher3-master
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java27
-rw-r--r--tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java2
2 files changed, 22 insertions, 7 deletions
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index dd768fd88..8a2e81616 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -20,6 +20,8 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static java.lang.System.exit;
+
import android.app.Instrumentation;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -29,6 +31,7 @@ import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageManager;
import android.os.Process;
import android.os.RemoteException;
+import android.util.Log;
import android.view.Surface;
import androidx.test.InstrumentationRegistry;
@@ -78,9 +81,10 @@ public abstract class AbstractLauncherUiTest {
public static final long DEFAULT_ACTIVITY_TIMEOUT = TimeUnit.SECONDS.toMillis(10);
public static final long DEFAULT_BROADCAST_TIMEOUT_SECS = 5;
- public static final long SHORT_UI_TIMEOUT= 300;
+ public static final long SHORT_UI_TIMEOUT = 300;
public static final long DEFAULT_UI_TIMEOUT = 10000;
protected static final int LONG_WAIT_TIME_MS = 60000;
+ private static final String TAG = "AbstractLauncherUiTest";
protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
protected final UiDevice mDevice;
@@ -107,10 +111,12 @@ public abstract class AbstractLauncherUiTest {
@Rule
public LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
- @Rule public ShellCommandRule mDefaultLauncherRule =
+ @Rule
+ public ShellCommandRule mDefaultLauncherRule =
TestHelpers.isInLauncherProcess() ? ShellCommandRule.setDefaultLauncher() : null;
- @Rule public ShellCommandRule mDisableHeadsUpNotification =
+ @Rule
+ public ShellCommandRule mDisableHeadsUpNotification =
ShellCommandRule.disableHeadsUpNotification();
// Annotation for tests that need to be run in portrait and landscape modes.
@@ -164,9 +170,17 @@ public abstract class AbstractLauncherUiTest {
}
@After
- public void tearDown() throws Exception {
- // Limits UI tests affecting tests running after them.
- waitForModelLoaded();
+ public void tearDown() {
+ try {
+ // Limits UI tests affecting tests running after them.
+ waitForModelLoaded();
+ } catch (Throwable t) {
+ Log.e(TAG,
+ "Couldn't deinit after a test, exiting tests, see logs for failures that "
+ + "could have caused this",
+ t);
+ exit(1);
+ }
}
protected void lockRotation(boolean naturalOrientation) throws RemoteException {
@@ -189,6 +203,7 @@ public abstract class AbstractLauncherUiTest {
/**
* Scrolls the {@param container} until it finds an object matching {@param condition}.
+ *
* @return the matching object.
*/
protected UiObject2 scrollAndFind(UiObject2 container, BySelector condition) {
diff --git a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java
index 68b16d6db..c8e7786b1 100644
--- a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java
@@ -95,7 +95,7 @@ public class BindWidgetTest extends AbstractLauncherUiTest {
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
if (mCursor != null) {
mCursor.close();
}