From 096982e4ba079e5b7969def1802cfc6796b75e26 Mon Sep 17 00:00:00 2001 From: Poovamraj T T Date: Mon, 31 Jul 2023 18:17:51 +0200 Subject: [PATCH] Fix test compilation to handle changes --- .../provider/AuthenticationActivityTest.kt | 26 ++++++++++++++++--- .../provider/CustomTabsControllerTest.java | 16 ++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.kt b/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.kt index 4f7d65cc..435ae536 100644 --- a/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.kt +++ b/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.kt @@ -6,6 +6,8 @@ import android.net.Uri import android.os.Bundle import android.os.Parcelable import androidx.test.espresso.intent.matcher.IntentMatchers +import com.auth0.android.authentication.AuthenticationException +import com.auth0.android.callback.RunnableTask import com.auth0.android.provider.AuthenticationActivity import com.auth0.android.provider.CustomTabsOptions import org.hamcrest.CoreMatchers @@ -86,7 +88,11 @@ public class AuthenticationActivityTest { createActivity(intentCaptor.value) activityController.create().start().resume() Mockito.verify(customTabsController).bindService() - Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture()) + Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture(), object : + RunnableTask { + override fun apply(error: AuthenticationException) { + } + }) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(Matchers.notNullValue())) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(uri)) MatcherAssert.assertThat(activity.deliveredIntent, Is.`is`(Matchers.nullValue())) @@ -117,7 +123,11 @@ public class AuthenticationActivityTest { createActivity(intentCaptor.value) activityController.create().start().resume() Mockito.verify(customTabsController).bindService() - Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture()) + Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture(), object : + RunnableTask { + override fun apply(error: AuthenticationException) { + } + }) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(Matchers.notNullValue())) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(uri)) MatcherAssert.assertThat(activity.deliveredIntent, Is.`is`(Matchers.nullValue())) @@ -148,7 +158,11 @@ public class AuthenticationActivityTest { createActivity(intentCaptor.value) activityController.create().start().resume() Mockito.verify(customTabsController).bindService() - Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture()) + Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture(), object : + RunnableTask { + override fun apply(error: AuthenticationException) { + } + }) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(Matchers.notNullValue())) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(uri)) MatcherAssert.assertThat(launchAsTwaCaptor.value, Is.`is`(Matchers.notNullValue())) @@ -178,7 +192,11 @@ public class AuthenticationActivityTest { createActivity(intentCaptor.value) activityController.create().start().resume() Mockito.verify(customTabsController).bindService() - Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture()) + Mockito.verify(customTabsController).launchUri(uriCaptor.capture(), launchAsTwaCaptor.capture(), object : + RunnableTask { + override fun apply(error: AuthenticationException) { + } + }) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(Matchers.notNullValue())) MatcherAssert.assertThat(uriCaptor.value, Is.`is`(uri)) MatcherAssert.assertThat(launchAsTwaCaptor.value, Is.`is`(Matchers.notNullValue())) diff --git a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java index 52e537c8..efd4cb3e 100644 --- a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java @@ -127,7 +127,7 @@ public void shouldUnbindEvenIfNotBound() throws Exception { @Test public void shouldBindAndLaunchUri() throws Exception { bindService(controller, true); - controller.launchUri(uri, false); + controller.launchUri(uri, false, (ex) -> {}); connectBoundService(); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); @@ -146,7 +146,7 @@ public void shouldBindAndLaunchUri() throws Exception { @Test public void shouldBindAndLaunchUriAsTwa() throws Exception { bindService(controller, true); - controller.launchUri(uri, true); + controller.launchUri(uri, true, (ex) -> {}); connectBoundService(); ArgumentCaptor trustedWebActivityIntentBuilderArgumentCaptor = ArgumentCaptor.forClass(TrustedWebActivityIntentBuilder.class); @@ -176,7 +176,7 @@ public void shouldLaunchUriUsingFallbackWhenNoCompatibleBrowserIsAvailable() { when(browserPicker.getBestBrowserPackage(context.getPackageManager())).thenReturn(null); CustomTabsOptions ctOptions = CustomTabsOptions.newBuilder().withBrowserPicker(browserPicker).build(); CustomTabsController controller = new CustomTabsController(context, ctOptions, twaLauncher); - controller.launchUri(uri, false); + controller.launchUri(uri, false, (ex) -> {}); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); Intent intent = launchIntentCaptor.getValue(); @@ -199,7 +199,7 @@ public void shouldBindAndLaunchUriWithCustomization() throws Exception { CustomTabsController controller = new CustomTabsController(context, ctOptions, twaLauncher); bindService(controller, true); - controller.launchUri(uri, false); + controller.launchUri(uri, false, (ex) -> {}); connectBoundService(); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); @@ -228,7 +228,7 @@ public void shouldBindAndLaunchUriWithCustomizationTwa() throws Exception { CustomTabsController controller = new CustomTabsController(context, ctOptions, twaLauncher); bindService(controller, true); - controller.launchUri(uri, true); + controller.launchUri(uri, true, (ex) -> {}); connectBoundService(); @@ -257,7 +257,7 @@ public void shouldBindAndLaunchUriWithCustomizationTwa() throws Exception { @Test public void shouldFailToBindButLaunchUri() { bindService(controller, false); - controller.launchUri(uri, false); + controller.launchUri(uri, false, (ex) -> {}); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); Intent intent = launchIntentCaptor.getValue(); @@ -271,7 +271,7 @@ public void shouldFailToBindButLaunchUri() { public void shouldNotLaunchUriIfContextNoLongerValid() { bindService(controller, true); controller.clearContext(); - controller.launchUri(uri, false); + controller.launchUri(uri, false, (ex) -> {}); verify(context, never()).startActivity(any(Intent.class)); } @@ -280,7 +280,7 @@ public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() { doThrow(ActivityNotFoundException.class) .doNothing() .when(context).startActivity(any(Intent.class)); - controller.launchUri(uri, false); + controller.launchUri(uri, false, (ex) -> {}); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); List intents = launchIntentCaptor.getAllValues();