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

Unified Diff: chrome/browser/net/chrome_network_delegate_unittest.cc

Issue 2715393002: Add tests for HttpRequestCompletionErrorCodes (Closed)
Patch Set: Add tests for HttpRequestCompletionErrorCodes Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/chrome_network_delegate_unittest.cc
diff --git a/chrome/browser/net/chrome_network_delegate_unittest.cc b/chrome/browser/net/chrome_network_delegate_unittest.cc
index edecbe6a5fb7ef84ffd2b5b6a3d2323ad5d8a7cb..8a08c72d5fb84e79059c66ec6190cad7d9f3ccef 100644
--- a/chrome/browser/net/chrome_network_delegate_unittest.cc
+++ b/chrome/browser/net/chrome_network_delegate_unittest.cc
@@ -235,6 +235,55 @@ TEST_F(ChromeNetworkDelegateTest, ReportOffTheRecordDataUseToAggregator) {
fake_aggregator.off_the_record_rx_bytes());
}
+TEST_F(ChromeNetworkDelegateTest, HttpRequestCompletionErrorCodes) {
+ Initialize();
+
+ const struct {
+ const GURL url;
+ int net_error;
+ bool is_main_frame;
+ int expected_sample_bucket;
+ int expected_request_completion_count;
+ int expected_request_completion_main_frame_count;
+ } kTests[] = {
+ {GURL("http://example.com"), net::OK, true, std::abs(net::OK), 1, 1},
+ {GURL("http://example.com"), net::ERR_ABORTED, true,
+ std::abs(net::ERR_ABORTED), 1, 1},
+ {GURL("http://example.com"), net::OK, false, std::abs(net::OK), 1, 0},
+ {GURL("https://example.com"), net::OK, true, std::abs(net::OK), 0, 0},
+ };
+
+ const char kHttpRequestCompletionErrorCode[] =
+ "Net.HttpRequestCompletionErrorCodes";
+ const char kHttpRequestCompletionErrorCodeMainFrame[] =
+ "Net.HttpRequestCompletionErrorCodes.MainFrame";
+
+ for (const auto& test : kTests) {
+ base::HistogramTester histograms;
+
+ net::TestDelegate test_delegate;
+ std::unique_ptr<net::URLRequest> request(context()->CreateRequest(
+ test.url, net::DEFAULT_PRIORITY, &test_delegate));
+ if (test.is_main_frame) {
+ request->SetLoadFlags(request->load_flags() |
+ net::LOAD_MAIN_FRAME_DEPRECATED);
+ }
+ network_delegate()->NotifyCompleted(request.get(), false, test.net_error);
+
+ histograms.ExpectTotalCount(kHttpRequestCompletionErrorCode,
+ test.expected_request_completion_count);
+ histograms.ExpectUniqueSample(kHttpRequestCompletionErrorCode,
+ test.expected_sample_bucket,
+ test.expected_request_completion_count);
+ histograms.ExpectTotalCount(
+ kHttpRequestCompletionErrorCodeMainFrame,
+ test.expected_request_completion_main_frame_count);
+ histograms.ExpectUniqueSample(
+ kHttpRequestCompletionErrorCodeMainFrame, test.expected_sample_bucket,
+ test.expected_request_completion_main_frame_count);
+ }
+}
+
class ChromeNetworkDelegatePolicyTest : public testing::Test {
public:
ChromeNetworkDelegatePolicyTest()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698