Commit 8fafd871 authored by alemate@chromium.org's avatar alemate@chromium.org

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
parent 73f411ce
......@@ -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
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