зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1748981 - Use delegateDuringNextWait when returning GeckoResult. r=calu
When looking test failure, I found that `onOrientationLock` always returned null in geckoview-junit since default method is called. We should use use `delegateDuringNextWait` instead of `waitUntilCalled`. Differential Revision: https://phabricator.services.mozilla.com/D135574
This commit is contained in:
Родитель
bf31f73133
Коммит
df7f7503f4
|
@ -47,7 +47,7 @@ class OrientationDelegateTest : BaseSessionTest() {
|
||||||
|
|
||||||
private fun lockPortrait() {
|
private fun lockPortrait() {
|
||||||
val promise = mainSession.evaluatePromiseJS("screen.orientation.lock('portrait-primary')")
|
val promise = mainSession.evaluatePromiseJS("screen.orientation.lock('portrait-primary')")
|
||||||
sessionRule.waitUntilCalled(object : OrientationController.OrientationDelegate {
|
sessionRule.delegateDuringNextWait(object : OrientationController.OrientationDelegate {
|
||||||
@AssertCalled(count = 1)
|
@AssertCalled(count = 1)
|
||||||
override fun onOrientationLock(aOrientation: Int): GeckoResult<AllowOrDeny> {
|
override fun onOrientationLock(aOrientation: Int): GeckoResult<AllowOrDeny> {
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -63,11 +63,13 @@ class OrientationDelegateTest : BaseSessionTest() {
|
||||||
})
|
})
|
||||||
sessionRule.runtime.orientationChanged(Configuration.ORIENTATION_PORTRAIT)
|
sessionRule.runtime.orientationChanged(Configuration.ORIENTATION_PORTRAIT)
|
||||||
promise.value
|
promise.value
|
||||||
|
// Remove previous delegate
|
||||||
|
mainSession.waitForRoundTrip()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun lockLandscape() {
|
private fun lockLandscape() {
|
||||||
val promise = mainSession.evaluatePromiseJS("screen.orientation.lock('landscape-primary')")
|
val promise = mainSession.evaluatePromiseJS("screen.orientation.lock('landscape-primary')")
|
||||||
sessionRule.waitUntilCalled(object : OrientationController.OrientationDelegate {
|
sessionRule.delegateDuringNextWait(object : OrientationController.OrientationDelegate {
|
||||||
@AssertCalled(count = 1)
|
@AssertCalled(count = 1)
|
||||||
override fun onOrientationLock(aOrientation: Int): GeckoResult<AllowOrDeny> {
|
override fun onOrientationLock(aOrientation: Int): GeckoResult<AllowOrDeny> {
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -83,6 +85,8 @@ class OrientationDelegateTest : BaseSessionTest() {
|
||||||
})
|
})
|
||||||
sessionRule.runtime.orientationChanged(Configuration.ORIENTATION_LANDSCAPE)
|
sessionRule.runtime.orientationChanged(Configuration.ORIENTATION_LANDSCAPE)
|
||||||
promise.value
|
promise.value
|
||||||
|
// Remove previous delegate
|
||||||
|
mainSession.waitForRoundTrip()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun orientationLock() {
|
@Test fun orientationLock() {
|
||||||
|
@ -144,7 +148,7 @@ class OrientationDelegateTest : BaseSessionTest() {
|
||||||
goFullscreen()
|
goFullscreen()
|
||||||
|
|
||||||
val promise = mainSession.evaluatePromiseJS("screen.orientation.lock('landscape-primary')")
|
val promise = mainSession.evaluatePromiseJS("screen.orientation.lock('landscape-primary')")
|
||||||
sessionRule.waitUntilCalled(object : OrientationController.OrientationDelegate {
|
sessionRule.delegateDuringNextWait(object : OrientationController.OrientationDelegate {
|
||||||
@AssertCalled(count = 1)
|
@AssertCalled(count = 1)
|
||||||
override fun onOrientationLock(aOrientation: Int): GeckoResult<AllowOrDeny> {
|
override fun onOrientationLock(aOrientation: Int): GeckoResult<AllowOrDeny> {
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -160,6 +164,8 @@ class OrientationDelegateTest : BaseSessionTest() {
|
||||||
})
|
})
|
||||||
sessionRule.runtime.orientationChanged(Configuration.ORIENTATION_LANDSCAPE)
|
sessionRule.runtime.orientationChanged(Configuration.ORIENTATION_LANDSCAPE)
|
||||||
promise.value
|
promise.value
|
||||||
|
// Remove previous delegate
|
||||||
|
mainSession.waitForRoundTrip()
|
||||||
|
|
||||||
// after locking to orientation landscape, unlock to default
|
// after locking to orientation landscape, unlock to default
|
||||||
mainSession.evaluateJS("screen.orientation.unlock()")
|
mainSession.evaluateJS("screen.orientation.unlock()")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче