Closed
Bug 1199444
Opened 9 years ago
Closed 9 years ago
Add test for UI/background events
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(firefox43 fixed)
RESOLVED
FIXED
Firefox 43
Tracking | Status | |
---|---|---|
firefox43 | --- | fixed |
People
(Reporter: jchen, Assigned: jchen)
References
Details
Attachments
(1 file)
10.95 KB,
patch
|
mcomella
:
review+
|
Details | Diff | Splinter Review |
Test for bug 991167.
Assignee | ||
Comment 1•9 years ago
|
||
Bug 991167 added BundleEventListener that allow dispatching an event directly to the UI thread or to the background thread. This patch adds tests to testEventDispatcher, to test that the events are dispatched on the correct threads and that the Bundle messages are correct. Because these events are asynchronous, the test waits for each event to be processed before continuing.
Attachment #8653727 -
Flags: review?(michael.l.comella)
Comment on attachment 8653727 [details] [diff] [review] Add test for BundleEventListener (v1) Review of attachment 8653727 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/tests/browser/robocop/testEventDispatcher.java @@ +39,5 @@ > + private static final String UI_RESPONSE_EVENT = "Robocop:TestUIResponse"; > + private static final String BACKGROUND_EVENT = "Robocop:TestBackgroundEvent"; > + private static final String BACKGROUND_RESPONSE_EVENT = "Robocop:TestBackgrondResponse"; > + > + private static final long WAIT_FOR_EVENT_TIMEOUT = 10000; // 10 seconds nit: -> WAIT_FOR_BUNDLE_EVENT_TIMEOUT_MILLIS This is only used for bundle listeners. @@ +85,5 @@ > + final long startTime = System.nanoTime(); > + while (!handledAsyncEvent) { > + try { > + wait(WAIT_FOR_EVENT_TIMEOUT); > + if (System.nanoTime() - startTime + 1e8 // allow 100ms of leeway. Why is 100ms of leeway necessary? Why not incorporate this into the WAIT_FOR_EVENT_TIMEOUT value? @@ +106,5 @@ > GeckoHelper.blockForReady(); > NavigationHelper.enterAndLoadUrl(mStringHelper.getHarnessUrlForJavascript(TEST_JS)); > > js.syncCall("send_test_message", GECKO_EVENT); > + fAssertTrue("Should have handled Gecko event synchronously", handledGeckoEvent); For future reference, it'd be good to put these cleanups (as opposed to the BundleEventListener changes) in a separate patch to make it easier to follow the motivation for these changes.
Attachment #8653727 -
Flags: review?(michael.l.comella) → review+
Assignee | ||
Comment 3•9 years ago
|
||
(In reply to Michael Comella (:mcomella) from comment #2) > Comment on attachment 8653727 [details] [diff] [review] > Add test for BundleEventListener (v1) > > Review of attachment 8653727 [details] [diff] [review]: > ----------------------------------------------------------------- > > @@ +85,5 @@ > > + final long startTime = System.nanoTime(); > > + while (!handledAsyncEvent) { > > + try { > > + wait(WAIT_FOR_EVENT_TIMEOUT); > > + if (System.nanoTime() - startTime + 1e8 // allow 100ms of leeway. > > Why is 100ms of leeway necessary? Why not incorporate this into the > WAIT_FOR_EVENT_TIMEOUT value? It's to guard against situations where, e.g., we wait for 10s, but our measured time difference was 9.99s due to clock discrepancies, differences in wait() implementation, etc. The docs don't really say whether this could happen though. I think I'll just change it to something like wait for 1s at a time, and just wait for multiple times to get to the timeout.
While I can see how this could happen, I've never heard of this before – perhaps it's not an issue in Java?
https://hg.mozilla.org/mozilla-central/rev/b2956e60f825
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 43
Updated•3 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•