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

Unified Diff: components/domain_reliability/context_unittest.cc

Issue 252613002: Domain Reliability: More security review. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ;_; 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/domain_reliability/context.cc ('k') | components/domain_reliability/dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/domain_reliability/context_unittest.cc
diff --git a/components/domain_reliability/context_unittest.cc b/components/domain_reliability/context_unittest.cc
index 56b62a1f19024c8f8f65170312ba403e5dc57c4d..2bdf2e682e3dfa6579405922ad13dcbe86828479 100644
--- a/components/domain_reliability/context_unittest.cc
+++ b/components/domain_reliability/context_unittest.cc
@@ -18,7 +18,6 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace domain_reliability {
-
namespace {
typedef std::vector<DomainReliabilityBeacon> BeaconVector;
@@ -43,8 +42,10 @@ class DomainReliabilityContextTest : public testing::Test {
params_(CreateParams()),
uploader_(base::Bind(&DomainReliabilityContextTest::OnUploadRequest,
base::Unretained(this))),
+ upload_reporter_string_("test-reporter"),
context_(&time_,
params_,
+ upload_reporter_string_,
&dispatcher_,
&uploader_,
CreateConfig().Pass()),
@@ -73,14 +74,16 @@ class DomainReliabilityContextTest : public testing::Test {
upload_pending_ = false;
}
- bool CheckNoBeacons(int index) {
+ bool CheckNoBeacons(size_t index) {
BeaconVector beacons;
context_.GetQueuedDataForTesting(index, &beacons, NULL, NULL);
return beacons.empty();
}
- bool CheckCounts(int index, int expected_successful, int expected_failed) {
- int successful, failed;
+ bool CheckCounts(size_t index,
+ unsigned expected_successful,
+ unsigned expected_failed) {
+ unsigned successful, failed;
context_.GetQueuedDataForTesting(index, NULL, &successful, &failed);
return successful == expected_successful && failed == expected_failed;
}
@@ -89,6 +92,7 @@ class DomainReliabilityContextTest : public testing::Test {
DomainReliabilityDispatcher dispatcher_;
DomainReliabilityScheduler::Params params_;
MockUploader uploader_;
+ std::string upload_reporter_string_;
DomainReliabilityContext context_;
private:
@@ -153,8 +157,9 @@ TEST_F(DomainReliabilityContextTest, Create) {
}
TEST_F(DomainReliabilityContextTest, NoResource) {
+ GURL url("http://example/no_resource");
DomainReliabilityBeacon beacon = MakeBeacon(&time_);
- context_.AddBeacon(beacon, GURL("http://example/no_resource"));
+ context_.OnBeacon(url, beacon);
EXPECT_TRUE(CheckNoBeacons(0));
EXPECT_TRUE(CheckCounts(0, 0, 0));
@@ -163,8 +168,9 @@ TEST_F(DomainReliabilityContextTest, NoResource) {
}
TEST_F(DomainReliabilityContextTest, NeverReport) {
+ GURL url("http://example/never_report");
DomainReliabilityBeacon beacon = MakeBeacon(&time_);
- context_.AddBeacon(beacon, GURL("http://example/never_report"));
+ context_.OnBeacon(url, beacon);
EXPECT_TRUE(CheckNoBeacons(0));
EXPECT_TRUE(CheckCounts(0, 0, 0));
@@ -173,8 +179,9 @@ TEST_F(DomainReliabilityContextTest, NeverReport) {
}
TEST_F(DomainReliabilityContextTest, AlwaysReport) {
+ GURL url("http://example/always_report");
DomainReliabilityBeacon beacon = MakeBeacon(&time_);
- context_.AddBeacon(beacon, GURL("http://example/always_report"));
+ context_.OnBeacon(url, beacon);
BeaconVector beacons;
context_.GetQueuedDataForTesting(0, &beacons, NULL, NULL);
@@ -185,10 +192,11 @@ TEST_F(DomainReliabilityContextTest, AlwaysReport) {
}
TEST_F(DomainReliabilityContextTest, ReportUpload) {
+ GURL url("http://example/always_report");
DomainReliabilityBeacon beacon = MakeBeacon(&time_);
- context_.AddBeacon(beacon, GURL("http://example/always_report"));
+ context_.OnBeacon(url, beacon);
- const char* kExpectedReport = "{\"reporter\":\"chrome\","
+ const char* kExpectedReport = "{\"reporter\":\"test-reporter\","
"\"resource_reports\":[{\"beacons\":[{\"http_response_code\":200,"
"\"request_age_ms\":300250,\"request_elapsed_ms\":250,\"server_ip\":"
"\"127.0.0.1\",\"status\":\"ok\"}],\"failed_requests\":0,"
« no previous file with comments | « components/domain_reliability/context.cc ('k') | components/domain_reliability/dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698