Commit d204dcc2 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add history testing code to VR navigation test

Checks browser history after navigating to two pages in the VR browser. Both
the VR browser and regular "2D" Chrome are supposed to share history, which
up until now was only tested manually.

Bug: 728779
Change-Id: I48b3c075e9a043c9a2fadb67e71e9080cb9f7e9b
Reviewed-on: https://chromium-review.googlesource.com/570120
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487209}
parent 9a8680d6
...@@ -589,6 +589,7 @@ if (enable_vr) { ...@@ -589,6 +589,7 @@ if (enable_vr) {
"//third_party/android_support_test_runner:rules_java", "//third_party/android_support_test_runner:rules_java",
"//third_party/android_support_test_runner:runner_java", "//third_party/android_support_test_runner:runner_java",
"//third_party/android_tools:android_support_v7_appcompat_java", "//third_party/android_tools:android_support_v7_appcompat_java",
"//third_party/android_tools:android_support_v7_recyclerview_java",
"//third_party/gvr-android-sdk:controller_test_api_java", "//third_party/gvr-android-sdk:controller_test_api_java",
"//third_party/gvr-android-sdk:gvr_common_java", "//third_party/gvr-android-sdk:gvr_common_java",
"//third_party/junit", "//third_party/junit",
......
...@@ -444,4 +444,9 @@ public class HistoryAdapter extends DateDividedAdapter implements BrowsingHistor ...@@ -444,4 +444,9 @@ public class HistoryAdapter extends DateDividedAdapter implements BrowsingHistor
ViewGroup getPrivacyDisclaimersForTests() { ViewGroup getPrivacyDisclaimersForTests() {
return mPrivacyDisclaimers; return mPrivacyDisclaimers;
} }
@VisibleForTesting
public ArrayList<HistoryItemView> getItemViewsForTests() {
return mItemViews;
}
} }
...@@ -381,7 +381,7 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser ...@@ -381,7 +381,7 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
} }
@VisibleForTesting @VisibleForTesting
HistoryAdapter getAdapterForTests() { public HistoryAdapter getAdapterForTests() {
return mHistoryAdapter; return mHistoryAdapter;
} }
......
...@@ -8,6 +8,7 @@ import android.app.Activity; ...@@ -8,6 +8,7 @@ import android.app.Activity;
import android.view.View; import android.view.View;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.BasicNativePage; import org.chromium.chrome.browser.BasicNativePage;
import org.chromium.chrome.browser.NativePageHost; import org.chromium.chrome.browser.NativePageHost;
...@@ -69,4 +70,9 @@ public class HistoryPage extends BasicNativePage { ...@@ -69,4 +70,9 @@ public class HistoryPage extends BasicNativePage {
public int getThemeColor() { public int getThemeColor() {
return mThemeColor; return mThemeColor;
} }
@VisibleForTesting
public HistoryManager getHistoryManagerForTesting() {
return mHistoryManager;
}
} }
...@@ -21,6 +21,8 @@ import org.junit.runner.RunWith; ...@@ -21,6 +21,8 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.history.HistoryItemView;
import org.chromium.chrome.browser.history.HistoryPage;
import org.chromium.chrome.browser.vr_shell.util.VrInfoBarUtils; import org.chromium.chrome.browser.vr_shell.util.VrInfoBarUtils;
import org.chromium.chrome.browser.vr_shell.util.VrTransitionUtils; import org.chromium.chrome.browser.vr_shell.util.VrTransitionUtils;
import org.chromium.chrome.test.ChromeActivityTestCaseBase; import org.chromium.chrome.test.ChromeActivityTestCaseBase;
...@@ -31,6 +33,7 @@ import org.chromium.content.browser.ContentViewCore; ...@@ -31,6 +33,7 @@ import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.DOMUtils; import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import java.util.ArrayList;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
...@@ -110,7 +113,8 @@ public class VrShellNavigationTest { ...@@ -110,7 +113,8 @@ public class VrShellNavigationTest {
} }
/** /**
* Tests navigation from a 2D to a 2D page. * Tests navigation from a 2D to a 2D page. Also tests that this navigation is
* properly added to Chrome's history.
*/ */
@Test @Test
@MediumTest @MediumTest
...@@ -121,6 +125,22 @@ public class VrShellNavigationTest { ...@@ -121,6 +125,22 @@ public class VrShellNavigationTest {
assertState(mVrTestRule.getFirstTabWebContents(), Page.PAGE_2D, assertState(mVrTestRule.getFirstTabWebContents(), Page.PAGE_2D,
PresentationMode.NON_PRESENTING, FullscreenMode.NON_FULLSCREENED); PresentationMode.NON_PRESENTING, FullscreenMode.NON_FULLSCREENED);
// Test that the navigations were added to history
VrTransitionUtils.forceExitVr();
mVrTestRule.loadUrl("chrome://history", PAGE_LOAD_TIMEOUT_S);
HistoryPage historyPage =
(HistoryPage) mVrTestRule.getActivity().getActivityTab().getNativePage();
ArrayList<HistoryItemView> itemViews = historyPage.getHistoryManagerForTesting()
.getAdapterForTests()
.getItemViewsForTests();
Assert.assertEquals("Two navigations showed up in history", 2, itemViews.size());
// History is in reverse chronological order, so the first navigation should actually be
// after the second in the list
Assert.assertEquals("First navigation is correct", TEST_PAGE_2D_URL,
itemViews.get(1).getItem().getUrl());
Assert.assertEquals("Second navigation is correct", getUrl(Page.PAGE_2D),
itemViews.get(0).getItem().getUrl());
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment