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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client_unittest.cc

Issue 2145743002: Changing the TimeDeltas in DRPPageLoadTiming to Optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 5 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
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client_unittest.cc
index 8131c02771fbea52f7a837050e4a498489dbc125..50bb13080974e15c3bee83b7b25ec70830f0ec82 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client_unittest.cc
@@ -3,20 +3,21 @@
// found in the LICENSE file.
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h"
#include <memory>
#include <string>
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
+#include "base/optional.h"
#include "base/test/histogram_tester.h"
#include "base/time/time.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_load_timing.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_util.h"
#include "components/data_reduction_proxy/proto/client_config.pb.h"
#include "components/data_reduction_proxy/proto/pageload_metrics.pb.h"
#include "net/base/net_errors.h"
#include "net/url_request/test_url_fetcher_factory.h"
@@ -61,24 +62,28 @@ class TestDataReductionProxyPingbackClient
}
bool should_override_random_;
float override_value_;
};
class DataReductionProxyPingbackClientTest : public testing::Test {
public:
DataReductionProxyPingbackClientTest()
: timing_(base::Time::FromJsTime(1500),
- base::TimeDelta::FromMilliseconds(1600),
- base::TimeDelta::FromMilliseconds(1700),
- base::TimeDelta::FromMilliseconds(1800),
- base::TimeDelta::FromMilliseconds(1900)) {}
+ base::Optional<base::TimeDelta>(
+ base::TimeDelta::FromMilliseconds(1600)),
+ base::Optional<base::TimeDelta>(
+ base::TimeDelta::FromMilliseconds(1700)),
+ base::Optional<base::TimeDelta>(
+ base::TimeDelta::FromMilliseconds(1800)),
+ base::Optional<base::TimeDelta>(
+ base::TimeDelta::FromMilliseconds(1900))) {}
TestDataReductionProxyPingbackClient* pingback_client() const {
return pingback_client_.get();
}
void Init() {
request_context_getter_ =
new net::TestURLRequestContextGetter(message_loop_.task_runner());
pingback_client_ = base::WrapUnique<TestDataReductionProxyPingbackClient>(
new TestDataReductionProxyPingbackClient(
@@ -116,29 +121,30 @@ TEST_F(DataReductionProxyPingbackClientTest, VerifyPingbackContent) {
CreateAndSendPingback();
histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 1);
net::TestURLFetcher* test_fetcher = factory()->GetFetcherByID(0);
EXPECT_EQ(test_fetcher->upload_content_type(), "application/x-protobuf");
RecordPageloadMetricsRequest batched_request;
batched_request.ParseFromString(test_fetcher->upload_data());
PageloadMetrics pageload_metrics = batched_request.pageloads(0);
EXPECT_EQ(
timing().navigation_start,
protobuf_parser::TimestampToTime(pageload_metrics.first_request_time()));
- EXPECT_EQ(timing().response_start,
+ EXPECT_EQ(timing().response_start.value(),
protobuf_parser::DurationToTimeDelta(
pageload_metrics.time_to_first_byte()));
- EXPECT_EQ(timing().load_event_start, protobuf_parser::DurationToTimeDelta(
- pageload_metrics.page_load_time()));
- EXPECT_EQ(timing().first_image_paint,
+ EXPECT_EQ(
+ timing().load_event_start.value(),
+ protobuf_parser::DurationToTimeDelta(pageload_metrics.page_load_time()));
+ EXPECT_EQ(timing().first_image_paint.value(),
protobuf_parser::DurationToTimeDelta(
pageload_metrics.time_to_first_image_paint()));
- EXPECT_EQ(timing().first_contentful_paint,
+ EXPECT_EQ(timing().first_contentful_paint.value(),
protobuf_parser::DurationToTimeDelta(
pageload_metrics.time_to_first_contentful_paint()));
EXPECT_EQ(kSessionKey, pageload_metrics.session_key());
EXPECT_EQ(kFakeURL, pageload_metrics.first_request_url());
test_fetcher->delegate()->OnURLFetchComplete(test_fetcher);
histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 1);
EXPECT_FALSE(factory()->GetFetcherByID(0));
}

Powered by Google App Engine
This is Rietveld 408576698