import org.chromium.content.browser.NavigationEntry;
import org.chromium.content.browser.NavigationHistory;
import org.chromium.net.test.util.TestWebServer;
-import org.xwalk.core.xwview.test.util.CommonResources;
-import org.xwalk.core.XWalkClient;
-import org.xwalk.core.XWalkContent;
+
+import org.xwalk.core.XWalkNavigationHistory;
import org.xwalk.core.XWalkView;
+import org.xwalk.core.internal.XWalkClient;
+import org.xwalk.core.xwview.test.util.CommonResources;
import java.util.concurrent.Callable;
private String mUrls[];
private XWalkView mXWalkView;
private XWalkView mRestoreXWalkView;
- private XWalkContent mXWalkContent;
@Override
public void setUp() throws Exception {
mXWalkView = getXWalkView();
mRestoreXWalkView = new XWalkView(activity, activity);
mXWalkView.setXWalkClient(new XWalkViewTestBase.TestXWalkClient());
- mXWalkContent = mXWalkView.getXWalkViewContentForTest();
}
});
}
}
- private NavigationHistory getNavigationHistoryOnUiThread(
- final XWalkContent content) throws Throwable{
- return runTestOnUiThreadAndGetResult(new Callable<NavigationHistory>() {
+ private XWalkNavigationHistory getNavigationHistoryOnUiThread(
+ final XWalkView content) throws Throwable{
+ return runTestOnUiThreadAndGetResult(new Callable<XWalkNavigationHistory>() {
@Override
- public NavigationHistory call() throws Exception {
- return content.getContentViewCoreForTest().getNavigationHistory();
+ public XWalkNavigationHistory call() throws Exception {
+ return content.getNavigationHistory();
}
});
}
- private void checkHistoryItemList(XWalkContent content) throws Throwable {
- NavigationHistory history = getNavigationHistoryOnUiThread(content);
- assertEquals(NUM_NAVIGATIONS, history.getEntryCount());
- assertEquals(NUM_NAVIGATIONS - 1, history.getCurrentEntryIndex());
+ private void checkHistoryItemList(XWalkView content) throws Throwable {
+ XWalkNavigationHistory history = getNavigationHistoryOnUiThread(content);
+ assertEquals(NUM_NAVIGATIONS, history.size());
+ assertEquals(NUM_NAVIGATIONS - 1, history.getCurrentIndex());
// Note this is not meant to be a thorough test of NavigationHistory,
// but is only meant to test enough to make sure state is restored.
// See NavigationHistoryTest for more thorough tests.
for (int i = 0; i < NUM_NAVIGATIONS; ++i) {
- assertEquals(mUrls[i], history.getEntryAtIndex(i).getOriginalUrl());
- assertEquals(mUrls[i], history.getEntryAtIndex(i).getUrl());
- assertEquals(TITLES[i], history.getEntryAtIndex(i).getTitle());
+ assertEquals(mUrls[i], history.getItemAt(i).getOriginalUrl());
+ assertEquals(mUrls[i], history.getItemAt(i).getUrl());
+ assertEquals(TITLES[i], history.getItemAt(i).getTitle());
}
}
@Override
public Boolean call() throws Exception {
// TODO(hengzhi): add the judge about updated title.
- return TITLES[0].equals(mXWalkContent.getContentViewCoreForTest().getTitle());
+ return TITLES[0].equals(mXWalkView.getTitle());
}
}));
}
public void testSaveRestoreStateWithHistoryItemList() throws Throwable {
setServerResponseAndLoad(NUM_NAVIGATIONS);
saveAndRestoreStateOnUiThread();
- checkHistoryItemList(mRestoreXWalkView.getXWalkViewContentForTest());
+ checkHistoryItemList(mRestoreXWalkView);
}
@SmallTest
@Feature({"SaveRestoreState"})
public void testRestoreFromInvalidStateFails() throws Throwable {
final Bundle invalidState = new Bundle();
- invalidState.putByteArray(mXWalkContent.SAVE_RESTORE_STATE_KEY,
+ // TODO(yongsheng): how to share this with
+ // XWalkContent.SAVE_RESTORE_STATE_KEY?
+ invalidState.putByteArray("XWALKVIEW_STATE",
"invalid state".getBytes());
boolean result = runTestOnUiThreadAndGetResult(new Callable<Boolean>() {
@Override