diff options
author | alemate@chromium.org <alemate@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 18:31:32 +0000 |
---|---|---|
committer | alemate@chromium.org <alemate@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 18:31:32 +0000 |
commit | 8fafd871f30e987ed59ae54bc7f1147731d0ed75 (patch) | |
tree | 924ec741ebf5229f98d69fe0ed41445cd15c97c0 /chrome/browser/chromeos/geolocation | |
parent | 73f411cefc7a05c0e5968a87a2b1bda4d6e71bc5 (diff) | |
download | chromium_src-8fafd871f30e987ed59ae54bc7f1147731d0ed75.zip chromium_src-8fafd871f30e987ed59ae54bc7f1147731d0ed75.tar.gz chromium_src-8fafd871f30e987ed59ae54bc7f1147731d0ed75.tar.bz2 |
Reduce potential flakiness of SimpleGeolocationTest.
SimpleGeolocation unittest should less depend on timings.
BUG=245075
TEST=unittest
Review URL: https://codereview.chromium.org/296853009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/geolocation')
-rw-r--r-- | chrome/browser/chromeos/geolocation/simple_geolocation_unittest.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/geolocation/simple_geolocation_unittest.cc b/chrome/browser/chromeos/geolocation/simple_geolocation_unittest.cc index 0137c4b..01b4900 100644 --- a/chrome/browser/chromeos/geolocation/simple_geolocation_unittest.cc +++ b/chrome/browser/chromeos/geolocation/simple_geolocation_unittest.cc @@ -216,7 +216,12 @@ TEST_F(SimpleGeolocationTest, InvalidResponse) { &provider); GeolocationReceiver receiver; + const int timeout_seconds = 1; + size_t expected_retries = static_cast<size_t>( + timeout_seconds * 1000 / kRequestRetryIntervalMilliSeconds); + ASSERT_GE(expected_retries, 2U); + provider.RequestGeolocation(base::TimeDelta::FromSeconds(timeout_seconds), base::Bind(&GeolocationReceiver::OnRequestDone, base::Unretained(&receiver))); @@ -229,10 +234,19 @@ TEST_F(SimpleGeolocationTest, InvalidResponse) { "Unexpected token..', status=4 (TIMEOUT)", receiver.position().ToString()); EXPECT_TRUE(receiver.server_error()); - size_t expected_retries = static_cast<size_t>( - timeout_seconds * 1000 / kRequestRetryIntervalMilliSeconds); - EXPECT_LE(url_factory.attempts(), expected_retries + 1); - EXPECT_GE(url_factory.attempts(), expected_retries - 1); + EXPECT_GE(url_factory.attempts(), 2U); + if (url_factory.attempts() > expected_retries + 1) { + LOG(WARNING) + << "SimpleGeolocationTest::InvalidResponse: Too many attempts (" + << url_factory.attempts() << "), no more then " << expected_retries + 1 + << " expected."; + } + if (url_factory.attempts() < expected_retries - 1) { + LOG(WARNING) + << "SimpleGeolocationTest::InvalidResponse: Too little attempts (" + << url_factory.attempts() << "), greater then " << expected_retries - 1 + << " expected."; + } } } // namespace chromeos |