use of androidx.browser.customtabs.CustomTabsSessionToken in project android-browser-helper by GoogleChrome.
the class TwaLauncherTest method createsDifferentSessions_IfDifferentIdsSpecified.
@Test
public void createsDifferentSessions_IfDifferentIdsSpecified() {
int sessionId1 = 1;
int sessionId2 = 2;
TwaLauncher launcher1 = new TwaLauncher(mActivity, null, sessionId1, new SharedPreferencesTokenStore(mActivity));
CustomTabsSessionToken token1 = getSessionTokenFromLaunchedBrowser(() -> launcher1.launch(URL));
launcher1.destroy();
// New activity is created (e.g. by an external VIEW intent).
TwaLauncher launcher2 = new TwaLauncher(mActivity, null, sessionId2, new SharedPreferencesTokenStore(mActivity));
CustomTabsSessionToken token2 = getSessionTokenFromLaunchedBrowser(() -> launcher2.launch(URL));
launcher2.destroy();
assertNotEquals(token1, token2);
}
use of androidx.browser.customtabs.CustomTabsSessionToken in project android-browser-helper by GoogleChrome.
the class TwaQualityEnforcerTest method triggerQualityEnforcement_NoCrashReason.
@Test
public void triggerQualityEnforcement_NoCrashReason() {
Runnable launchRunnable = () -> mTwaLauncher.launch(new TrustedWebActivityIntentBuilder(URL), mCustomTabsCallback, null, null);
CustomTabsSessionToken token = CustomTabsSessionToken.getSessionTokenFromIntent(getBrowserActivityWhenLaunched(launchRunnable).getIntent());
CustomTabsCallback callback = token.getCallback();
Bundle args = Bundle.EMPTY;
Bundle result = callback.extraCallbackWithResult(QualityEnforcer.CRASH, args);
assertFalse(result.getBoolean(QualityEnforcer.KEY_SUCCESS));
}
use of androidx.browser.customtabs.CustomTabsSessionToken in project android-browser-helper by GoogleChrome.
the class TwaLauncherTest method reusesSessionForSubsequentLaunches.
@Test
public void reusesSessionForSubsequentLaunches() {
TwaLauncher launcher1 = new TwaLauncher(mActivity);
CustomTabsSessionToken token1 = getSessionTokenFromLaunchedBrowser(() -> launcher1.launch(URL));
launcher1.destroy();
// New activity is created (e.g. by an external VIEW intent).
TwaLauncher launcher2 = new TwaLauncher(mActivity);
CustomTabsSessionToken token2 = getSessionTokenFromLaunchedBrowser(() -> launcher2.launch(URL));
launcher2.destroy();
assertEquals(token1, token2);
}
use of androidx.browser.customtabs.CustomTabsSessionToken in project android-browser-helper by GoogleChrome.
the class TwaQualityEnforcerTest method triggerQualityEnforcement_Crash.
@Test
public void triggerQualityEnforcement_Crash() {
Runnable launchRunnable = () -> mTwaLauncher.launch(new TrustedWebActivityIntentBuilder(URL), mCustomTabsCallback, null, null);
CustomTabsSessionToken token = CustomTabsSessionToken.getSessionTokenFromIntent(getBrowserActivityWhenLaunched(launchRunnable).getIntent());
CustomTabsCallback callback = token.getCallback();
Bundle args = new Bundle();
String message = "TestMessage";
args.putString(QualityEnforcer.KEY_CRASH_REASON, message);
Bundle result = callback.extraCallbackWithResult(QualityEnforcer.CRASH, args);
assertTrue(result.getBoolean(QualityEnforcer.KEY_SUCCESS));
assertTrue(mCrashed);
}
Aggregations