mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Not assuming that all accessibility events contain bundle
Bundles come from Launcher being explicitly asked a question. When waiting for ANY event, it may contain any parcelable, so it's incorrect to cast it to Bundle. See this: https://sponge.corp.google.com/target?show=FAILED&sortBy=STATUS&id=9b8d0d26-f81d-427f-8857-b8d71e012504&target=android.test.appsmoke Bug: 110103162 Test: will watch for reducing flakes in platform tests. Change-Id: I989cee018183140d7fd672c0a925f03441ca339c
This commit is contained in:
@@ -26,6 +26,7 @@ import android.app.ActivityManager;
|
||||
import android.app.Instrumentation;
|
||||
import android.app.UiAutomation;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
@@ -160,14 +161,14 @@ public final class LauncherInstrumentation {
|
||||
}
|
||||
}
|
||||
|
||||
private Bundle executeAndWaitForEvent(Runnable command,
|
||||
private Parcelable executeAndWaitForEvent(Runnable command,
|
||||
UiAutomation.AccessibilityEventFilter eventFilter, String message) {
|
||||
try {
|
||||
final AccessibilityEvent event =
|
||||
mInstrumentation.getUiAutomation().executeAndWaitForEvent(
|
||||
command, eventFilter, WAIT_TIME_MS);
|
||||
assertNotNull("executeAndWaitForEvent returned null (this can't happen)", event);
|
||||
return (Bundle) event.getParcelableData();
|
||||
return event.getParcelableData();
|
||||
} catch (TimeoutException e) {
|
||||
fail(message);
|
||||
return null;
|
||||
@@ -177,7 +178,7 @@ public final class LauncherInstrumentation {
|
||||
Bundle getAnswerFromLauncher(UiObject2 view, String requestTag) {
|
||||
// Send a fake set-text request to Launcher to initiate a response with requested data.
|
||||
final String responseTag = requestTag + TestProtocol.RESPONSE_MESSAGE_POSTFIX;
|
||||
return executeAndWaitForEvent(
|
||||
return (Bundle) executeAndWaitForEvent(
|
||||
() -> view.setText(requestTag),
|
||||
event -> responseTag.equals(event.getClassName()),
|
||||
"Launcher didn't respond to request: " + requestTag);
|
||||
|
||||
Reference in New Issue
Block a user