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");
}
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");
}
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();
}
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");
}
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());
}
}
Aggregations