Not using dropbox entries before the test start for diagnostics
Change-Id: Ia060b5d2b98ea9ea3b6e61ae11d610f1a888d7a0
This commit is contained in:
@@ -100,7 +100,8 @@ public class TestCommandProvider 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,8 +111,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) {
|
||||
|
||||
@@ -106,11 +106,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))) {
|
||||
@@ -128,7 +128,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();
|
||||
|
||||
@@ -144,7 +144,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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user