Bug 1456543 - 3. Add test for updating module state during transfer; r=esawin
authorJim Chen <nchen@mozilla.com>
Fri, 27 Apr 2018 11:57:14 -0400
changeset 472179 c3888fb8c222ee328da7f5fccf865c11785cf7c0
parent 472178 206d01e57d0dfefec680d0a0f29254f700f8cc83
child 472180 0ec752913e9685f2e25ac1be4e16b822e58de2de
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1456543
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1456543 - 3. Add test for updating module state during transfer; r=esawin Add a test for correctly updating module states after transferring, so that, for example, if we transfer a session with a null delegate to another session with a non-null delegate, the corresponding module will be automatically enabled. MozReview-Commit-ID: IHskWAJ584i
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/SessionLifecycleTest.kt
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/SessionLifecycleTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/SessionLifecycleTest.kt
@@ -1,16 +1,19 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 package org.mozilla.geckoview.test
 
 import org.mozilla.geckoview.GeckoSession
 import org.mozilla.geckoview.GeckoSessionSettings
+import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ClosedSessionAtStart
+import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.NullDelegate
+import org.mozilla.geckoview.test.util.Callbacks
 
 import android.support.test.filters.MediumTest
 import android.support.test.runner.AndroidJUnit4
 
 import org.hamcrest.Matchers.*
 import org.junit.Test
 import org.junit.runner.RunWith
 
@@ -185,16 +188,46 @@ class SessionLifecycleTest : BaseSession
         session2.toParcel { parcel ->
             session3.readFromParcel(parcel)
         }
 
         session3.reload()
         session3.waitForPageStop()
     }
 
+    @NullDelegate(GeckoSession.NavigationDelegate::class)
+    @ClosedSessionAtStart
+    @Test fun readFromParcel_moduleUpdated() {
+        val session = sessionRule.createOpenSession()
+
+        // Disable navigation notifications on the old, open session.
+        assertThat("Old session navigation delegate should be null",
+                   session.navigationDelegate, nullValue())
+
+        // Enable navigation notifications on the new, closed session.
+        var onLocationCount = 0
+        sessionRule.session.navigationDelegate = object : Callbacks.NavigationDelegate {
+            override fun onLocationChange(session: GeckoSession, url: String) {
+                onLocationCount++
+            }
+        }
+
+        // Transferring the old session to the new session should
+        // automatically re-enable navigation notifications.
+        session.toParcel { parcel ->
+            sessionRule.session.readFromParcel(parcel)
+        }
+
+        sessionRule.session.reload()
+        sessionRule.session.waitForPageStop()
+
+        assertThat("New session should receive navigation notifications",
+                   onLocationCount, equalTo(1))
+    }
+
     @Test fun createFromParcel() {
         val session = sessionRule.createOpenSession()
 
         session.toParcel { parcel ->
             val newSession = sessionRule.wrapSession(
                     GeckoSession.CREATOR.createFromParcel(parcel))
 
             assertThat("New session has same settings",