Merge "Not using dropbox entries before the test start for diagnostics" into ub-launcher3-qt-qpr1-dev
This commit is contained in:
commit
dcb5412e1c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue