Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2613)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBarTest.java

Issue 2593393002: Add some integration tests for the search geolocation disclosure. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBarTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBarTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8fb7c358230c40dee6ce1c3fb3f4f783497f032e
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBarTest.java
@@ -0,0 +1,106 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.infobar;
+
+import android.support.test.filters.SmallTest;
+
+import org.chromium.base.test.util.CommandLineFlags;
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.SearchGeolocationDisclosureTabHelper;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.chrome.test.util.InfoBarTestAnimationListener;
+import org.chromium.net.test.EmbeddedTestServer;
+
+import java.util.concurrent.TimeoutException;
+
+/** Tests for the SearchGeolocationDisclosureInfobar. */
+public class SearchGeolocationDisclosureInfoBarTest
+ extends ChromeActivityTestCaseBase<ChromeActivity> {
+ private static final String SEARCH_PAGE = "/chrome/test/data/empty.html";
+ private static final String ENABLE_NEW_DISCLOSURE_FEATURE =
+ "enable-features=ConsistentOmniboxGeolocation";
+ private static final String DISABLE_NEW_DISCLOSURE_FEATURE =
+ "disable-features=ConsistentOmniboxGeolocation";
+
+ private EmbeddedTestServer mTestServer;
+
+ public SearchGeolocationDisclosureInfoBarTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mTestServer.stopAndDestroyServer();
+ super.tearDown();
+ }
+
+ @SmallTest
+ @Feature({"Browser", "Main"})
+ @CommandLineFlags.Add(ENABLE_NEW_DISCLOSURE_FEATURE)
+ public void testInfoBarAppears() throws InterruptedException, TimeoutException {
+ SearchGeolocationDisclosureTabHelper.setIgnoreUrlChecks(true);
+ assertEquals("Wrong starting infobar count", 0, getInfoBars().size());
+
+ InfoBarContainer container = getActivity().getActivityTab().getInfoBarContainer();
+ InfoBarTestAnimationListener listener = new InfoBarTestAnimationListener();
+ container.setAnimationListener(listener);
+ loadUrl(mTestServer.getURL(SEARCH_PAGE));
+ assertEquals("Wrong infobar count after search", 1, getInfoBars().size());
+ listener.addInfoBarAnimationFinished("InfoBar not added.");
+
+ SearchGeolocationDisclosureTabHelper.setIgnoreUrlChecks(false);
+ }
+
+ @SmallTest
+ @Feature({"Browser", "Main"})
+ @CommandLineFlags.Add(ENABLE_NEW_DISCLOSURE_FEATURE)
+ public void testNoInfoBarForRandomUrl() throws InterruptedException, TimeoutException {
+ assertEquals("Wrong starting infobar count", 0, getInfoBars().size());
+
+ loadUrl(mTestServer.getURL(SEARCH_PAGE));
+ assertEquals("Wrong infobar count after search", 0, getInfoBars().size());
+ }
+
+ @SmallTest
+ @Feature({"Browser", "Main"})
+ @CommandLineFlags.Add(ENABLE_NEW_DISCLOSURE_FEATURE)
+ public void testNoInfoBarInIncognito() throws InterruptedException, TimeoutException {
+ SearchGeolocationDisclosureTabHelper.setIgnoreUrlChecks(true);
+ newIncognitoTabFromMenu();
+ assertEquals("Wrong starting infobar count", 0, getInfoBars().size());
+
+ loadUrl(mTestServer.getURL(SEARCH_PAGE));
+ assertEquals("Wrong infobar count after search", 0, getInfoBars().size());
+
+ SearchGeolocationDisclosureTabHelper.setIgnoreUrlChecks(false);
+ }
+
+ @SmallTest
+ @Feature({"Browser", "Main"})
+ @CommandLineFlags.Add(DISABLE_NEW_DISCLOSURE_FEATURE)
+ public void testInfoBarAppearsDoesntAppearWithoutFeature()
+ throws InterruptedException, TimeoutException {
+ SearchGeolocationDisclosureTabHelper.setIgnoreUrlChecks(true);
+ assertEquals("Wrong starting infobar count", 0, getInfoBars().size());
+
+ loadUrl(mTestServer.getURL(SEARCH_PAGE));
+ assertEquals("Wrong infobar count after search", 0, getInfoBars().size());
+
+ SearchGeolocationDisclosureTabHelper.setIgnoreUrlChecks(false);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698