Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d7ff519 authored by Vadim Tryshev's avatar Vadim Tryshev Committed by Android (Google) Code Review
Browse files

Merge "Detect leaks only on test success Bug: 191690396 Test: presubmit" into sc-dev

parents e43edc74 143748fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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),
+3 −3
Original line number Diff line number Diff line
@@ -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) {
    }
}
+12 −1
Original line number Diff line number Diff line
@@ -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);