Search in sources :

Example 1 with SessionManager

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();
}
Also used : SessionManager(org.mozilla.rocket.tabs.SessionManager) Bundle(android.os.Bundle) Session(org.mozilla.rocket.tabs.Session)

Example 2 with SessionManager

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);
}
Also used : SessionManager(org.mozilla.rocket.tabs.SessionManager) SessionLoadedIdlingResource(org.mozilla.focus.helper.SessionLoadedIdlingResource) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with SessionManager

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();
}
Also used : SessionManager(org.mozilla.rocket.tabs.SessionManager) Bundle(android.os.Bundle) Session(org.mozilla.rocket.tabs.Session)

Aggregations

SessionManager (org.mozilla.rocket.tabs.SessionManager)3 Bundle (android.os.Bundle)2 Session (org.mozilla.rocket.tabs.Session)2 Intent (android.content.Intent)1 Test (org.junit.Test)1 SessionLoadedIdlingResource (org.mozilla.focus.helper.SessionLoadedIdlingResource)1