mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 13:21:28 +00:00
Bug 840825 - Add blockForEventData method to EventExpecter. r=gbrown
This commit is contained in:
parent
b59ad2d831
commit
741eb2c12b
@ -20,6 +20,9 @@ public interface Actions {
|
||||
/** Blocks until the event has been received. Subsequent calls will return immediately. */
|
||||
public void blockForEvent();
|
||||
|
||||
/** Blocks until the event has been received and returns data associated with the event. */
|
||||
public String blockForEventData();
|
||||
|
||||
/** Polls to see if the event has been received. Once this returns true, subsequent calls will also return true. */
|
||||
public boolean eventReceived();
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class FennecNativeActions implements Actions {
|
||||
}
|
||||
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
|
||||
"Waking up on "+methodName);
|
||||
mEventExpecter.notifyOfEvent();
|
||||
mEventExpecter.notifyOfEvent(args);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -105,6 +105,7 @@ public class FennecNativeActions implements Actions {
|
||||
private final String mGeckoEvent;
|
||||
private final Object[] mRegistrationParams;
|
||||
private boolean mEventReceived;
|
||||
private String mEventData;
|
||||
private static final int MAX_WAIT_MS = 90000;
|
||||
|
||||
GeckoEventExpecter(String geckoEvent, Object[] registrationParams) {
|
||||
@ -190,15 +191,21 @@ public class FennecNativeActions implements Actions {
|
||||
"unblocked on expecter for " + mGeckoEvent);
|
||||
}
|
||||
|
||||
public synchronized String blockForEventData() {
|
||||
blockForEvent();
|
||||
return mEventData;
|
||||
}
|
||||
|
||||
public synchronized boolean eventReceived() {
|
||||
return mEventReceived;
|
||||
}
|
||||
|
||||
void notifyOfEvent() {
|
||||
void notifyOfEvent(Object[] args) {
|
||||
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
|
||||
"received event " + mGeckoEvent);
|
||||
synchronized (this) {
|
||||
mEventReceived = true;
|
||||
mEventData = args[1].toString();
|
||||
this.notifyAll();
|
||||
}
|
||||
}
|
||||
@ -247,7 +254,7 @@ public class FennecNativeActions implements Actions {
|
||||
if ("drawFinished".equals(methodName)) {
|
||||
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
|
||||
"Received drawFinished notification");
|
||||
mPaintExpecter.notifyOfEvent();
|
||||
mPaintExpecter.notifyOfEvent(args);
|
||||
} else if ("toString".equals(methodName)) {
|
||||
return "DrawListenerProxy";
|
||||
} else if ("equals".equals(methodName)) {
|
||||
@ -269,7 +276,7 @@ public class FennecNativeActions implements Actions {
|
||||
mSetDrawListener.invoke(mRobocopApi, proxy);
|
||||
}
|
||||
|
||||
void notifyOfEvent() {
|
||||
void notifyOfEvent(Object[] args) {
|
||||
synchronized (this) {
|
||||
mPaintDone = true;
|
||||
this.notifyAll();
|
||||
@ -300,6 +307,11 @@ public class FennecNativeActions implements Actions {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized String blockForEventData() {
|
||||
blockForEvent();
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized boolean eventReceived() {
|
||||
return mPaintDone;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user