Detect leaks only on test success
Bug: 191690396 Test: presubmit Change-Id: Ie59c3b944d420ac25ebba86bf500fcf33700ca99
This commit is contained in:
parent
26cd946f29
commit
143748fbf4
|
@ -107,7 +107,7 @@ public class FallbackRecentsTest {
|
|||
|
||||
mOrderSensitiveRules = RuleChain
|
||||
.outerRule(new NavigationModeSwitchRule(mLauncher))
|
||||
.around(new FailureWatcher(mDevice));
|
||||
.around(new FailureWatcher(mDevice, mLauncher));
|
||||
|
||||
mOtherLauncherActivity = context.getPackageManager().queryIntentActivities(
|
||||
getHomeIntentInPackage(context),
|
||||
|
|
|
@ -229,7 +229,7 @@ public abstract class AbstractLauncherUiTest {
|
|||
|
||||
protected TestRule getRulesInsideActivityMonitor() {
|
||||
final RuleChain inner = RuleChain.outerRule(new PortraitLandscapeRunner(this))
|
||||
.around(new FailureWatcher(mDevice));
|
||||
.around(new FailureWatcher(mDevice, mLauncher));
|
||||
|
||||
return TestHelpers.isInLauncherProcess()
|
||||
? RuleChain.outerRule(ShellCommandRule.setDefaultLauncher())
|
||||
|
@ -310,7 +310,6 @@ public abstract class AbstractLauncherUiTest {
|
|||
assertEquals("Launcher crashed, pid mismatch:",
|
||||
mLauncherPid, mLauncher.getPid().intValue());
|
||||
}
|
||||
checkDetectedLeaks(mLauncher);
|
||||
} finally {
|
||||
mLauncher.onTestFinish();
|
||||
}
|
||||
|
@ -618,5 +617,6 @@ public abstract class AbstractLauncherUiTest {
|
|||
isResumed);
|
||||
}
|
||||
|
||||
protected void onLauncherActivityClose(Launcher launcher) { }
|
||||
protected void onLauncherActivityClose(Launcher launcher) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import android.util.Log;
|
|||
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
|
||||
import com.android.launcher3.tapl.LauncherInstrumentation;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
|
||||
|
@ -16,9 +19,11 @@ import java.io.IOException;
|
|||
public class FailureWatcher extends TestWatcher {
|
||||
private static final String TAG = "FailureWatcher";
|
||||
final private UiDevice mDevice;
|
||||
private final LauncherInstrumentation mLauncher;
|
||||
|
||||
public FailureWatcher(UiDevice device) {
|
||||
public FailureWatcher(UiDevice device, LauncherInstrumentation launcher) {
|
||||
mDevice = device;
|
||||
mLauncher = launcher;
|
||||
}
|
||||
|
||||
private static void dumpViewHierarchy(UiDevice device) {
|
||||
|
@ -35,6 +40,12 @@ public class FailureWatcher extends TestWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void succeeded(Description description) {
|
||||
super.succeeded(description);
|
||||
AbstractLauncherUiTest.checkDetectedLeaks(mLauncher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void failed(Throwable e, Description description) {
|
||||
onError(mDevice, description, e);
|
||||
|
|
Loading…
Reference in New Issue