Commit 20c1c846 authored by MozLando's avatar MozLando
Browse files

Merge #6544



6544: Close #5795: Support viewport-fit descriptor via onMetaViewportFitChange. r=jonalmeida a=rocketsroger
Co-authored-by: default avatarRoger Yang <royang@mozilla.com>
parents 892e1de5 4eb90523
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
package mozilla.components.browser.engine.gecko package mozilla.components.browser.engine.gecko
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Build
import android.view.WindowManager
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
...@@ -681,6 +683,18 @@ class GeckoEngineSession( ...@@ -681,6 +683,18 @@ class GeckoEngineSession(
notifyObservers { onWebAppManifestLoaded(parsed.manifest) } notifyObservers { onWebAppManifestLoaded(parsed.manifest) }
} }
} }
override fun onMetaViewportFitChange(session: GeckoSession, viewportFit: String) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val layoutInDisplayCutoutMode = when (viewportFit) {
"cover" -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
"contain" -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
else -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
}
notifyObservers { onMetaViewportFitChanged(layoutInDisplayCutoutMode) }
}
}
} }
private fun createContentBlockingDelegate() = object : ContentBlocking.Delegate { private fun createContentBlockingDelegate() = object : ContentBlocking.Delegate {
......
...@@ -7,6 +7,7 @@ package mozilla.components.browser.engine.gecko ...@@ -7,6 +7,7 @@ package mozilla.components.browser.engine.gecko
import android.content.Intent import android.content.Intent
import android.os.Handler import android.os.Handler
import android.os.Message import android.os.Message
import android.view.WindowManager
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest import kotlinx.coroutines.test.runBlockingTest
...@@ -52,6 +53,7 @@ import org.mockito.ArgumentMatchers.anyInt ...@@ -52,6 +53,7 @@ import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyList import org.mockito.ArgumentMatchers.anyList
import org.mockito.ArgumentMatchers.anyString import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mockito.never import org.mockito.Mockito.never
import org.mockito.Mockito.reset
import org.mockito.Mockito.times import org.mockito.Mockito.times
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyZeroInteractions import org.mockito.Mockito.verifyZeroInteractions
...@@ -1748,6 +1750,33 @@ class GeckoEngineSessionTest { ...@@ -1748,6 +1750,33 @@ class GeckoEngineSessionTest {
verify(geckoSession).exitFullScreen() verify(geckoSession).exitFullScreen()
} }
@Test
fun viewportFitChangeTranslateValuesCorrectly() {
val engineSession = GeckoEngineSession(mock(),
geckoSessionProvider = geckoSessionProvider)
val observer: EngineSession.Observer = mock()
// Verify the call to the observer.
engineSession.register(observer)
captureDelegates()
contentDelegate.value.onMetaViewportFitChange(geckoSession, "test")
verify(observer).onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT)
reset(observer)
contentDelegate.value.onMetaViewportFitChange(geckoSession, "auto")
verify(observer).onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT)
reset(observer)
contentDelegate.value.onMetaViewportFitChange(geckoSession, "cover")
verify(observer).onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)
reset(observer)
contentDelegate.value.onMetaViewportFitChange(geckoSession, "contain")
verify(observer).onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER)
reset(observer)
}
@Test @Test
fun clearData() { fun clearData() {
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider) val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
......
...@@ -17,6 +17,7 @@ import mozilla.components.browser.session.ext.toTabSessionState ...@@ -17,6 +17,7 @@ import mozilla.components.browser.session.ext.toTabSessionState
import mozilla.components.browser.state.action.ContentAction.AddFindResultAction import mozilla.components.browser.state.action.ContentAction.AddFindResultAction
import mozilla.components.browser.state.action.ContentAction.ClearFindResultsAction import mozilla.components.browser.state.action.ContentAction.ClearFindResultsAction
import mozilla.components.browser.state.action.ContentAction.ConsumeHitResultAction import mozilla.components.browser.state.action.ContentAction.ConsumeHitResultAction
import mozilla.components.browser.state.action.ContentAction.FullScreenChangedAction
import mozilla.components.browser.state.action.ContentAction.RemoveThumbnailAction import mozilla.components.browser.state.action.ContentAction.RemoveThumbnailAction
import mozilla.components.browser.state.action.ContentAction.UpdateHitResultAction import mozilla.components.browser.state.action.ContentAction.UpdateHitResultAction
import mozilla.components.browser.state.action.ContentAction.UpdateLoadingStateAction import mozilla.components.browser.state.action.ContentAction.UpdateLoadingStateAction
...@@ -26,6 +27,7 @@ import mozilla.components.browser.state.action.ContentAction.UpdateSecurityInfoA ...@@ -26,6 +27,7 @@ import mozilla.components.browser.state.action.ContentAction.UpdateSecurityInfoA
import mozilla.components.browser.state.action.ContentAction.UpdateThumbnailAction import mozilla.components.browser.state.action.ContentAction.UpdateThumbnailAction
import mozilla.components.browser.state.action.ContentAction.UpdateTitleAction import mozilla.components.browser.state.action.ContentAction.UpdateTitleAction
import mozilla.components.browser.state.action.ContentAction.UpdateUrlAction import mozilla.components.browser.state.action.ContentAction.UpdateUrlAction
import mozilla.components.browser.state.action.ContentAction.ViewportFitChangedAction
import mozilla.components.browser.state.action.CustomTabListAction.RemoveCustomTabAction import mozilla.components.browser.state.action.CustomTabListAction.RemoveCustomTabAction
import mozilla.components.browser.state.action.EngineAction import mozilla.components.browser.state.action.EngineAction
import mozilla.components.browser.state.action.TabListAction.AddTabAction import mozilla.components.browser.state.action.TabListAction.AddTabAction
...@@ -98,6 +100,10 @@ class Session( ...@@ -98,6 +100,10 @@ class Session(
fun onFindResult(session: Session, result: FindResult) = Unit fun onFindResult(session: Session, result: FindResult) = Unit
fun onDesktopModeChanged(session: Session, enabled: Boolean) = Unit fun onDesktopModeChanged(session: Session, enabled: Boolean) = Unit
fun onFullScreenChanged(session: Session, enabled: Boolean) = Unit fun onFullScreenChanged(session: Session, enabled: Boolean) = Unit
/**
* @param layoutInDisplayCutoutMode value of defined in https://developer.android.com/reference/android/view/WindowManager.LayoutParams#layoutInDisplayCutoutMode
*/
fun onMetaViewportFitChanged(session: Session, layoutInDisplayCutoutMode: Int) = Unit
fun onThumbnailChanged(session: Session, bitmap: Bitmap?) = Unit fun onThumbnailChanged(session: Session, bitmap: Bitmap?) = Unit
fun onContentPermissionRequested(session: Session, permissionRequest: PermissionRequest): Boolean = false fun onContentPermissionRequested(session: Session, permissionRequest: PermissionRequest): Boolean = false
fun onAppPermissionRequested(session: Session, permissionRequest: PermissionRequest): Boolean = false fun onAppPermissionRequested(session: Session, permissionRequest: PermissionRequest): Boolean = false
...@@ -406,7 +412,17 @@ class Session( ...@@ -406,7 +412,17 @@ class Session(
* Exits fullscreen mode if it's in that state. * Exits fullscreen mode if it's in that state.
*/ */
var fullScreenMode: Boolean by Delegates.observable(false) { _, old, new -> var fullScreenMode: Boolean by Delegates.observable(false) { _, old, new ->
notifyObservers(old, new) { onFullScreenChanged(this@Session, new) } if (notifyObservers(old, new) { onFullScreenChanged(this@Session, new) }) {
store?.syncDispatch(FullScreenChangedAction(id, new))
}
}
/**
* Display cutout mode state.
*/
var layoutInDisplayCutoutMode: Int by Delegates.observable(0) { _, _, new ->
notifyObservers { onMetaViewportFitChanged(this@Session, new) }
store?.syncDispatch(ViewportFitChangedAction(id, new))
} }
/** /**
......
...@@ -208,6 +208,10 @@ internal class EngineObserver( ...@@ -208,6 +208,10 @@ internal class EngineObserver(
session.fullScreenMode = enabled session.fullScreenMode = enabled
} }
override fun onMetaViewportFitChanged(layoutInDisplayCutoutMode: Int) {
session.layoutInDisplayCutoutMode = layoutInDisplayCutoutMode
}
override fun onThumbnailChange(bitmap: Bitmap?) { override fun onThumbnailChange(bitmap: Bitmap?) {
session.thumbnail = bitmap session.thumbnail = bitmap
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package mozilla.components.browser.session package mozilla.components.browser.session
import android.graphics.Bitmap import android.graphics.Bitmap
import android.view.WindowManager
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async import kotlinx.coroutines.async
...@@ -673,6 +674,21 @@ class SessionTest { ...@@ -673,6 +674,21 @@ class SessionTest {
verify(observer, never()).onFullScreenChanged(session, false) verify(observer, never()).onFullScreenChanged(session, false)
} }
@Test
fun `observer is notified on meta viewport fit change`() {
val observer = mock(Session.Observer::class.java)
val session = Session("https://www.mozilla.org")
session.register(observer)
session.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
verify(observer).onMetaViewportFitChanged(session,
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT)
reset(observer)
session.unregister(observer)
session.layoutInDisplayCutoutMode = 123
verify(observer, never()).onMetaViewportFitChanged(session, 123)
}
@Test @Test
fun `observer is notified on on thumbnail changed `() { fun `observer is notified on on thumbnail changed `() {
val observer = mock(Session.Observer::class.java) val observer = mock(Session.Observer::class.java)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package mozilla.components.browser.session.engine package mozilla.components.browser.session.engine
import android.graphics.Bitmap import android.graphics.Bitmap
import android.view.WindowManager
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import mozilla.components.browser.session.Session import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.SessionManager
...@@ -392,6 +393,24 @@ class EngineObserverTest { ...@@ -392,6 +393,24 @@ class EngineObserverTest {
assertEquals(false, session.fullScreenMode) assertEquals(false, session.fullScreenMode)
} }
@Test
fun engineObserverNotifiesMetaViewportFitChange() {
val session = Session("https://www.mozilla.org")
val observer = EngineObserver(session)
observer.onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT)
assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT,
session.layoutInDisplayCutoutMode)
observer.onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)
assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES,
session.layoutInDisplayCutoutMode)
observer.onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER)
assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER,
session.layoutInDisplayCutoutMode)
observer.onMetaViewportFitChanged(123)
assertEquals(123, session.layoutInDisplayCutoutMode)
}
@Test @Test
fun `Engine observer notified when thumbnail is assigned`() { fun `Engine observer notified when thumbnail is assigned`() {
val session = Session("https://www.mozilla.org") val session = Session("https://www.mozilla.org")
......
...@@ -246,6 +246,19 @@ sealed class ContentAction : BrowserAction() { ...@@ -246,6 +246,19 @@ sealed class ContentAction : BrowserAction() {
* Removes the [SearchRequest] of the [ContentState] with the given [sessionId]. * Removes the [SearchRequest] of the [ContentState] with the given [sessionId].
*/ */
data class ConsumeSearchRequestAction(val sessionId: String) : ContentAction() data class ConsumeSearchRequestAction(val sessionId: String) : ContentAction()
/**
* Updates the [fullScreenEnabled] with the given [sessionId].
*/
data class FullScreenChangedAction(val sessionId: String, val fullScreenEnabled: Boolean) : ContentAction()
/**
* Updates the [layoutInDisplayCutoutMode] with the given [sessionId].
*
* @property sessionId the ID of the session
* @property layoutInDisplayCutoutMode value of defined in https://developer.android.com/reference/android/view/WindowManager.LayoutParams#layoutInDisplayCutoutMode
*/
data class ViewportFitChangedAction(val sessionId: String, val layoutInDisplayCutoutMode: Int) : ContentAction()
} }
/** /**
......
...@@ -99,6 +99,12 @@ internal object ContentStateReducer { ...@@ -99,6 +99,12 @@ internal object ContentStateReducer {
is ContentAction.ConsumeSearchRequestAction -> updateContentState(state, action.sessionId) { is ContentAction.ConsumeSearchRequestAction -> updateContentState(state, action.sessionId) {
it.copy(searchRequest = null) it.copy(searchRequest = null)
} }
is ContentAction.FullScreenChangedAction -> updateContentState(state, action.sessionId) {
it.copy(fullScreen = action.fullScreenEnabled)
}
is ContentAction.ViewportFitChangedAction -> updateContentState(state, action.sessionId) {
it.copy(layoutInDisplayCutoutMode = action.layoutInDisplayCutoutMode)
}
} }
} }
} }
......
...@@ -33,6 +33,8 @@ import mozilla.components.concept.engine.window.WindowRequest ...@@ -33,6 +33,8 @@ import mozilla.components.concept.engine.window.WindowRequest
* @property findResults the list of results of the latest "find in page" operation. * @property findResults the list of results of the latest "find in page" operation.
* @property windowRequest the last received [WindowRequest]. * @property windowRequest the last received [WindowRequest].
* @property searchRequest the last received [SearchRequest] * @property searchRequest the last received [SearchRequest]
* @property fullScreen true if the page is full screen, false if not.
* @property layoutInDisplayCutoutMode the display layout cutout mode state.
*/ */
data class ContentState( data class ContentState(
val url: String, val url: String,
...@@ -49,5 +51,7 @@ data class ContentState( ...@@ -49,5 +51,7 @@ data class ContentState(
val promptRequest: PromptRequest? = null, val promptRequest: PromptRequest? = null,
val findResults: List<FindResultState> = emptyList(), val findResults: List<FindResultState> = emptyList(),
val windowRequest: WindowRequest? = null, val windowRequest: WindowRequest? = null,
val searchRequest: SearchRequest? = null val searchRequest: SearchRequest? = null,
val fullScreen: Boolean = false,
val layoutInDisplayCutoutMode: Int = 0
) )
...@@ -54,6 +54,11 @@ abstract class EngineSession( ...@@ -54,6 +54,11 @@ abstract class EngineSession(
fun onFind(text: String) = Unit fun onFind(text: String) = Unit
fun onFindResult(activeMatchOrdinal: Int, numberOfMatches: Int, isDoneCounting: Boolean) = Unit fun onFindResult(activeMatchOrdinal: Int, numberOfMatches: Int, isDoneCounting: Boolean) = Unit
fun onFullScreenChange(enabled: Boolean) = Unit fun onFullScreenChange(enabled: Boolean) = Unit
/**
* @param layoutInDisplayCutoutMode value of defined in https://developer.android.com/reference/android/view/WindowManager.LayoutParams#layoutInDisplayCutoutMode
*/
fun onMetaViewportFitChanged(layoutInDisplayCutoutMode: Int) = Unit
fun onThumbnailChange(bitmap: Bitmap?) = Unit fun onThumbnailChange(bitmap: Bitmap?) = Unit
fun onAppPermissionRequest(permissionRequest: PermissionRequest) = permissionRequest.reject() fun onAppPermissionRequest(permissionRequest: PermissionRequest) = permissionRequest.reject()
fun onContentPermissionRequest(permissionRequest: PermissionRequest) = permissionRequest.reject() fun onContentPermissionRequest(permissionRequest: PermissionRequest) = permissionRequest.reject()
......
...@@ -58,6 +58,7 @@ class EngineSessionTest { ...@@ -58,6 +58,7 @@ class EngineSessionTest {
session.notifyInternalObservers { onFind("search") } session.notifyInternalObservers { onFind("search") }
session.notifyInternalObservers { onFindResult(0, 1, true) } session.notifyInternalObservers { onFindResult(0, 1, true) }
session.notifyInternalObservers { onFullScreenChange(true) } session.notifyInternalObservers { onFullScreenChange(true) }
session.notifyInternalObservers { onMetaViewportFitChanged(1) }
session.notifyInternalObservers { onThumbnailChange(emptyBitmap) } session.notifyInternalObservers { onThumbnailChange(emptyBitmap) }
session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) }
session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) }
...@@ -84,6 +85,7 @@ class EngineSessionTest { ...@@ -84,6 +85,7 @@ class EngineSessionTest {
verify(observer).onFind("search") verify(observer).onFind("search")
verify(observer).onFindResult(0, 1, true) verify(observer).onFindResult(0, 1, true)
verify(observer).onFullScreenChange(true) verify(observer).onFullScreenChange(true)
verify(observer).onMetaViewportFitChanged(1)
verify(observer).onThumbnailChange(emptyBitmap) verify(observer).onThumbnailChange(emptyBitmap)
verify(observer).onAppPermissionRequest(permissionRequest) verify(observer).onAppPermissionRequest(permissionRequest)
verify(observer).onContentPermissionRequest(permissionRequest) verify(observer).onContentPermissionRequest(permissionRequest)
...@@ -123,6 +125,7 @@ class EngineSessionTest { ...@@ -123,6 +125,7 @@ class EngineSessionTest {
session.notifyInternalObservers { onFind("search") } session.notifyInternalObservers { onFind("search") }
session.notifyInternalObservers { onFindResult(0, 1, true) } session.notifyInternalObservers { onFindResult(0, 1, true) }
session.notifyInternalObservers { onFullScreenChange(true) } session.notifyInternalObservers { onFullScreenChange(true) }
session.notifyInternalObservers { onMetaViewportFitChanged(1) }
session.notifyInternalObservers { onThumbnailChange(emptyBitmap) } session.notifyInternalObservers { onThumbnailChange(emptyBitmap) }
session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) }
session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) }
...@@ -147,6 +150,7 @@ class EngineSessionTest { ...@@ -147,6 +150,7 @@ class EngineSessionTest {
session.notifyInternalObservers { onFind("search2") } session.notifyInternalObservers { onFind("search2") }
session.notifyInternalObservers { onFindResult(0, 1, false) } session.notifyInternalObservers { onFindResult(0, 1, false) }
session.notifyInternalObservers { onFullScreenChange(false) } session.notifyInternalObservers { onFullScreenChange(false) }
session.notifyInternalObservers { onMetaViewportFitChanged(2) }
session.notifyInternalObservers { onThumbnailChange(null) } session.notifyInternalObservers { onThumbnailChange(null) }
session.notifyInternalObservers { onContentPermissionRequest(otherPermissionRequest) } session.notifyInternalObservers { onContentPermissionRequest(otherPermissionRequest) }
session.notifyInternalObservers { onCancelContentPermissionRequest(otherPermissionRequest) } session.notifyInternalObservers { onCancelContentPermissionRequest(otherPermissionRequest) }
...@@ -169,6 +173,7 @@ class EngineSessionTest { ...@@ -169,6 +173,7 @@ class EngineSessionTest {
verify(observer).onFind("search") verify(observer).onFind("search")
verify(observer).onFindResult(0, 1, true) verify(observer).onFindResult(0, 1, true)
verify(observer).onFullScreenChange(true) verify(observer).onFullScreenChange(true)
verify(observer).onMetaViewportFitChanged(1)
verify(observer).onThumbnailChange(emptyBitmap) verify(observer).onThumbnailChange(emptyBitmap)
verify(observer).onAppPermissionRequest(permissionRequest) verify(observer).onAppPermissionRequest(permissionRequest)
verify(observer).onContentPermissionRequest(permissionRequest) verify(observer).onContentPermissionRequest(permissionRequest)
...@@ -188,6 +193,7 @@ class EngineSessionTest { ...@@ -188,6 +193,7 @@ class EngineSessionTest {
verify(observer, never()).onFind("search2") verify(observer, never()).onFind("search2")
verify(observer, never()).onFindResult(0, 1, false) verify(observer, never()).onFindResult(0, 1, false)
verify(observer, never()).onFullScreenChange(false) verify(observer, never()).onFullScreenChange(false)
verify(observer, never()).onMetaViewportFitChanged(2)
verify(observer, never()).onThumbnailChange(null) verify(observer, never()).onThumbnailChange(null)
verify(observer, never()).onAppPermissionRequest(otherPermissionRequest) verify(observer, never()).onAppPermissionRequest(otherPermissionRequest)
verify(observer, never()).onContentPermissionRequest(otherPermissionRequest) verify(observer, never()).onContentPermissionRequest(otherPermissionRequest)
...@@ -227,6 +233,7 @@ class EngineSessionTest { ...@@ -227,6 +233,7 @@ class EngineSessionTest {
session.notifyInternalObservers { onFind("search") } session.notifyInternalObservers { onFind("search") }
session.notifyInternalObservers { onFindResult(0, 1, true) } session.notifyInternalObservers { onFindResult(0, 1, true) }
session.notifyInternalObservers { onFullScreenChange(true) } session.notifyInternalObservers { onFullScreenChange(true) }
session.notifyInternalObservers { onMetaViewportFitChanged(1) }
session.notifyInternalObservers { onThumbnailChange(emptyBitmap) } session.notifyInternalObservers { onThumbnailChange(emptyBitmap) }
session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) }
session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) }
...@@ -246,6 +253,7 @@ class EngineSessionTest { ...@@ -246,6 +253,7 @@ class EngineSessionTest {
session.notifyInternalObservers { onFind("search2") } session.notifyInternalObservers { onFind("search2") }
session.notifyInternalObservers { onFindResult(0, 1, false) } session.notifyInternalObservers { onFindResult(0, 1, false) }
session.notifyInternalObservers { onFullScreenChange(false) } session.notifyInternalObservers { onFullScreenChange(false) }
session.notifyInternalObservers { onMetaViewportFitChanged(2) }
session.notifyInternalObservers { onThumbnailChange(null) } session.notifyInternalObservers { onThumbnailChange(null) }
session.notifyInternalObservers { onContentPermissionRequest(otherPermissionRequest) } session.notifyInternalObservers { onContentPermissionRequest(otherPermissionRequest) }
session.notifyInternalObservers { onCancelContentPermissionRequest(otherPermissionRequest) } session.notifyInternalObservers { onCancelContentPermissionRequest(otherPermissionRequest) }
...@@ -263,6 +271,7 @@ class EngineSessionTest { ...@@ -263,6 +271,7 @@ class EngineSessionTest {
verify(observer).onFind("search") verify(observer).onFind("search")
verify(observer).onFindResult(0, 1, true) verify(observer).onFindResult(0, 1, true)
verify(observer).onFullScreenChange(true) verify(observer).onFullScreenChange(true)
verify(observer).onMetaViewportFitChanged(1)
verify(observer).onThumbnailChange(emptyBitmap) verify(observer).onThumbnailChange(emptyBitmap)
verify(observer).onAppPermissionRequest(permissionRequest) verify(observer).onAppPermissionRequest(permissionRequest)
verify(observer).onContentPermissionRequest(permissionRequest) verify(observer).onContentPermissionRequest(permissionRequest)
...@@ -279,6 +288,7 @@ class EngineSessionTest { ...@@ -279,6 +288,7 @@ class EngineSessionTest {
verify(observer, never()).onFind("search2") verify(observer, never()).onFind("search2")
verify(observer, never()).onFindResult(0, 1, false) verify(observer, never()).onFindResult(0, 1, false)
verify(observer, never()).onFullScreenChange(false) verify(observer, never()).onFullScreenChange(false)
verify(observer, never()).onMetaViewportFitChanged(2)
verify(observer, never()).onThumbnailChange(null) verify(observer, never()).onThumbnailChange(null)
verify(observer, never()).onAppPermissionRequest(otherPermissionRequest) verify(observer, never()).onAppPermissionRequest(otherPermissionRequest)
verify(observer, never()).onContentPermissionRequest(otherPermissionRequest) verify(observer, never()).onContentPermissionRequest(otherPermissionRequest)
...@@ -295,6 +305,7 @@ class EngineSessionTest { ...@@ -295,6 +305,7 @@ class EngineSessionTest {
verify(otherObserver, never()).onFind("search2") verify(otherObserver, never()).onFind("search2")
verify(otherObserver, never()).onFindResult(0, 1, false) verify(otherObserver, never()).onFindResult(0, 1, false)
verify(otherObserver, never()).onFullScreenChange(false) verify(otherObserver, never()).onFullScreenChange(false)
verify(otherObserver, never()).onMetaViewportFitChanged(2)
verify(otherObserver, never()).onThumbnailChange(null) verify(otherObserver, never()).onThumbnailChange(null)
verify(otherObserver, never()).onAppPermissionRequest(otherPermissionRequest) verify(otherObserver, never()).onAppPermissionRequest(otherPermissionRequest)
verify(otherObserver, never()).onContentPermissionRequest(otherPermissionRequest) verify(otherObserver, never()).onContentPermissionRequest(otherPermissionRequest)
...@@ -327,6 +338,7 @@ class EngineSessionTest { ...@@ -327,6 +338,7 @@ class EngineSessionTest {
session.notifyInternalObservers { onFind("search") } session.notifyInternalObservers { onFind("search") }
session.notifyInternalObservers { onFindResult(0, 1, true) } session.notifyInternalObservers { onFindResult(0, 1, true) }
session.notifyInternalObservers { onFullScreenChange(true) } session.notifyInternalObservers { onFullScreenChange(true) }
session.notifyInternalObservers { onMetaViewportFitChanged(1) }
session.notifyInternalObservers { onThumbnailChange(emptyBitmap) } session.notifyInternalObservers { onThumbnailChange(emptyBitmap) }
session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onContentPermissionRequest(permissionRequest) }
session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) } session.notifyInternalObservers { onCancelContentPermissionRequest(permissionRequest) }
...@@ -346,6 +358,7 @@ class EngineSessionTest { ...@@ -346,6 +358,7 @@ class EngineSessionTest {
session.notifyInternalObservers { onFind("search2") } session.notifyInternalObservers { onFind("search2") }
session.notifyInternalObservers { onFindResult(0, 1, false) } session.notifyInternalObservers { onFindResult(0, 1, false) }
session.notifyInternalObservers { onFullScreenChange(false) } session.notifyInternalObservers { onFullScreenChange(false) }
session.notifyInternalObservers { onMetaViewportFitChanged(2) }
session.notifyInternalObservers { onThumbnailChange(null) } session.notifyInternalObservers { onThumbnailChange(null) }
session.notifyInternalObservers { onContentPermissionRequest(otherPermissionRequest) } session.notifyInternalObservers { onContentPermissionRequest(otherPermissionRequest) }
session.notifyInternalObservers { onCancelContentPermissionRequest(otherPermissionRequest) } session.notifyInternalObservers { onCancelContentPermissionRequest(otherPermissionRequest) }
...@@ -363,6 +376,7 @@ class EngineSessionTest { ...@@ -363,6 +376,7 @@ class EngineSessionTest {
verify(observer).onFind("search") verify(observer).onFind("search")
verify(observer).onFindResult(0, 1, true) verify(observer).onFindResult(0, 1, true)
verify(observer).onFullScreenChange(true) verify(observer).onFullScreenChange(true)
verify(observer).onMetaViewportFitChanged(1)
verify(observer).onThumbnailChange(emptyBitmap) verify(observer).onThumbnailChange(emptyBitmap)
verify(observer).onAppPermissionRequest(permissionRequest) verify(observer).onAppPermissionRequest(permissionRequest)
verify(observer).onContentPermissionRequest(permissionRequest) verify(observer).onContentPermissionRequest(permissionRequest)
...@@ -379,6 +393,7 @@ class EngineSessionTest { ...@@ -379,6 +393,7 @@ class EngineSessionTest {
verify(observer, never()).onFind("search2") verify(observer, never()).onFind("search2")
verify(observer, never()).onFindResult(0, 1, false) verify(observer, never()).onFindResult(0, 1, false)
verify(observer, never()).onFullScreenChange(false) verify(observer, never()).onFullScreenChange(false)
verify(observer, never()).onMetaViewportFitChanged(2)