diff options
author | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 17:36:07 +0000 |
---|---|---|
committer | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 17:36:07 +0000 |
commit | d4cee672ee3270ac4ecda47a69b8f1df0db3f8c5 (patch) | |
tree | 9468b06d3fff3b3145b9134148fefe2d1b70f4eb | |
parent | fe5a7d7f58362f754a5b25f0b05f5279d3ba6030 (diff) | |
download | chromium_src-d4cee672ee3270ac4ecda47a69b8f1df0db3f8c5.zip chromium_src-d4cee672ee3270ac4ecda47a69b8f1df0db3f8c5.tar.gz chromium_src-d4cee672ee3270ac4ecda47a69b8f1df0db3f8c5.tar.bz2 |
Try to fix GeolocationProviderTest flakiness
Make the GeolocationProviderTest family of tests wait until the
geolocation thread has finished cleaning up during teardown. This
should fix the flakines (*should*, not *will* because I am unable
to reproduce the flakiness myself...).
BUG=126421
TEST=content_unittest GeolocationProviderTest.*
Review URL: https://chromiumcodereview.appspot.com/10382036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136063 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/geolocation/geolocation_provider_unittest.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/content/browser/geolocation/geolocation_provider_unittest.cc b/content/browser/geolocation/geolocation_provider_unittest.cc index 9f141a8..8181b6d 100644 --- a/content/browser/geolocation/geolocation_provider_unittest.cc +++ b/content/browser/geolocation/geolocation_provider_unittest.cc @@ -164,6 +164,11 @@ class GeolocationProviderTest : public testing::Test { GeolocationArbitrator::SetDependencyFactoryForTest(NULL); } + void WaitAndReset() { + event_.Wait(); + event_.Reset(); + } + MessageLoop message_loop_; content::TestBrowserThread io_thread_; @@ -186,14 +191,13 @@ TEST_F(GeolocationProviderTest, StartStop) { provider_->AddObserver(&null_observer, options); EXPECT_TRUE(provider_->IsRunning()); // Wait for token load request from the arbitrator to come through. - event_.Wait(); + WaitAndReset(); - event_.Reset(); EXPECT_EQ(MockLocationProvider::instance_->state_, MockLocationProvider::LOW_ACCURACY); provider_->RemoveObserver(&null_observer); - // Wait for the providers to be stopped. - event_.Wait(); + // Wait for the providers to be stopped now that all clients are gone. + WaitAndReset(); EXPECT_TRUE(provider_->IsRunning()); } @@ -206,7 +210,12 @@ TEST_F(GeolocationProviderTest, OverrideLocationForTesting) { MockGeolocationObserver mock_observer; EXPECT_CALL(mock_observer, OnLocationUpdate(GeopositionEq(position))); provider_->AddObserver(&mock_observer, GeolocationObserverOptions()); + // Wait for token load request from the arbitrator to come through. + WaitAndReset(); + provider_->RemoveObserver(&mock_observer); + // Wait for the providers to be stopped now that all clients are gone. + WaitAndReset(); } TEST_F(GeolocationProviderTest, Callback) { @@ -214,6 +223,8 @@ TEST_F(GeolocationProviderTest, Callback) { provider_->RequestCallback( base::Bind(&MockGeolocationCallbackWrapper::Callback, base::Unretained(&callback_wrapper))); + // Wait for token load request from the arbitrator to come through. + WaitAndReset(); content::Geoposition position; position.latitude = 12; @@ -222,6 +233,8 @@ TEST_F(GeolocationProviderTest, Callback) { position.timestamp = base::Time::Now(); EXPECT_CALL(callback_wrapper, Callback(GeopositionEq(position))); provider_->OverrideLocationForTesting(position); + // Wait for the providers to be stopped now that all clients are gone. + WaitAndReset(); } } // namespace |