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

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

Issue 691053003: Domain Reliability: Mark beacons from previous networks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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.
davidben 2014/10/30 21:18:00 This probably wants tests (not sure if here or els
Deprecated (see juliatuttle) 2014/10/31 22:01:02 The Context itself just bases it on the (shared) l
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/context.h" 5 #include "components/domain_reliability/context.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
(...skipping 28 matching lines...) Expand all
40 protected: 40 protected:
41 DomainReliabilityContextTest() 41 DomainReliabilityContextTest()
42 : dispatcher_(&time_), 42 : dispatcher_(&time_),
43 params_(MakeTestSchedulerParams()), 43 params_(MakeTestSchedulerParams()),
44 uploader_(base::Bind(&DomainReliabilityContextTest::OnUploadRequest, 44 uploader_(base::Bind(&DomainReliabilityContextTest::OnUploadRequest,
45 base::Unretained(this))), 45 base::Unretained(this))),
46 upload_reporter_string_("test-reporter"), 46 upload_reporter_string_("test-reporter"),
47 context_(&time_, 47 context_(&time_,
48 params_, 48 params_,
49 upload_reporter_string_, 49 upload_reporter_string_,
50 last_network_change_time_,
50 &dispatcher_, 51 &dispatcher_,
51 &uploader_, 52 &uploader_,
52 MakeTestConfig().Pass()), 53 MakeTestConfig().Pass()),
53 upload_pending_(false) {} 54 upload_pending_(false) {}
54 55
55 TimeDelta min_delay() const { return params_.minimum_upload_delay; } 56 TimeDelta min_delay() const { return params_.minimum_upload_delay; }
56 TimeDelta max_delay() const { return params_.maximum_upload_delay; } 57 TimeDelta max_delay() const { return params_.maximum_upload_delay; }
57 TimeDelta retry_interval() const { return params_.upload_retry_interval; } 58 TimeDelta retry_interval() const { return params_.upload_retry_interval; }
58 TimeDelta zero_delta() const { return TimeDelta::FromMicroseconds(0); } 59 TimeDelta zero_delta() const { return TimeDelta::FromMicroseconds(0); }
59 60
(...skipping 23 matching lines...) Expand all
83 84
84 bool CheckCounts(size_t index, 85 bool CheckCounts(size_t index,
85 unsigned expected_successful, 86 unsigned expected_successful,
86 unsigned expected_failed) { 87 unsigned expected_failed) {
87 unsigned successful, failed; 88 unsigned successful, failed;
88 context_.GetRequestCountsForTesting(index, &successful, &failed); 89 context_.GetRequestCountsForTesting(index, &successful, &failed);
89 return successful == expected_successful && failed == expected_failed; 90 return successful == expected_successful && failed == expected_failed;
90 } 91 }
91 92
92 MockTime time_; 93 MockTime time_;
94 base::TimeTicks last_network_change_time_;
93 DomainReliabilityDispatcher dispatcher_; 95 DomainReliabilityDispatcher dispatcher_;
94 DomainReliabilityScheduler::Params params_; 96 DomainReliabilityScheduler::Params params_;
95 MockUploader uploader_; 97 MockUploader uploader_;
96 std::string upload_reporter_string_; 98 std::string upload_reporter_string_;
97 DomainReliabilityContext context_; 99 DomainReliabilityContext context_;
98 100
99 private: 101 private:
100 void OnUploadRequest( 102 void OnUploadRequest(
101 const std::string& report_json, 103 const std::string& report_json,
102 const GURL& upload_url, 104 const GURL& upload_url,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 EXPECT_EQ(GURL("https://exampleuploader/upload"), upload_url()); 183 EXPECT_EQ(GURL("https://exampleuploader/upload"), upload_url());
182 CallUploadCallback(true); 184 CallUploadCallback(true);
183 185
184 EXPECT_TRUE(CheckNoBeacons()); 186 EXPECT_TRUE(CheckNoBeacons());
185 EXPECT_TRUE(CheckCounts(0, 0, 0)); 187 EXPECT_TRUE(CheckCounts(0, 0, 0));
186 EXPECT_TRUE(CheckCounts(1, 0, 0)); 188 EXPECT_TRUE(CheckCounts(1, 0, 0));
187 } 189 }
188 190
189 } // namespace 191 } // namespace
190 } // namespace domain_reliability 192 } // namespace domain_reliability
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698