Search in sources :

Example 11 with WebBackForwardList

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

the class ShadowWebViewTest method shouldReturnHistoryFromSaveState.

@Test
public void shouldReturnHistoryFromSaveState() {
    shadowOf(webView).pushEntryToHistory("foo1.bar");
    shadowOf(webView).pushEntryToHistory("foo2.bar");
    Bundle outState = new Bundle();
    WebBackForwardList historyList = webView.saveState(outState);
    assertThat(historyList.getSize()).isEqualTo(2);
    assertThat(historyList.getCurrentItem().getUrl()).isEqualTo("foo2.bar");
}
Also used : Bundle(android.os.Bundle) WebBackForwardList(android.webkit.WebBackForwardList) Test(org.junit.Test)

Example 12 with WebBackForwardList

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

the class ShadowWebViewTest method shouldCopyBackForwardListWhenEmpty.

@Test
public void shouldCopyBackForwardListWhenEmpty() {
    WebBackForwardList historyList = webView.copyBackForwardList();
    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 13 with WebBackForwardList

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

the class ShadowWebViewTest method shouldReturnNullFromRestoreStateIfNoHistoryAvailable.

@Test
public void shouldReturnNullFromRestoreStateIfNoHistoryAvailable() {
    Bundle inState = new Bundle();
    WebBackForwardList historyList = webView.restoreState(inState);
    assertThat(historyList).isNull();
}
Also used : Bundle(android.os.Bundle) WebBackForwardList(android.webkit.WebBackForwardList) Test(org.junit.Test)

Example 14 with WebBackForwardList

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

the class ShadowWebViewTest method shouldSaveAndRestoreHistoryList.

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

Example 15 with WebBackForwardList

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

the class ShadowWebViewTest method shouldCopyBackForwardListWhenPopulated.

@Test
public void shouldCopyBackForwardListWhenPopulated() {
    shadowOf(webView).pushEntryToHistory("foo1.bar");
    shadowOf(webView).pushEntryToHistory("foo2.bar");
    WebBackForwardList historyList = webView.copyBackForwardList();
    assertThat(historyList.getSize()).isEqualTo(2);
    assertThat(historyList.getCurrentItem().getUrl()).isEqualTo("foo2.bar");
}
Also used : WebBackForwardList(android.webkit.WebBackForwardList) Test(org.junit.Test)

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