Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Commit 57c3542

Browse files
committed
Issue #110: Bug fix: Do not try to load URL if empty
1 parent 708d91b commit 57c3542

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

components/feature/session/src/main/java/mozilla/components/feature/session/SessionIntentProcessor.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ class SessionIntentProcessor(
2020
val url = intent.dataString
2121
if (TextUtils.isEmpty(url)) {
2222
false
23+
} else {
24+
// TODO switch to loadUrlInNewTab
25+
// https://github.com/mozilla-mobile/android-components/issues/136
26+
sessionUseCases.loadUrl.invoke(url)
27+
true
2328
}
24-
25-
// TODO switch to loadUrlInNewTab, once available
26-
sessionUseCases.loadUrl.invoke(url)
27-
true
2829
}
2930

3031
private val defaultHandlers: MutableMap<String, IntentHandler> by lazy {

components/feature/session/src/test/java/mozilla/components/feature/session/SessionIntentProcessorTest.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.junit.Test
1515
import org.junit.runner.RunWith
1616
import org.mockito.Mockito.`when`
1717
import org.mockito.Mockito.mock
18+
import org.mockito.Mockito.never
1819
import org.mockito.Mockito.verify
1920
import org.mockito.Mockito.verifyZeroInteractions
2021
import org.robolectric.RobolectricTestRunner
@@ -33,12 +34,16 @@ class SessionIntentProcessorTest {
3334
}
3435

3536
@Test
36-
fun testProcessWIthDefaultHandlers() {
37+
fun testProcessWithDefaultHandlers() {
3738
val handler = SessionIntentProcessor(useCases)
3839
val intent = mock(Intent::class.java)
3940
`when`(intent.action).thenReturn(Intent.ACTION_VIEW)
40-
`when`(intent.dataString).thenReturn("http://mozilla.org")
4141

42+
`when`(intent.dataString).thenReturn("")
43+
handler.process(intent)
44+
verify(engineSession, never()).loadUrl("")
45+
46+
`when`(intent.dataString).thenReturn("http://mozilla.org")
4247
handler.process(intent)
4348
verify(engineSession).loadUrl("http://mozilla.org")
4449
}

0 commit comments

Comments
 (0)