use of org.mozilla.rocket.tabs.SessionManager in project Rocket by mozilla-tw.
the class PrivateWebContextMenu method openInNewTab.
private static void openInNewTab(final TabView source, final Dialog dialog, final String url) {
final SessionManager session = TabsSessionProvider.getOrThrow(dialog.getOwnerActivity());
final List<Session> tabs = session.getTabs();
String parentId = null;
// Try to find parent tab for new tab
for (final Session tab : tabs) {
if (tab.getEngineSession().getTabView() == source) {
parentId = tab.getId();
break;
}
}
Bundle args = TabUtil.argument(parentId, false, false);
args.putInt(BrowserFragment.EXTRA_NEW_TAB_SRC, BrowserFragment.SRC_CONTEXT_MENU);
session.addTab(url, args);
TelemetryWrapper.addNewTabFromContextMenu();
}
use of org.mozilla.rocket.tabs.SessionManager in project Rocket by mozilla-tw.
the class BrowsingIntentTest method appHasOneTabAndReceiveBrowsingIntent_tabIncreasedAndBrowse.
@Test
public void appHasOneTabAndReceiveBrowsingIntent_tabIncreasedAndBrowse() {
// Launch activity
activityTestRule.launchActivity(new Intent());
// Click search field
onView(withId(R.id.home_fragment_fake_input)).perform(click());
loadingIdlingResource = new SessionLoadedIdlingResource(activityTestRule.getActivity());
// Browsing site 2
onView(allOf(withId(R.id.url_edit), isDisplayed())).perform(replaceText(TARGET_URL_SITE_2), pressImeActionButton());
IdlingRegistry.getInstance().register(loadingIdlingResource);
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_2)));
SessionManager sessionManager = TabsSessionProvider.getOrThrow(activityTestRule.getActivity());
final int tabCount = sessionManager.getTabsCount();
// Receive browsing intent
sendBrowsingIntent();
// Check if browser fragment is launched
onView(withId(R.id.display_url)).check(matches(isDisplayed()));
// Check if target url is resolved and site 1 is loaded
onView(withId(R.id.display_url)).check(matches(isDisplayed())).check(matches(withText(TARGET_URL_SITE_1)));
IdlingRegistry.getInstance().unregister(loadingIdlingResource);
// Check if tab count is increased
sessionManager = TabsSessionProvider.getOrThrow(activityTestRule.getActivity());
Assert.assertTrue(sessionManager.getTabsCount() == tabCount + 1);
}
use of org.mozilla.rocket.tabs.SessionManager in project Rocket by mozilla-tw.
the class WebContextMenu method openInNewTab.
private static void openInNewTab(final TabView source, final Dialog dialog, final String url) {
final SessionManager session = TabsSessionProvider.getOrThrow(dialog.getOwnerActivity());
final List<Session> tabs = session.getTabs();
String parentId = null;
// Try to find parent tab for new tab
for (final Session tab : tabs) {
if (tab.getEngineSession().getTabView() == source) {
parentId = tab.getId();
break;
}
}
Bundle args = TabUtil.argument(parentId, false, false);
args.putInt(BrowserFragment.EXTRA_NEW_TAB_SRC, BrowserFragment.SRC_CONTEXT_MENU);
session.addTab(url, args);
TelemetryWrapper.addNewTabFromContextMenu();
}
Aggregations