@@ -78,7 +78,7 @@ public void shouldHaveDefaultValues() {
7878 CustomTabsOptions options = CustomTabsOptions .newBuilder ().build ();
7979 assertThat (options , is (notNullValue ()));
8080
81- Intent intent = options .toIntent (context , null , null );
81+ Intent intent = options .toIntent (context , null );
8282
8383 assertThat (intent , is (notNullValue ()));
8484 assertThat (intent .hasExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR ), is (false ));
@@ -93,7 +93,7 @@ public void shouldHaveDefaultValues() {
9393 CustomTabsOptions parceledOptions = CustomTabsOptions .CREATOR .createFromParcel (parcel );
9494 assertThat (parceledOptions , is (notNullValue ()));
9595
96- Intent parceledIntent = parceledOptions .toIntent (context , null , null );
96+ Intent parceledIntent = parceledOptions .toIntent (context , null );
9797 assertThat (parceledIntent , is (notNullValue ()));
9898 assertThat (parceledIntent .hasExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR ), is (false ));
9999 assertThat (parceledIntent .hasExtra (CustomTabsIntent .EXTRA_TITLE_VISIBILITY_STATE ), is (true ));
@@ -109,7 +109,7 @@ public void shouldSetShowTitle() {
109109 .build ();
110110 assertThat (options , is (notNullValue ()));
111111
112- Intent intent = options .toIntent (context , null , null );
112+ Intent intent = options .toIntent (context , null );
113113
114114 assertThat (intent , is (notNullValue ()));
115115 assertThat (intent .hasExtra (CustomTabsIntent .EXTRA_TITLE_VISIBILITY_STATE ), is (true ));
@@ -122,7 +122,7 @@ public void shouldSetShowTitle() {
122122 CustomTabsOptions parceledOptions = CustomTabsOptions .CREATOR .createFromParcel (parcel );
123123 assertThat (parceledOptions , is (notNullValue ()));
124124
125- Intent parceledIntent = parceledOptions .toIntent (context , null , null );
125+ Intent parceledIntent = parceledOptions .toIntent (context , null );
126126 assertThat (parceledIntent , is (notNullValue ()));
127127 assertThat (parceledIntent .hasExtra (CustomTabsIntent .EXTRA_TITLE_VISIBILITY_STATE ), is (true ));
128128 assertThat (parceledIntent .getIntExtra (CustomTabsIntent .EXTRA_TITLE_VISIBILITY_STATE , CustomTabsIntent .NO_TITLE ), is (CustomTabsIntent .SHOW_PAGE_TITLE ));
@@ -135,7 +135,7 @@ public void shouldSetToolbarColor() {
135135 .build ();
136136 assertThat (options , is (notNullValue ()));
137137
138- Intent intent = options .toIntent (context , null , null );
138+ Intent intent = options .toIntent (context , null );
139139
140140 assertThat (intent , is (notNullValue ()));
141141 assertThat (intent .hasExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR ), is (true ));
@@ -149,7 +149,7 @@ public void shouldSetToolbarColor() {
149149 CustomTabsOptions parceledOptions = CustomTabsOptions .CREATOR .createFromParcel (parcel );
150150 assertThat (parceledOptions , is (notNullValue ()));
151151
152- Intent parceledIntent = parceledOptions .toIntent (context , null , null );
152+ Intent parceledIntent = parceledOptions .toIntent (context , null );
153153 assertThat (parceledIntent , is (notNullValue ()));
154154 assertThat (parceledIntent .hasExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR ), is (true ));
155155 assertThat (parceledIntent .getIntExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR , 0 ), is (resolvedColor ));
@@ -181,33 +181,47 @@ public void shouldSetBrowserPicker() {
181181
182182 @ Test
183183 public void shouldSetDisabledCustomTabPackages () {
184+ Activity activity = spy (Robolectric .setupActivity (Activity .class ));
185+ BrowserPickerTest .setupBrowserContext (activity , Collections .singletonList ("com.auth0.browser" ), null , null );
186+ BrowserPicker browserPicker = BrowserPicker .newBuilder ().build ();
187+
184188 CustomTabsOptions options = CustomTabsOptions .newBuilder ()
189+ .withBrowserPicker (browserPicker )
185190 .withDisabledCustomTabsPackages (List .of ("com.auth0.browser" ))
186191 .withToolbarColor (android .R .color .black )
187192 .build ();
188193 assertThat (options , is (notNullValue ()));
189194
190- Intent intentNoExtras = options .toIntent (context , null , "com.auth0.browser" );
195+ Intent intentNoExtras = options .toIntent (activity , null );
191196
192197 assertThat (intentNoExtras , is (notNullValue ()));
193198 assertThat (intentNoExtras .getExtras (), is (nullValue ()));
194199 assertEquals (intentNoExtras .getAction (), "android.intent.action.VIEW" );
195200
196- Intent intentWithToolbarExtra = options .toIntent (context , null , "com.another.browser" );
197- assertThat (intentWithToolbarExtra , is (notNullValue ()));
198- assertThat (intentWithToolbarExtra .hasExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR ), is (true ));
199- int resolvedColor = ContextCompat .getColor (context , android .R .color .black );
200- assertThat (intentWithToolbarExtra .getIntExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR , 0 ), is (resolvedColor ));
201-
202201 Parcel parcel = Parcel .obtain ();
203202 options .writeToParcel (parcel , 0 );
204203 parcel .setDataPosition (0 );
205204 CustomTabsOptions parceledOptions = CustomTabsOptions .CREATOR .createFromParcel (parcel );
206205 assertThat (parceledOptions , is (notNullValue ()));
207206
208- Intent parceledIntent = parceledOptions .toIntent (context , null , "com.auth0.browser" );
207+ Intent parceledIntent = parceledOptions .toIntent (activity , null );
209208 assertThat (parceledIntent , is (notNullValue ()));
210209 assertThat (parceledIntent .getExtras (), is (nullValue ()));
211210 assertEquals (parceledIntent .getAction (), "android.intent.action.VIEW" );
211+
212+ BrowserPickerTest .setupBrowserContext (activity , Collections .singletonList ("com.another.browser" ), null , null );
213+ BrowserPicker browserPicker2 = BrowserPicker .newBuilder ().build ();
214+
215+ CustomTabsOptions options2 = CustomTabsOptions .newBuilder ()
216+ .withBrowserPicker (browserPicker2 )
217+ .withDisabledCustomTabsPackages (List .of ("com.auth0.browser" ))
218+ .withToolbarColor (android .R .color .black )
219+ .build ();
220+
221+ Intent intentWithToolbarExtra = options2 .toIntent (activity , null );
222+ assertThat (intentWithToolbarExtra , is (notNullValue ()));
223+ assertThat (intentWithToolbarExtra .hasExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR ), is (true ));
224+ int resolvedColor = ContextCompat .getColor (activity , android .R .color .black );
225+ assertThat (intentWithToolbarExtra .getIntExtra (CustomTabsIntent .EXTRA_TOOLBAR_COLOR , 0 ), is (resolvedColor ));
212226 }
213227}
0 commit comments