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

Side by Side Diff: chrome/browser/ssl/chrome_expect_ct_reporter_unittest.cc

Issue 2120683002: Fix up certificate error reporting histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 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/ssl/chrome_expect_ct_reporter.h" 5 #include "chrome/browser/ssl/chrome_expect_ct_reporter.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 net::GetTestCertsDirectory(), "localhost_cert.pem"); 392 net::GetTestCertsDirectory(), "localhost_cert.pem");
393 393
394 net::HostPortPair host_port("example.test", 443); 394 net::HostPortPair host_port("example.test", 443);
395 GURL report_uri( 395 GURL report_uri(
396 net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_FAILED)); 396 net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_FAILED));
397 397
398 SendReport(&reporter, host_port, report_uri, ssl_info); 398 SendReport(&reporter, host_port, report_uri, ssl_info);
399 399
400 histograms.ExpectTotalCount(kFailureHistogramName, 1); 400 histograms.ExpectTotalCount(kFailureHistogramName, 1);
401 histograms.ExpectBucketCount(kFailureHistogramName, 401 histograms.ExpectBucketCount(kFailureHistogramName,
402 net::ERR_CONNECTION_FAILED, 1); 402 -net::ERR_CONNECTION_FAILED, 1);
403 histograms.ExpectTotalCount(kSendHistogramName, 1); 403 histograms.ExpectTotalCount(kSendHistogramName, 1);
404 histograms.ExpectBucketCount(kSendHistogramName, true, 1); 404 histograms.ExpectBucketCount(kSendHistogramName, true, 1);
405 } 405 }
406 406
407 // Test that a sent report has the right format. 407 // Test that a sent report has the right format.
408 TEST(ChromeExpectCTReporterTest, SendReport) { 408 TEST(ChromeExpectCTReporterTest, SendReport) {
409 base::HistogramTester histograms; 409 base::HistogramTester histograms;
410 histograms.ExpectTotalCount(kFailureHistogramName, 0); 410 histograms.ExpectTotalCount(kFailureHistogramName, 0);
411 histograms.ExpectTotalCount(kSendHistogramName, 0); 411 histograms.ExpectTotalCount(kSendHistogramName, 0);
412 412
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 reporter.OnExpectCTFailed(host_port, report_uri, ssl_info); 463 reporter.OnExpectCTFailed(host_port, report_uri, ssl_info);
464 EXPECT_EQ(report_uri, sender->latest_report_uri()); 464 EXPECT_EQ(report_uri, sender->latest_report_uri());
465 EXPECT_FALSE(sender->latest_serialized_report().empty()); 465 EXPECT_FALSE(sender->latest_serialized_report().empty());
466 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( 466 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport(
467 sender->latest_serialized_report(), host_port, ssl_info)); 467 sender->latest_serialized_report(), host_port, ssl_info));
468 468
469 histograms.ExpectTotalCount(kFailureHistogramName, 0); 469 histograms.ExpectTotalCount(kFailureHistogramName, 0);
470 histograms.ExpectTotalCount(kSendHistogramName, 1); 470 histograms.ExpectTotalCount(kSendHistogramName, 1);
471 histograms.ExpectBucketCount(kSendHistogramName, true, 1); 471 histograms.ExpectBucketCount(kSendHistogramName, true, 1);
472 } 472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698