diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:47:56 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:47:56 +0000 |
commit | 02a5fe29729b8230764a17651ac646f96d680b74 (patch) | |
tree | 039157bd1ce8d9a1e51e33edb37ab399f591a4ff /chrome/browser/geolocation | |
parent | b9f22d1e6fb76de05b9bb8a361bae8c7a58ed656 (diff) | |
download | chromium_src-02a5fe29729b8230764a17651ac646f96d680b74.zip chromium_src-02a5fe29729b8230764a17651ac646f96d680b74.tar.gz chromium_src-02a5fe29729b8230764a17651ac646f96d680b74.tar.bz2 |
Geolocation support for chromedriver, browser-side only.
BUG=chromedriver:14
TEST=none
Review URL: http://codereview.chromium.org/10070012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133988 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
-rw-r--r-- | chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/geolocation/geolocation_browsertest.cc | 44 |
2 files changed, 20 insertions, 30 deletions
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index 5ae6f87..9bbbee4 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -23,7 +23,6 @@ #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/web_contents.h" -#include "content/test/mock_geolocation.h" #include "content/test/mock_render_process_host.h" #include "content/test/test_browser_thread.h" #include "content/test/test_renderer_host.h" @@ -141,7 +140,6 @@ class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness { virtual void TearDown() OVERRIDE; content::TestBrowserThread ui_thread_; - content::MockGeolocation mock_geolocation_; // A map between renderer child id and a pair represending the bridge id and // whether the requested permission was allowed. @@ -231,14 +229,12 @@ void GeolocationPermissionContextTests::CheckTabContentsState( void GeolocationPermissionContextTests::SetUp() { TabContentsWrapperTestHarness::SetUp(); - mock_geolocation_.Setup(); geolocation_permission_context_ = new ChromeGeolocationPermissionContext(profile()); } void GeolocationPermissionContextTests::TearDown() { extra_tabs_.reset(); - mock_geolocation_.TearDown(); TabContentsWrapperTestHarness::TearDown(); } @@ -603,5 +599,3 @@ TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) { DeleteContents(); infobar_0->InfoBarClosed(); } - - diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index 4dbb890..a53ade3 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -29,7 +29,6 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" -#include "content/test/mock_geolocation.h" #include "net/base/net_util.h" #include "net/test/test_server.h" @@ -205,19 +204,20 @@ class GeolocationBrowserTest : public InProcessBrowserTest { : infobar_(NULL), current_browser_(NULL), html_for_tests_("files/geolocation/simple.html"), + fake_latitude_(1.23), + fake_longitude_(4.56), started_test_server_(false) { EnableDOMAutomation(); } // InProcessBrowserTest - virtual void SetUpInProcessBrowserTestFixture() { - mock_geolocation_.Setup(); + virtual void SetUpOnMainThread() { + ui_test_utils::OverrideGeolocation(fake_latitude_, fake_longitude_); } // InProcessBrowserTest virtual void TearDownInProcessBrowserTestFixture() { LOG(WARNING) << "TearDownInProcessBrowserTestFixture. Test Finished."; - mock_geolocation_.TearDown(); } enum InitializationOptions { @@ -290,12 +290,6 @@ class GeolocationBrowserTest : public InProcessBrowserTest { "geoGetLastPositionLongitude()"); } - void CheckGeopositionEqualsMock() { - double latitude, longitude; - mock_geolocation_.GetCurrentPosition(&latitude, &longitude); - CheckGeoposition(latitude, longitude); - } - void SetInfobarResponse(const GURL& requesting_url, bool allowed) { TabContentsWrapper* tab_contents_wrapper = current_browser_->GetSelectedTabContentsWrapper(); @@ -349,7 +343,9 @@ class GeolocationBrowserTest : public InProcessBrowserTest { } void NotifyGeoposition(double latitude, double longitude) { - mock_geolocation_.SetCurrentPosition(latitude, longitude); + fake_latitude_ = latitude; + fake_longitude_ = longitude; + ui_test_utils::OverrideGeolocation(latitude, longitude); LOG(WARNING) << "MockLocationProvider listeners updated"; } @@ -364,11 +360,11 @@ class GeolocationBrowserTest : public InProcessBrowserTest { GURL current_url_; // If not empty, the GURLs for the iframes loaded by LoadIFrames(). std::vector<GURL> iframe_urls_; + double fake_latitude_; + double fake_longitude_; // TODO(phajdan.jr): Remove after we can ask TestServer whether it is started. bool started_test_server_; - - content::MockGeolocation mock_geolocation_; }; IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DisplaysPermissionBar) { @@ -380,7 +376,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, Geoposition) { ASSERT_TRUE(Initialize(INITIALIZATION_NONE)); AddGeolocationWatch(true); SetInfobarResponse(current_url_, true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); } // Crashy, http://crbug.com/70585. @@ -409,7 +405,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForSecondTab) { // Checks infobar will not be created a second tab. ASSERT_TRUE(Initialize(INITIALIZATION_NEWTAB)); AddGeolocationWatch(false); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); } // http://crbug.com/44589. Hangs on Mac, crashes on Windows @@ -451,7 +447,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, MAYBE_NoInfobarForAllowedOrigin) CONTENT_SETTING_ALLOW); // Checks no infobar will be created and there's no error callback. AddGeolocationWatch(false); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); } IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForOffTheRecord) { @@ -460,13 +456,13 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, NoInfobarForOffTheRecord) { AddGeolocationWatch(true); // Response will be persisted SetInfobarResponse(current_url_, true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); // Disables further prompts from this tab. CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); // Go incognito, and checks no infobar will be created. ASSERT_TRUE(Initialize(INITIALIZATION_OFFTHERECORD)); AddGeolocationWatch(false); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); } // Test fails: http://crbug.com/90927 @@ -480,7 +476,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, iframe_xpath_ = L"//iframe[@id='iframe_0']"; AddGeolocationWatch(true); SetInfobarResponse(iframe_urls_[0], true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); // Disables further prompts from this iframe. CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); @@ -524,7 +520,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, iframe_xpath_ = L"//iframe[@id='iframe_0']"; AddGeolocationWatch(true); SetInfobarResponse(iframe_urls_[0], true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); // Refresh geoposition, but let's not yet create the watch on the second frame // so that it'll fetch from cache. @@ -563,7 +559,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, iframe_xpath_ = L"//iframe[@id='iframe_0']"; AddGeolocationWatch(true); SetInfobarResponse(iframe_urls_[0], true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); // Disables further prompts from this iframe. CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); @@ -607,14 +603,14 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_NoInfoBarBeforeStart) { iframe_xpath_ = L"//iframe[@id='iframe_0']"; AddGeolocationWatch(true); SetInfobarResponse(iframe_urls_[0], true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); CheckStringValueFromJavascript("0", "geoSetMaxNavigateCount(0)"); // Permission should be requested after adding a watch. iframe_xpath_ = L"//iframe[@id='iframe_1']"; AddGeolocationWatch(true); SetInfobarResponse(iframe_urls_[1], true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); } IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TwoWatchesInOneFrame) { @@ -635,7 +631,7 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, TwoWatchesInOneFrame) { // Send a position which both geolocation watches will receive. AddGeolocationWatch(true); SetInfobarResponse(current_url_, true); - CheckGeopositionEqualsMock(); + CheckGeoposition(fake_latitude_, fake_longitude_); // The second watch will now have cancelled. Ensure an update still makes // its way through to the first watcher. |