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

Side by Side Diff: chrome/browser/safe_browsing/certificate_reporting_service_test_utils.cc

Issue 2503243003: Wire up CertificateReportingService to handle report uploads (Closed)
Patch Set: Rebase onto crrev/2543523002 Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils. h" 5 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils. h"
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/test/test_utils.h" 9 #include "content/public/test/test_utils.h"
10 #include "net/test/url_request/url_request_failed_job.h" 10 #include "net/test/url_request/url_request_failed_job.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 expected_report_result) { 198 expected_report_result) {
199 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 199 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
200 url_request_interceptor_->SetFailureMode(expected_report_result); 200 url_request_interceptor_->SetFailureMode(expected_report_result);
201 } 201 }
202 202
203 void CertificateReportingServiceTestBase::ResumeDelayedRequest() { 203 void CertificateReportingServiceTestBase::ResumeDelayedRequest() {
204 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 204 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
205 url_request_interceptor_->Resume(); 205 url_request_interceptor_->Resume();
206 } 206 }
207 207
208 void CertificateReportingServiceTestBase::CheckExpectedResults(
209 const ReportEventObserver& observer,
210 ObservedReportEvent expected_observed_event,
211 const std::set<int>& expected_successful_report_ids,
212 const std::set<int>& expected_failed_report_ids) {
213 switch (expected_observed_event) {
214 case EXPECT_NONE:
215 EXPECT_EQ(0u, observer.num_completed_attempts());
216 EXPECT_EQ(0u, observer.num_cancelled_attempts());
217 EXPECT_EQ(0u, observer.num_resets());
218 break;
219
220 case EXPECT_SEND_ATTEMPT_COMPLETED:
221 EXPECT_EQ(1u, observer.num_completed_attempts());
222 EXPECT_EQ(0u, observer.num_cancelled_attempts());
223 EXPECT_EQ(0u, observer.num_resets());
224 break;
225
226 case EXPECT_SEND_ATTEMPT_CANCELLED:
227 EXPECT_EQ(0u, observer.num_completed_attempts());
228 EXPECT_EQ(1u, observer.num_cancelled_attempts());
229 EXPECT_EQ(0u, observer.num_resets());
230 break;
231
232 case EXPECT_SERVICE_RESET:
233 EXPECT_EQ(0u, observer.num_completed_attempts());
234 EXPECT_EQ(0u, observer.num_cancelled_attempts());
235 EXPECT_EQ(1u, observer.num_resets());
236 break;
237 }
238 EXPECT_EQ(expected_successful_report_ids, observer.successful_report_ids());
239 EXPECT_EQ(expected_failed_report_ids, observer.failed_report_ids());
240 }
241
208 } // namespace certificate_reporting_test_utils 242 } // namespace certificate_reporting_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698