Search in sources :

Example 1 with WebBackForwardList

use of android.webkit.WebBackForwardList in project robolectric by robolectric.

the class ShadowWebViewTest method shouldNotPushEntryFromLoadUrlToHistoryUntilRequested.

@Test
public void shouldNotPushEntryFromLoadUrlToHistoryUntilRequested() {
    webView.loadUrl("foo1.bar");
    assertThat(webView.getUrl()).isEqualTo("foo1.bar");
    WebBackForwardList history = webView.copyBackForwardList();
    assertThat(history.getSize()).isEqualTo(0);
    shadowOf(webView).pushEntryToHistory("foo1.bar");
    history = webView.copyBackForwardList();
    assertThat(history.getSize()).isEqualTo(1);
    assertThat(history.getItemAtIndex(0).getUrl()).isEqualTo("foo1.bar");
}
Also used : WebBackForwardList(android.webkit.WebBackForwardList) Test(org.junit.Test)

Example 2 with WebBackForwardList

use of android.webkit.WebBackForwardList in project robolectric by robolectric.

the class ShadowWebViewTest method shouldNotPushEntryFromLoadDataWithBaseUrlToHistoryUntilRequested.

@Test
public void shouldNotPushEntryFromLoadDataWithBaseUrlToHistoryUntilRequested() {
    webView.loadDataWithBaseURL("foo1.bar", "data", "mime", "encoding", "foo1.bar");
    assertThat(webView.getUrl()).isEqualTo("foo1.bar");
    WebBackForwardList history = webView.copyBackForwardList();
    assertThat(history.getSize()).isEqualTo(0);
    shadowOf(webView).pushEntryToHistory("foo1.bar");
    history = webView.copyBackForwardList();
    assertThat(history.getSize()).isEqualTo(1);
    assertThat(history.getItemAtIndex(0).getUrl()).isEqualTo("foo1.bar");
}
Also used : WebBackForwardList(android.webkit.WebBackForwardList) Test(org.junit.Test)

Example 3 with WebBackForwardList

use of android.webkit.WebBackForwardList in project robolectric by robolectric.

the class ShadowWebViewTest method shouldReturnCopyFromCopyBackForwardList.

@Test
public void shouldReturnCopyFromCopyBackForwardList() {
    WebBackForwardList historyList = webView.copyBackForwardList();
    // Adding history after copying should not affect the copy.
    shadowOf(webView).pushEntryToHistory("foo1.bar");
    shadowOf(webView).pushEntryToHistory("foo2.bar");
    assertThat(historyList.getSize()).isEqualTo(0);
    assertThat(historyList.getCurrentIndex()).isEqualTo(-1);
    assertThat(historyList.getCurrentItem()).isNull();
}
Also used : WebBackForwardList(android.webkit.WebBackForwardList) Test(org.junit.Test)

Example 4 with WebBackForwardList

use of android.webkit.WebBackForwardList in project robolectric by robolectric.

the class ShadowWebViewTest method shouldSaveAndRestoreHistoryList_goBack.

@Test
public void shouldSaveAndRestoreHistoryList_goBack() {
    shadowOf(webView).pushEntryToHistory("foo1.bar");
    shadowOf(webView).pushEntryToHistory("foo2.bar");
    webView.goBack();
    Bundle outState = new Bundle();
    webView.saveState(outState);
    WebView newWebView = new WebView(ApplicationProvider.getApplicationContext());
    WebBackForwardList historyList = newWebView.restoreState(outState);
    assertThat(newWebView.canGoBack()).isFalse();
    assertThat(newWebView.canGoForward()).isTrue();
    assertThat(newWebView.getUrl()).isEqualTo("foo1.bar");
    assertThat(historyList.getSize()).isEqualTo(2);
    assertThat(historyList.getCurrentItem().getUrl()).isEqualTo("foo1.bar");
}
Also used : Bundle(android.os.Bundle) WebView(android.webkit.WebView) WebBackForwardList(android.webkit.WebBackForwardList) Test(org.junit.Test)

Example 5 with WebBackForwardList

use of android.webkit.WebBackForwardList in project newsrob by marianokamp.

the class ShowArticleActivity method dumpHistory.

private void dumpHistory() {
    if (false) {
        WebBackForwardList history = webView.copyBackForwardList();
        for (int i = 0, lim = history.getSize(); i < lim; i++) {
            WebHistoryItem hi = history.getItemAtIndex(i);
            System.out.println("XXX" + i + "    url = " + hi.getUrl() + " originalUrl=" + hi.getOriginalUrl());
        }
        System.out.println("XXX current url=" + selectedEntry.getAlternateHRef());
    }
}
Also used : WebHistoryItem(android.webkit.WebHistoryItem) WebBackForwardList(android.webkit.WebBackForwardList)

Aggregations

WebBackForwardList (android.webkit.WebBackForwardList)19 Test (org.junit.Test)10 WebHistoryItem (android.webkit.WebHistoryItem)7 Bundle (android.os.Bundle)6 WebView (android.webkit.WebView)5 SuppressLint (android.annotation.SuppressLint)2 TabView (org.mozilla.focus.tabs.TabView)2