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

Unified Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc

Issue 1154623008: Fix the secure proxy check state displayed on net-internals#bandwidth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sclittle CR comment Created 5 years, 6 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/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc
index bd32412437b20981b87117033c4e22756d44aaab..b1616da12027f40c1301dfcbe612bbb0dd67cc3a 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc
@@ -42,6 +42,12 @@ class DataReductionProxyEventStoreTest : public testing::Test {
return entries[0];
}
+ net::TestNetLogEntry GetLatestEntry() const {
+ net::TestNetLogEntry::List entries;
+ net_log_->GetEntries(&entries);
+ return entries.back();
+ }
+
DataReductionProxyEventStore* event_store() { return event_store_.get(); }
DataReductionProxyEventCreator* event_creator() {
@@ -157,4 +163,47 @@ TEST_F(DataReductionProxyEventStoreTest, TestEndSecureProxyCheck) {
secure_proxy_check_state());
}
+TEST_F(DataReductionProxyEventStoreTest, TestEndSecureProxyCheckFailed) {
+ const struct {
+ const char* test_case;
+ int net_error;
+ int http_response_code;
+ bool secure_proxy_check_succeeded;
+ bool expected_proxy_check_succeeded;
+ } tests[] = {
+ {
+ "Succeeded", net::OK, net::HTTP_OK, true, true,
+ },
+ {
+ "Net failure", net::ERR_CONNECTION_RESET, -1, false, false,
+ },
+ {
+ "HTTP failure", net::OK, net::HTTP_NOT_FOUND, false, false,
+ },
+ {
+ "Bad content", net::OK, net::HTTP_OK, false, false,
+ },
+ };
+ size_t expected_event_count = 0;
+ EXPECT_EQ(expected_event_count, net_log()->GetSize());
+ EXPECT_EQ(expected_event_count++, event_count());
+ EXPECT_EQ(DataReductionProxyEventStorageDelegate::CHECK_UNKNOWN,
+ secure_proxy_check_state());
+ for (const auto& test : tests) {
+ event_creator()->EndSecureProxyCheck(bound_net_log(), test.net_error,
+ test.http_response_code,
+ test.secure_proxy_check_succeeded);
+ EXPECT_EQ(expected_event_count, net_log()->GetSize()) << test.test_case;
+ EXPECT_EQ(expected_event_count++, event_count()) << test.test_case;
+ net::TestNetLogEntry entry = GetLatestEntry();
+ EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_CANARY_REQUEST, entry.type)
+ << test.test_case;
+ EXPECT_EQ(test.secure_proxy_check_succeeded
+ ? DataReductionProxyEventStorageDelegate::CHECK_SUCCESS
+ : DataReductionProxyEventStorageDelegate::CHECK_FAILED,
+ secure_proxy_check_state())
+ << test.test_case;
+ }
+}
+
} // namespace data_reduction_proxy
« no previous file with comments | « components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698