@@ -2,7 +2,6 @@ package com.stripe.android.challenge.confirmation
22
33import android.net.Uri
44import android.net.http.SslError
5- import android.os.Build
65import android.webkit.RenderProcessGoneDetail
76import android.webkit.SslErrorHandler
87import android.webkit.WebResourceError
@@ -17,14 +16,12 @@ import org.mockito.kotlin.mock
1716import org.mockito.kotlin.verify
1817import org.mockito.kotlin.whenever
1918import org.robolectric.RobolectricTestRunner
20- import org.robolectric.annotation.Config
2119
2220@RunWith(RobolectricTestRunner ::class )
2321internal class IntentConfirmationWebViewClientTest {
2422
2523 // onReceivedError (API 23+) tests
2624 @Test
27- @Config(sdk = [Build .VERSION_CODES .M ])
2825 fun `onReceivedError for host url calls errorHandler with correct details` () =
2926 testWithSetup { client, errors, webView ->
3027 val request = createRequest(HOST_URL )
@@ -43,7 +40,6 @@ internal class IntentConfirmationWebViewClientTest {
4340 }
4441
4542 @Test
46- @Config(sdk = [Build .VERSION_CODES .M ])
4743 fun `onReceivedError for wrong url does not call errorHandler` () = testWithSetup { client, errors, webView ->
4844 val request = createRequest(url = " https://example.com/iframe" )
4945 val error = createWebResourceError()
@@ -54,7 +50,6 @@ internal class IntentConfirmationWebViewClientTest {
5450 }
5551
5652 @Test
57- @Config(sdk = [Build .VERSION_CODES .M ])
5853 fun `onReceivedError handles trailing slash in failingUrl` () = testWithSetup { client, errors, webView ->
5954 val request = createRequest(url = " $HOST_URL /" )
6055 val error = createWebResourceError()
@@ -71,7 +66,6 @@ internal class IntentConfirmationWebViewClientTest {
7166 }
7267
7368 @Test
74- @Config(sdk = [Build .VERSION_CODES .M ])
7569 fun `onReceivedError handles trailing slash in hostUrl` () =
7670 testWithSetup(" $HOST_URL /" ) { client, errors, webView ->
7771 val request = createRequest(HOST_URL )
@@ -88,56 +82,8 @@ internal class IntentConfirmationWebViewClientTest {
8882 )
8983 }
9084
91- // onReceivedError (Pre-API 23) tests
92- @Test
93- @Config(sdk = [Build .VERSION_CODES .LOLLIPOP ])
94- fun `onReceivedError legacy API calls errorHandler` () = testWithSetup { client, errors, webView ->
95- @Suppress(" DEPRECATION" )
96- client.onReceivedError(webView, - 2 , " Connection failed" , HOST_URL )
97-
98- assertThat(errors).hasSize(1 )
99- errors[0 ].assertHasDetails(
100- message = " Connection failed" ,
101- errorCode = - 2 ,
102- url = HOST_URL ,
103- type = " generic_resource_error"
104- )
105- }
106-
107- @Test
108- @Config(sdk = [Build .VERSION_CODES .LOLLIPOP ])
109- fun `onReceivedError legacy API handles trailing slash in failingUrl` () = testWithSetup { client, errors, webView ->
110- @Suppress(" DEPRECATION" )
111- client.onReceivedError(webView, - 2 , " Connection failed" , " $HOST_URL /" )
112-
113- assertThat(errors).hasSize(1 )
114- errors[0 ].assertHasDetails(
115- message = " Connection failed" ,
116- errorCode = - 2 ,
117- url = " $HOST_URL /" ,
118- type = " generic_resource_error"
119- )
120- }
121-
122- @Test
123- @Config(sdk = [Build .VERSION_CODES .LOLLIPOP ])
124- fun `onReceivedError legacy API handles trailing slash in hostUrl` () =
125- testWithSetup(hostUrl = " $HOST_URL /" ) { client, errors, webView ->
126- @Suppress(" DEPRECATION" )
127- client.onReceivedError(webView, - 2 , " Connection failed" , HOST_URL )
128-
129- assertThat(errors).hasSize(1 )
130- errors[0 ].assertHasDetails(
131- message = " Connection failed" ,
132- errorCode = - 2 ,
133- url = HOST_URL ,
134- type = " generic_resource_error"
135- )
136- }
137-
13885 // onReceivedHttpError tests
13986 @Test
140- @Config(sdk = [Build .VERSION_CODES .M ])
14187 fun `onReceivedHttpError for host url calls errorHandler` () = testWithSetup { client, errors, webView ->
14288 val request = createRequest(HOST_URL )
14389 val response = createWebResourceResponse()
@@ -154,7 +100,6 @@ internal class IntentConfirmationWebViewClientTest {
154100 }
155101
156102 @Test
157- @Config(sdk = [Build .VERSION_CODES .M ])
158103 fun `onReceivedHttpError for non-host url does not call errorHandler` () = testWithSetup { client, errors, webView ->
159104 val request = createRequest(url = " https://example.com/iframe" )
160105 val response = createWebResourceResponse()
@@ -165,7 +110,6 @@ internal class IntentConfirmationWebViewClientTest {
165110 }
166111
167112 @Test
168- @Config(sdk = [Build .VERSION_CODES .M ])
169113 fun `onReceivedHttpError handles trailing slash in request url` () = testWithSetup { client, errors, webView ->
170114 val request = createRequest(url = " $HOST_URL /" )
171115 val response = createWebResourceResponse()
@@ -182,7 +126,6 @@ internal class IntentConfirmationWebViewClientTest {
182126 }
183127
184128 @Test
185- @Config(sdk = [Build .VERSION_CODES .M ])
186129 fun `onReceivedHttpError handles trailing slash in hostUrl` () =
187130 testWithSetup(hostUrl = " $HOST_URL /" ) { client, errors, webView ->
188131 val request = createRequest(HOST_URL )
@@ -219,7 +162,6 @@ internal class IntentConfirmationWebViewClientTest {
219162
220163 // onRenderProcessGone tests
221164 @Test
222- @Config(sdk = [Build .VERSION_CODES .O ])
223165 fun `onRenderProcessGone calls errorHandler with view URL` () = testWithSetup { client, errors, webView ->
224166 webView.loadUrl(HOST_URL )
225167 val detail = createRenderProcessGoneDetail()
0 commit comments