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

Unified Diff: components/policy/core/common/cloud/device_management_service_unittest.cc

Issue 2285233002: Don't retry fetching policies if it's a blocking operation, don't wait if we will bypass the proxy … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months 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
« no previous file with comments | « components/policy/core/common/cloud/device_management_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/cloud/device_management_service_unittest.cc
diff --git a/components/policy/core/common/cloud/device_management_service_unittest.cc b/components/policy/core/common/cloud/device_management_service_unittest.cc
index 6da74eef1657c286d73b6a5a761d10299f3e10e7..10b9a5bf926da329a92f2652cd829f773e302094 100644
--- a/components/policy/core/common/cloud/device_management_service_unittest.cc
+++ b/components/policy/core/common/cloud/device_management_service_unittest.cc
@@ -683,6 +683,38 @@ TEST_F(DeviceManagementServiceTest, RetryOnNetworkChanges) {
EXPECT_EQ(net::URLRequestStatus::SUCCESS, fetcher->GetStatus().status());
}
+TEST_F(DeviceManagementServiceTest, PolicyFetchRetryImmediately) {
+ // We must not wait before a policy fetch retry, so this must not time out.
+ policy::DeviceManagementService::SetRetryDelayForTesting(60000);
+
+ // Make a request.
+ EXPECT_CALL(*this, OnJobDone(_, _, _)).Times(0);
+ EXPECT_CALL(*this, OnJobRetry(_));
+
+ std::unique_ptr<DeviceManagementRequestJob> request_job(
+ StartPolicyFetchJob());
+ net::TestURLFetcher* fetcher = GetFetcher();
+ ASSERT_TRUE(fetcher);
+ const GURL original_url(fetcher->GetOriginalURL());
+ const std::string original_upload_data(fetcher->upload_data());
+
+ // Make it fail with ERR_NETWORK_CHANGED.
+ fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::FAILED,
+ net::ERR_NETWORK_CHANGED));
+ fetcher->set_url(GURL(kServiceUrl));
+ fetcher->delegate()->OnURLFetchComplete(fetcher);
+ base::RunLoop().RunUntilIdle();
+
+ // Verify that a new URLFetcher was started that retries this job, after
+ // having called OnJobRetry.
+ Mock::VerifyAndClearExpectations(this);
+ fetcher = GetFetcher();
+ ASSERT_TRUE(fetcher);
+ EXPECT_EQ(original_url, fetcher->GetOriginalURL());
+ EXPECT_EQ(original_upload_data, fetcher->upload_data());
+ EXPECT_EQ(net::URLRequestStatus::SUCCESS, fetcher->GetStatus().status());
+}
+
TEST_F(DeviceManagementServiceTest, RetryLimit) {
std::unique_ptr<DeviceManagementRequestJob> request_job(
StartRegistrationJob());
« no previous file with comments | « components/policy/core/common/cloud/device_management_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698