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