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

Commit 3bdba615 authored by vadimt's avatar vadimt Committed by Vadim Tryshev
Browse files

Not using dropbox entries before the test start for diagnostics

Change-Id: Ieb48d969d86a855c91109f4ace0d636fa01aafc7
Merged-in: Ia060b5d2b98ea9ea3b6e61ae11d610f1a888d7a0
parent 32c8664f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -104,7 +104,8 @@ public class TestCommandReceiver extends ContentProvider {

            case GET_SYSTEM_HEALTH_MESSAGE: {
                final Bundle response = new Bundle();
                response.putString("result", TestHelpers.getSystemHealthMessage(getContext()));
                response.putString("result",
                        TestHelpers.getSystemHealthMessage(getContext(), Long.parseLong(arg)));
                return response;
            }
        }
+3 −2
Original line number Diff line number Diff line
@@ -105,8 +105,9 @@ public abstract class AbstractLauncherUiTest {
        }
        if (TestHelpers.isInLauncherProcess()) {
            Utilities.enableRunningInTestHarnessForTests();
            mLauncher.setSystemHealthSupplier(() -> TestCommandReceiver.callCommand(
                    TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE).getString("result"));
            mLauncher.setSystemHealthSupplier(startTime -> TestCommandReceiver.callCommand(
                    TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE, startTime.toString()).
                    getString("result"));
            mLauncher.setOnSettledStateAction(
                    containerType -> executeOnLauncher(
                            launcher ->
+6 −5
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.function.Function;

/**
 * The main tapl object. The only object that can be explicitly constructed by the using code. It
@@ -84,6 +84,7 @@ public final class LauncherInstrumentation {
    private static final String TAG = "Tapl";
    private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20;
    private static final int GESTURE_STEP_MS = 16;
    private static long START_TIME = System.currentTimeMillis();

    // Types for launcher containers that the user is interacting with. "Background" is a
    // pseudo-container corresponding to inactive launcher covered by another app.
@@ -134,7 +135,7 @@ public final class LauncherInstrumentation {
    private int mExpectedRotation = Surface.ROTATION_0;
    private final Uri mTestProviderUri;
    private final Deque<String> mDiagnosticContext = new LinkedList<>();
    private Supplier<String> mSystemHealthSupplier;
    private Function<Long, String> mSystemHealthSupplier;

    private Consumer<ContainerType> mOnSettledStateAction;

@@ -296,7 +297,7 @@ public final class LauncherInstrumentation {
        return "Background";
    }

    public void setSystemHealthSupplier(Supplier<String> supplier) {
    public void setSystemHealthSupplier(Function<Long, String> supplier) {
        this.mSystemHealthSupplier = supplier;
    }

@@ -316,8 +317,8 @@ public final class LauncherInstrumentation {
        }

        return mSystemHealthSupplier != null
                ? mSystemHealthSupplier.get()
                : TestHelpers.getSystemHealthMessage(getContext());
                ? mSystemHealthSupplier.apply(START_TIME)
                : TestHelpers.getSystemHealthMessage(getContext(), START_TIME);
    }

    private void fail(String message) {
+4 −4
Original line number Diff line number Diff line
@@ -101,11 +101,11 @@ public class TestHelpers {
        return ret.toString();
    }

    private static String checkCrash(Context context, String label) {
    private static String checkCrash(Context context, String label, long startTime) {
        DropBoxManager dropbox = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE);
        Assert.assertNotNull("Unable access the DropBoxManager service", dropbox);

        long timestamp = System.currentTimeMillis() - 5 * 60000;
        long timestamp = startTime;
        DropBoxManager.Entry entry;
        StringBuilder errorDetails = new StringBuilder();
        while (null != (entry = dropbox.getNextEntry(label, timestamp))) {
@@ -123,7 +123,7 @@ public class TestHelpers {
        return errorDetails.length() != 0 ? errorDetails.toString() : null;
    }

    public static String getSystemHealthMessage(Context context) {
    public static String getSystemHealthMessage(Context context, long startTime) {
        try {
            StringBuilder errors = new StringBuilder();

@@ -139,7 +139,7 @@ public class TestHelpers {
            };

            for (String label : labels) {
                final String crash = checkCrash(context, label);
                final String crash = checkCrash(context, label, startTime);
                if (crash != null) errors.append(crash);
            }