Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions library/java/net/openid/appauth/AuthorizationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ public CustomTabManager getCustomTabManager() {
return mCustomTabManager;
}

/**
* Returns the BrowserDescriptor of the chosen browser.
* Can for example be used to set the browsers package name to a CustomTabsIntent.
*/
public BrowserDescriptor getBrowserDescriptor() {
return mBrowser;
}

/**
* Creates a custom tab builder, that will use a tab session from an existing connection to
* a web browser, if available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import net.openid.appauth.AppAuthConfiguration.Builder;
import net.openid.appauth.AuthorizationException.GeneralErrors;
import net.openid.appauth.browser.BrowserDescriptor;
import net.openid.appauth.browser.Browsers;
import net.openid.appauth.browser.CustomTabManager;
import net.openid.appauth.connectivity.ConnectionBuilder;
Expand Down Expand Up @@ -119,6 +120,7 @@ public class AuthorizationServiceTest {
private RegistrationCallback mRegistrationCallback;
private AuthorizationService mService;
private OutputStream mOutputStream;
private BrowserDescriptor mBrowserDescriptor;
@Mock ConnectionBuilder mConnectionBuilder;
@Mock HttpURLConnection mHttpConnection;
@Mock PendingIntent mPendingIntent;
Expand All @@ -132,12 +134,13 @@ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mAuthCallback = new AuthorizationCallback();
mRegistrationCallback = new RegistrationCallback();
mBrowserDescriptor = Browsers.Chrome.customTab("46");
mService = new AuthorizationService(
mContext,
new Builder()
.setConnectionBuilder(mConnectionBuilder)
.build(),
Browsers.Chrome.customTab("46"),
mBrowserDescriptor,
mCustomTabManager);
mOutputStream = new ByteArrayOutputStream();
when(mConnectionBuilder.openConnection(any(Uri.class))).thenReturn(mHttpConnection);
Expand Down Expand Up @@ -397,6 +400,11 @@ public void testCreateCustomTabsIntentBuilder_afterDispose() throws Exception {
mService.createCustomTabsIntentBuilder();
}

@Test
public void testGetBrowserDescriptor_browserAvailable() {
assertEquals(mService.getBrowserDescriptor(), mBrowserDescriptor);
}

private Intent captureAuthRequestIntent() {
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(mContext).startActivity(intentCaptor.capture());
Expand Down