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

Side by Side Diff: components/domain_reliability/monitor_unittest.cc

Issue 238863005: Domain Reliability: Remove browsing data when requested. (Closed) Base URL: http://git.chromium.org/chromium/src.git@domrel_bakedin
Patch Set: ...and fix BrowsingDataRemoverTet Created 6 years, 7 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
« no previous file with comments | « components/domain_reliability/monitor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // Count the number of baked-in configs. 281 // Count the number of baked-in configs.
282 size_t num_baked_in_configs = 0; 282 size_t num_baked_in_configs = 0;
283 for (const char* const* p = kBakedInJsonConfigs; *p; ++p) 283 for (const char* const* p = kBakedInJsonConfigs; *p; ++p)
284 ++num_baked_in_configs; 284 ++num_baked_in_configs;
285 285
286 // The monitor should have contexts for all of the baked-in configs, plus the 286 // The monitor should have contexts for all of the baked-in configs, plus the
287 // test one added in the test constructor. 287 // test one added in the test constructor.
288 EXPECT_EQ(num_baked_in_configs + 1, monitor_.contexts_size_for_testing()); 288 EXPECT_EQ(num_baked_in_configs + 1, monitor_.contexts_size_for_testing());
289 } 289 }
290 290
291 TEST_F(DomainReliabilityMonitorTest, ClearBeacons) {
292 // Initially the monitor should have just the test context, with no beacons.
293 EXPECT_EQ(1u, monitor_.contexts_size_for_testing());
294 EXPECT_EQ(0u, CountPendingBeacons(kAlwaysReportIndex));
295 EXPECT_TRUE(CheckRequestCounts(kAlwaysReportIndex, 0u, 0u));
296 EXPECT_EQ(0u, CountPendingBeacons(kNeverReportIndex));
297 EXPECT_TRUE(CheckRequestCounts(kNeverReportIndex, 0u, 0u));
298
299 // Add a beacon.
300 RequestInfo request = MakeRequestInfo();
301 request.url = GURL("http://example/always_report");
302 OnRequestLegComplete(request);
303
304 // Make sure it was added.
305 EXPECT_EQ(1u, CountPendingBeacons(kAlwaysReportIndex));
306 EXPECT_TRUE(CheckRequestCounts(kAlwaysReportIndex, 1u, 0u));
307
308 monitor_.ClearBrowsingData(CLEAR_BEACONS);
309
310 // Make sure the beacon was cleared, but not the contexts.
311 EXPECT_EQ(1u, monitor_.contexts_size_for_testing());
312 EXPECT_EQ(0u, CountPendingBeacons(kAlwaysReportIndex));
313 EXPECT_TRUE(CheckRequestCounts(kAlwaysReportIndex, 0u, 0u));
314 EXPECT_EQ(0u, CountPendingBeacons(kNeverReportIndex));
315 EXPECT_TRUE(CheckRequestCounts(kNeverReportIndex, 0u, 0u));
316 }
317
318
319 TEST_F(DomainReliabilityMonitorTest, ClearContexts) {
320 // Initially the monitor should have just the test context.
321 EXPECT_EQ(1u, monitor_.contexts_size_for_testing());
322
323 monitor_.ClearBrowsingData(CLEAR_CONTEXTS);
324
325 // Clearing contexts should leave the monitor with none.
326 EXPECT_EQ(0u, monitor_.contexts_size_for_testing());
327 }
328
291 } // namespace 329 } // namespace
292 330
293 } // namespace domain_reliability 331 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/domain_reliability/monitor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698