OLD | NEW |
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/domain_reliability/monitor.h" | 5 #include "components/domain_reliability/monitor.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 size_t num_baked_in_configs = 0; | 159 size_t num_baked_in_configs = 0; |
160 for (const char* const* p = kBakedInJsonConfigs; *p; ++p) | 160 for (const char* const* p = kBakedInJsonConfigs; *p; ++p) |
161 ++num_baked_in_configs; | 161 ++num_baked_in_configs; |
162 | 162 |
163 // The monitor should have contexts for all of the baked-in configs, plus the | 163 // The monitor should have contexts for all of the baked-in configs, plus the |
164 // test one added in the test constructor. | 164 // test one added in the test constructor. |
165 EXPECT_EQ(num_baked_in_configs + 1, monitor_.contexts_size_for_testing()); | 165 EXPECT_EQ(num_baked_in_configs + 1, monitor_.contexts_size_for_testing()); |
166 } | 166 } |
167 | 167 |
| 168 TEST_F(DomainReliabilityMonitorTest, ClearBeacons) { |
| 169 // Initially the monitor should have just the test context, with no beacons. |
| 170 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); |
| 171 EXPECT_TRUE(CheckNoBeacons(0)); |
| 172 EXPECT_TRUE(CheckNoBeacons(1)); |
| 173 |
| 174 // Add a beacon. |
| 175 RequestInfo request = MakeRequestInfo(); |
| 176 request.url = GURL("http://example/always_report"); |
| 177 OnRequestLegComplete(request); |
| 178 |
| 179 // Make sure it was added. |
| 180 BeaconVector beacons; |
| 181 context_->GetQueuedDataForTesting(0, &beacons, NULL, NULL); |
| 182 EXPECT_EQ(1u, beacons.size()); |
| 183 EXPECT_TRUE(CheckNoBeacons(1)); |
| 184 |
| 185 monitor_.ClearBrowsingData(CLEAR_BEACONS); |
| 186 |
| 187 // Make sure the beacon was cleared, but not the contexts. |
| 188 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); |
| 189 EXPECT_TRUE(CheckNoBeacons(0)); |
| 190 EXPECT_TRUE(CheckNoBeacons(1)); |
| 191 } |
| 192 |
| 193 |
| 194 TEST_F(DomainReliabilityMonitorTest, ClearContexts) { |
| 195 // Initially the monitor should have just the test context. |
| 196 EXPECT_EQ(1u, monitor_.contexts_size_for_testing()); |
| 197 |
| 198 monitor_.ClearBrowsingData(CLEAR_CONTEXTS); |
| 199 |
| 200 // Clearing contexts should leave the monitor with none. |
| 201 EXPECT_EQ(0u, monitor_.contexts_size_for_testing()); |
| 202 } |
| 203 |
168 } // namespace domain_reliability | 204 } // namespace domain_reliability |
OLD | NEW |