Loading tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +2 −10 Original line number Diff line number Diff line Loading @@ -184,16 +184,8 @@ public abstract class AbstractLauncherUiTest { @After public void verifyLauncherState() { try { // Limits UI tests affecting tests running after them. mLauncher.waitForLauncherInitialized(); } 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 clearLauncherData() throws IOException, InterruptedException { Loading tests/src/com/android/launcher3/util/rule/FailureWatcher.java +29 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import androidx.test.uiautomator.UiDevice; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.io.ByteArrayOutputStream; import java.io.File; Loading @@ -15,6 +16,7 @@ import java.io.IOException; public class FailureWatcher extends TestWatcher { private static final String TAG = "FailureWatcher"; private static boolean sHadFailedTestDeinitialization; final private UiDevice mDevice; public FailureWatcher(UiDevice device) { Loading Loading @@ -60,4 +62,31 @@ public class FailureWatcher extends TestWatcher { device.takeScreenshot(new File(pathname)); } @Override public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { if (sHadFailedTestDeinitialization) { Log.d(TAG, "Skipping due to a recent test deinitialization failure: " + description.getDisplayName()); return; } try { base.evaluate(); } catch (Throwable e) { if (!Log.getStackTraceString(e).contains( "androidx.test.internal.runner.junit4.statement.RunBefores.evaluate")) { // Test failed to deinitialize. Since the global state is probably // corrupted, won't execute other tests. sHadFailedTestDeinitialization = true; } throw e; } } }; } } Loading
tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +2 −10 Original line number Diff line number Diff line Loading @@ -184,16 +184,8 @@ public abstract class AbstractLauncherUiTest { @After public void verifyLauncherState() { try { // Limits UI tests affecting tests running after them. mLauncher.waitForLauncherInitialized(); } 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 clearLauncherData() throws IOException, InterruptedException { Loading
tests/src/com/android/launcher3/util/rule/FailureWatcher.java +29 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import androidx.test.uiautomator.UiDevice; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.io.ByteArrayOutputStream; import java.io.File; Loading @@ -15,6 +16,7 @@ import java.io.IOException; public class FailureWatcher extends TestWatcher { private static final String TAG = "FailureWatcher"; private static boolean sHadFailedTestDeinitialization; final private UiDevice mDevice; public FailureWatcher(UiDevice device) { Loading Loading @@ -60,4 +62,31 @@ public class FailureWatcher extends TestWatcher { device.takeScreenshot(new File(pathname)); } @Override public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { if (sHadFailedTestDeinitialization) { Log.d(TAG, "Skipping due to a recent test deinitialization failure: " + description.getDisplayName()); return; } try { base.evaluate(); } catch (Throwable e) { if (!Log.getStackTraceString(e).contains( "androidx.test.internal.runner.junit4.statement.RunBefores.evaluate")) { // Test failed to deinitialize. Since the global state is probably // corrupted, won't execute other tests. sHadFailedTestDeinitialization = true; } throw e; } } }; } }