| 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/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" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 TEST_F(DomainReliabilityContextTest, ReportUpload) { | 192 TEST_F(DomainReliabilityContextTest, ReportUpload) { |
| 193 GURL url("http://example/always_report"); | 193 GURL url("http://example/always_report"); |
| 194 DomainReliabilityBeacon beacon = MakeBeacon(&time_); | 194 DomainReliabilityBeacon beacon = MakeBeacon(&time_); |
| 195 context_.OnBeacon(url, beacon); | 195 context_.OnBeacon(url, beacon); |
| 196 | 196 |
| 197 const char* kExpectedReport = "{\"reporter\":\"test-reporter\"," | 197 const char* kExpectedReport = "{\"reporter\":\"test-reporter\"," |
| 198 "\"resource_reports\":[{\"beacons\":[{\"http_response_code\":200," | 198 "\"resource_reports\":[{\"beacons\":[{\"http_response_code\":200," |
| 199 "\"request_age_ms\":300250,\"request_elapsed_ms\":250,\"server_ip\":" | 199 "\"request_age_ms\":300250,\"request_elapsed_ms\":250,\"server_ip\":" |
| 200 "\"127.0.0.1\",\"status\":\"ok\"}],\"failed_requests\":0," | 200 "\"127.0.0.1\",\"status\":\"ok\"}],\"failed_requests\":0," |
| 201 "\"resource_name\":\"always_report\",\"successful_requests\":1}," | 201 "\"resource_name\":\"always_report\",\"successful_requests\":1}]}"; |
| 202 "{\"beacons\":[],\"failed_requests\":0,\"resource_name\":" | |
| 203 "\"never_report\",\"successful_requests\":0}]}"; | |
| 204 | 202 |
| 205 time_.Advance(max_delay()); | 203 time_.Advance(max_delay()); |
| 206 EXPECT_TRUE(upload_pending()); | 204 EXPECT_TRUE(upload_pending()); |
| 207 EXPECT_EQ(kExpectedReport, upload_report()); | 205 EXPECT_EQ(kExpectedReport, upload_report()); |
| 208 EXPECT_EQ(GURL("https://example/upload"), upload_url()); | 206 EXPECT_EQ(GURL("https://example/upload"), upload_url()); |
| 209 CallUploadCallback(true); | 207 CallUploadCallback(true); |
| 210 } | 208 } |
| 211 | 209 |
| 212 } // namespace | 210 } // namespace |
| 213 } // namespace domain_reliability | 211 } // namespace domain_reliability |
| OLD | NEW |