mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1777405 - GeckoView Intermittent in GeolocationTest onPause r=geckoview-reviewers,calu
In some test runs, the `onPause` Android Lifecycle event is not occuring in the GeckoView test `GeolocationTest`. Increasing the time between calling an `onPause` event (going Home) and the `onResume` event (returning to app) will give the device more time to complete the `onPause` event and return the expected results. Differential Revision: https://phabricator.services.mozilla.com/D151031
This commit is contained in:
parent
5c4c6b84a0
commit
fab615eabb
@ -95,6 +95,17 @@ import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
error => reject(error.code))""").value as JSONObject
|
||||
}
|
||||
|
||||
private fun getCurrentPositionJSWithWait(): JSONObject {
|
||||
return mainSession.evaluatePromiseJS("""
|
||||
new Promise((resolve, reject) =>
|
||||
setTimeout(() => {
|
||||
window.navigator.geolocation.getCurrentPosition(
|
||||
position => resolve(
|
||||
{latitude: position.coords.latitude, longitude: position.coords.longitude})),
|
||||
error => reject(error.code)
|
||||
}, "750"))""").value as JSONObject
|
||||
}
|
||||
|
||||
@GeckoSessionTestRule.NullDelegate(Autofill.Delegate::class)
|
||||
// General test that location can be requested from JS and that the mock provider is providing location
|
||||
@Test fun jsContentRequestForLocation() {
|
||||
@ -170,13 +181,13 @@ import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
// Ensures a return to the foreground
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
setActivityToForeground()
|
||||
}, 1000)
|
||||
}, 1500)
|
||||
|
||||
// Will cause onPause event to occur
|
||||
pressHome()
|
||||
|
||||
// After/During onPause Event
|
||||
val whilePausingPosition = getCurrentPositionJS()
|
||||
val whilePausingPosition = getCurrentPositionJSWithWait()
|
||||
assertThat("Longitude after/during onPause matches.", whilePausingPosition["latitude"] as Number, equalTo(afterPauseLat))
|
||||
assertThat("Longitude after/during onPause matches.", whilePausingPosition["longitude"] as Number, equalTo(afterPauseLon))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user