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

Side by Side Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc

Issue 1084533002: Rename NetLogLogger and CapturingNetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename NetLogLogger and CapturingNetLog(removed compiler error for chromeOS) Created 5 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/data_reduction_proxy/core/common/data_reduction_proxy_event _store.h" 5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event _store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/test/test_simple_task_runner.h" 11 #include "base/test/test_simple_task_runner.h"
12 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h" 12 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h"
13 #include "net/log/capturing_net_log.h"
14 #include "net/log/net_log.h" 13 #include "net/log/net_log.h"
14 #include "net/log/test_net_log.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace data_reduction_proxy { 17 namespace data_reduction_proxy {
18 18
19 class DataReductionProxyEventStoreTest : public testing::Test { 19 class DataReductionProxyEventStoreTest : public testing::Test {
20 public: 20 public:
21 DataReductionProxyEventStoreTest() 21 DataReductionProxyEventStoreTest()
22 : task_runner_(scoped_refptr<base::TestSimpleTaskRunner>( 22 : task_runner_(scoped_refptr<base::TestSimpleTaskRunner>(
23 new base::TestSimpleTaskRunner())), 23 new base::TestSimpleTaskRunner())),
24 net_log_(new net::CapturingNetLog()) { 24 net_log_(new net::TestNetLog()) {
25 bound_net_log_ = net::BoundNetLog::Make( 25 bound_net_log_ = net::BoundNetLog::Make(
26 net_log_.get(), net::NetLog::SOURCE_DATA_REDUCTION_PROXY); 26 net_log_.get(), net::NetLog::SOURCE_DATA_REDUCTION_PROXY);
27 } 27 }
28 28
29 void SetUp() override { 29 void SetUp() override {
30 proxy_.reset(new DataReductionProxyEventStore(task_runner_)); 30 proxy_.reset(new DataReductionProxyEventStore(task_runner_));
31 } 31 }
32 32
33 net::CapturingNetLog::CapturedEntry GetSingleEntry() const { 33 net::TestNetLog::CapturedEntry GetSingleEntry() const {
34 net::CapturingNetLog::CapturedEntryList entries; 34 net::TestNetLog::CapturedEntryList entries;
35 net_log_->GetEntries(&entries); 35 net_log_->GetEntries(&entries);
36 EXPECT_EQ(1u, entries.size()); 36 EXPECT_EQ(1u, entries.size());
37 return entries[0]; 37 return entries[0];
38 } 38 }
39 39
40 DataReductionProxyEventStore* proxy() { 40 DataReductionProxyEventStore* proxy() {
41 return proxy_.get(); 41 return proxy_.get();
42 } 42 }
43 43
44 base::TestSimpleTaskRunner* task_runner() { 44 base::TestSimpleTaskRunner* task_runner() {
45 return task_runner_.get(); 45 return task_runner_.get();
46 } 46 }
47 47
48 net::CapturingNetLog* net_log() { 48 net::TestNetLog* net_log() { return net_log_.get(); }
49 return net_log_.get();
50 }
51 49
52 const net::BoundNetLog& bound_net_log() { 50 const net::BoundNetLog& bound_net_log() {
53 return bound_net_log_; 51 return bound_net_log_;
54 } 52 }
55 53
56 private: 54 private:
57 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 55 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
58 scoped_ptr<net::CapturingNetLog> net_log_; 56 scoped_ptr<net::TestNetLog> net_log_;
59 scoped_ptr<DataReductionProxyEventStore> proxy_; 57 scoped_ptr<DataReductionProxyEventStore> proxy_;
60 net::BoundNetLog bound_net_log_; 58 net::BoundNetLog bound_net_log_;
61 }; 59 };
62 60
63 TEST_F(DataReductionProxyEventStoreTest, TestAddProxyEnabledEvent) { 61 TEST_F(DataReductionProxyEventStoreTest, TestAddProxyEnabledEvent) {
64 EXPECT_EQ(0u, proxy()->stored_events_.size()); 62 EXPECT_EQ(0u, proxy()->stored_events_.size());
65 proxy()->AddProxyEnabledEvent( 63 proxy()->AddProxyEnabledEvent(
66 net_log(), false, false, 64 net_log(), false, false,
67 TestDataReductionProxyParams::DefaultOrigin(), 65 TestDataReductionProxyParams::DefaultOrigin(),
68 TestDataReductionProxyParams::DefaultFallbackOrigin(), 66 TestDataReductionProxyParams::DefaultFallbackOrigin(),
69 TestDataReductionProxyParams::DefaultSSLOrigin()); 67 TestDataReductionProxyParams::DefaultSSLOrigin());
70 task_runner()->RunPendingTasks(); 68 task_runner()->RunPendingTasks();
71 EXPECT_EQ(1u, proxy()->stored_events_.size()); 69 EXPECT_EQ(1u, proxy()->stored_events_.size());
72 net::CapturingNetLog::CapturedEntry entry = GetSingleEntry(); 70 net::TestNetLog::CapturedEntry entry = GetSingleEntry();
73 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_ENABLED, 71 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_ENABLED,
74 entry.type); 72 entry.type);
75 } 73 }
76 74
77 TEST_F(DataReductionProxyEventStoreTest, TestAddProxyDisabledEvent) { 75 TEST_F(DataReductionProxyEventStoreTest, TestAddProxyDisabledEvent) {
78 EXPECT_EQ(0u, proxy()->stored_events_.size()); 76 EXPECT_EQ(0u, proxy()->stored_events_.size());
79 proxy()->AddProxyDisabledEvent(net_log()); 77 proxy()->AddProxyDisabledEvent(net_log());
80 task_runner()->RunPendingTasks(); 78 task_runner()->RunPendingTasks();
81 EXPECT_EQ(1u, proxy()->stored_events_.size()); 79 EXPECT_EQ(1u, proxy()->stored_events_.size());
82 net::CapturingNetLog::CapturedEntry entry = GetSingleEntry(); 80 net::TestNetLog::CapturedEntry entry = GetSingleEntry();
83 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_ENABLED, 81 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_ENABLED,
84 entry.type); 82 entry.type);
85 } 83 }
86 84
87 TEST_F(DataReductionProxyEventStoreTest, TestAddBypassActionEvent) { 85 TEST_F(DataReductionProxyEventStoreTest, TestAddBypassActionEvent) {
88 EXPECT_EQ(0u, proxy()->stored_events_.size()); 86 EXPECT_EQ(0u, proxy()->stored_events_.size());
89 EXPECT_EQ(nullptr, proxy()->last_bypass_event_.get()); 87 EXPECT_EQ(nullptr, proxy()->last_bypass_event_.get());
90 proxy()->AddBypassActionEvent(bound_net_log(), "bypass", GURL(), 88 proxy()->AddBypassActionEvent(bound_net_log(), "bypass", GURL(),
91 base::TimeDelta::FromMinutes(1)); 89 base::TimeDelta::FromMinutes(1));
92 task_runner()->RunPendingTasks(); 90 task_runner()->RunPendingTasks();
93 EXPECT_EQ(1u, proxy()->stored_events_.size()); 91 EXPECT_EQ(1u, proxy()->stored_events_.size());
94 net::CapturingNetLog::CapturedEntry entry = GetSingleEntry(); 92 net::TestNetLog::CapturedEntry entry = GetSingleEntry();
95 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_BYPASS_REQUESTED, 93 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_BYPASS_REQUESTED,
96 entry.type); 94 entry.type);
97 EXPECT_NE(nullptr, proxy()->last_bypass_event_.get()); 95 EXPECT_NE(nullptr, proxy()->last_bypass_event_.get());
98 } 96 }
99 97
100 TEST_F(DataReductionProxyEventStoreTest, TestAddBypassTypeEvent) { 98 TEST_F(DataReductionProxyEventStoreTest, TestAddBypassTypeEvent) {
101 EXPECT_EQ(0u, proxy()->stored_events_.size()); 99 EXPECT_EQ(0u, proxy()->stored_events_.size());
102 EXPECT_EQ(nullptr, proxy()->last_bypass_event_.get()); 100 EXPECT_EQ(nullptr, proxy()->last_bypass_event_.get());
103 proxy()->AddBypassTypeEvent(bound_net_log(), BYPASS_EVENT_TYPE_LONG, GURL(), 101 proxy()->AddBypassTypeEvent(bound_net_log(), BYPASS_EVENT_TYPE_LONG, GURL(),
104 base::TimeDelta::FromMinutes(1)); 102 base::TimeDelta::FromMinutes(1));
105 task_runner()->RunPendingTasks(); 103 task_runner()->RunPendingTasks();
106 EXPECT_EQ(1u, proxy()->stored_events_.size()); 104 EXPECT_EQ(1u, proxy()->stored_events_.size());
107 EXPECT_EQ(1u, net_log()->GetSize()); 105 EXPECT_EQ(1u, net_log()->GetSize());
108 net::CapturingNetLog::CapturedEntry entry = GetSingleEntry(); 106 net::TestNetLog::CapturedEntry entry = GetSingleEntry();
109 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_BYPASS_REQUESTED, 107 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_BYPASS_REQUESTED,
110 entry.type); 108 entry.type);
111 EXPECT_NE(nullptr, proxy()->last_bypass_event_.get()); 109 EXPECT_NE(nullptr, proxy()->last_bypass_event_.get());
112 } 110 }
113 111
114 TEST_F(DataReductionProxyEventStoreTest, TestBeginSecureProxyCheck) { 112 TEST_F(DataReductionProxyEventStoreTest, TestBeginSecureProxyCheck) {
115 EXPECT_EQ(0u, proxy()->stored_events_.size()); 113 EXPECT_EQ(0u, proxy()->stored_events_.size());
116 EXPECT_EQ(CHECK_UNKNOWN, proxy()->secure_proxy_check_state_); 114 EXPECT_EQ(CHECK_UNKNOWN, proxy()->secure_proxy_check_state_);
117 proxy()->BeginSecureProxyCheck(bound_net_log(), GURL()); 115 proxy()->BeginSecureProxyCheck(bound_net_log(), GURL());
118 task_runner()->RunPendingTasks(); 116 task_runner()->RunPendingTasks();
119 EXPECT_EQ(1u, proxy()->stored_events_.size()); 117 EXPECT_EQ(1u, proxy()->stored_events_.size());
120 EXPECT_EQ(1u, net_log()->GetSize()); 118 EXPECT_EQ(1u, net_log()->GetSize());
121 net::CapturingNetLog::CapturedEntry entry = GetSingleEntry(); 119 net::TestNetLog::CapturedEntry entry = GetSingleEntry();
122 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_CANARY_REQUEST, 120 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_CANARY_REQUEST,
123 entry.type); 121 entry.type);
124 EXPECT_EQ(CHECK_PENDING, proxy()->secure_proxy_check_state_); 122 EXPECT_EQ(CHECK_PENDING, proxy()->secure_proxy_check_state_);
125 } 123 }
126 124
127 TEST_F(DataReductionProxyEventStoreTest, TestEndSecureProxyCheck) { 125 TEST_F(DataReductionProxyEventStoreTest, TestEndSecureProxyCheck) {
128 EXPECT_EQ(0u, proxy()->stored_events_.size()); 126 EXPECT_EQ(0u, proxy()->stored_events_.size());
129 EXPECT_EQ(CHECK_UNKNOWN, proxy()->secure_proxy_check_state_); 127 EXPECT_EQ(CHECK_UNKNOWN, proxy()->secure_proxy_check_state_);
130 proxy()->EndSecureProxyCheck(bound_net_log(), 0); 128 proxy()->EndSecureProxyCheck(bound_net_log(), 0);
131 task_runner()->RunPendingTasks(); 129 task_runner()->RunPendingTasks();
132 EXPECT_EQ(1u, proxy()->stored_events_.size()); 130 EXPECT_EQ(1u, proxy()->stored_events_.size());
133 EXPECT_EQ(1u, net_log()->GetSize()); 131 EXPECT_EQ(1u, net_log()->GetSize());
134 net::CapturingNetLog::CapturedEntry entry = GetSingleEntry(); 132 net::TestNetLog::CapturedEntry entry = GetSingleEntry();
135 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_CANARY_REQUEST, 133 EXPECT_EQ(net::NetLog::TYPE_DATA_REDUCTION_PROXY_CANARY_REQUEST,
136 entry.type); 134 entry.type);
137 EXPECT_EQ(CHECK_SUCCESS, proxy()->secure_proxy_check_state_); 135 EXPECT_EQ(CHECK_SUCCESS, proxy()->secure_proxy_check_state_);
138 } 136 }
139 137
140 } // namespace data_reduction_proxy 138 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc ('k') | content/shell/browser/shell_net_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698