Bug 1647797 - Add geckoview-junit tests for onPaintStatusReset. r=agi,geckoview-reviewers

Add test paintStatusReset() to ContentDelegateTest, which asserts that
onPaintStatusReset() is called after GeckoSession.setActive(false).

Add test capturePixelsSessionDeactivatedActivated() to ScreenshotTest, which
asserts that capturePixels() is successful if called when the session is
deactivated then reactivated, after waiting for the onPaintStatusReset() and
onFirstContentfulPaint() callbacks.

Differential Revision: https://phabricator.services.mozilla.com/D87463
This commit is contained in:
Jamie Nicol 2020-08-19 15:25:26 +00:00
parent e3b924526e
commit 456abf2772
2 changed files with 47 additions and 0 deletions

View File

@ -229,6 +229,22 @@ class ContentDelegateTest : BaseSessionTest() {
})
}
@WithDisplay(width = 10, height = 10)
@Test fun paintStatusReset() {
mainSession.loadTestPath(HELLO_HTML_PATH)
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onFirstContentfulPaint(session: GeckoSession) {
}
})
mainSession.setActive(false)
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onPaintStatusReset(session: GeckoSession) {
}
})
}
@Test fun webAppManifestPref() {
val initialState = sessionRule.runtime.settings.getWebManifestEnabled()
val jsToRun = "document.querySelector('link[rel=manifest]').relList.supports('manifest');"

View File

@ -154,6 +154,37 @@ class ScreenshotTest : BaseSessionTest() {
}
}
@WithDisplay(height = SCREEN_HEIGHT, width = SCREEN_WIDTH)
@Test
fun capturePixelsSessionDeactivatedActivated() {
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onFirstContentfulPaint(session: GeckoSession) {
}
})
sessionRule.session.setActive(false)
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onPaintStatusReset(session: GeckoSession) {
}
})
sessionRule.session.setActive(true)
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onFirstContentfulPaint(session: GeckoSession) {
}
})
sessionRule.display?.let {
assertScreenshotResult(it.capturePixels(), screenshotFile)
}
}
@WithDisplay(height = SCREEN_HEIGHT, width = SCREEN_WIDTH)
@Test
fun screenshotToBitmap() {