Skip to content
Permalink
Browse files

Issue 1195: Remove webview if EngineView instance is reused

  • Loading branch information...
csadilek committed Jan 8, 2019
1 parent c2f6480 commit 59240f7a71a9f63fc51c1ff65e604f6735196a0e
@@ -69,9 +69,10 @@ class SystemEngineView @JvmOverloads constructor(
* Render the content of the given session.
*/
override fun render(session: EngineSession) {
this.session = session as SystemEngineSession
removeAllViews()

(session.webView?.parent as? SystemEngineView)?.removeView(session.webView)
this.session = session as SystemEngineSession
(session.webView.parent as? SystemEngineView)?.removeView(session.webView)
addView(initWebView(session.webView))
}

@@ -1033,6 +1033,7 @@ class SystemEngineViewTest {
engineView.render(SystemEngineSession(getApplicationContext()))
assertFalse(engineView.onLongClick(null))
}

@Test
fun `Calling onJsAlert must provide an Alert PromptRequest`() {
val context = getApplicationContext<Context>()
@@ -1190,6 +1191,18 @@ class SystemEngineViewTest {
}
}

@Test
fun `render removes webview from previous session`() {
val engineView = SystemEngineView(getApplicationContext())

val session1 = SystemEngineSession(getApplicationContext())
val session2 = SystemEngineSession(getApplicationContext())
engineView.render(session1)
engineView.render(session2)

assertNull(session1.webView.parent)
}

private fun Date.add(timeUnit: Int, amountOfTime: Int): Date {
val calendar = Calendar.getInstance()
calendar.time = this

0 comments on commit 59240f7

Please sign in to comment.
You can’t perform that action at this time.