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

Side by Side Diff: chrome/renderer/page_load_metrics/fake_page_load_metrics.cc

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: Addressed comments, remove unnecessary RunUntilIdle, call OnTimingUpdated directly in unit tests Created 3 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/page_load_metrics/fake_page_load_metrics.h"
6
7 #include "base/feature_list.h"
8 #include "chrome/common/chrome_features.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace page_load_metrics {
12
13 FakePageLoadMetricsImpl::FakePageLoadMetricsImpl() : binding_(this) {}
14
15 void FakePageLoadMetricsImpl::Bind(mojom::PageLoadMetricsRequest request) {
16 binding_.Close();
17 binding_.Bind(std::move(request));
18 }
19
20 FakePageLoadMetricsImpl::~FakePageLoadMetricsImpl() {
21 VerifyExpectedTimings();
22 }
23
24 void FakePageLoadMetricsImpl::ExpectPageLoadTiming(
25 const PageLoadTiming& timing) {
26 VerifyExpectedTimings();
27 expected_timings_.push_back(timing);
28 }
29
30 void FakePageLoadMetricsImpl::VerifyExpectedTimings() const {
31 if (!base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication))
32 return;
33 // Ideally we'd just call ASSERT_EQ(actual_timings_, expected_timings_) here,
34 // but this causes the generated gtest code to fail to build on Windows. See
35 // the comments in the header file for additional details.
36 ASSERT_EQ(actual_timings_.size(), expected_timings_.size());
37 for (size_t i = 0; i < actual_timings_.size(); ++i) {
38 if (actual_timings_.at(i) == expected_timings_.at(i))
39 continue;
40 ADD_FAILURE() << "Actual timing != expected timing at index " << i;
41 }
42 }
43
44 void FakePageLoadMetricsImpl::UpdateTiming(const PageLoadTiming& timing,
45 const PageLoadMetadata& metadata) {
46 actual_timings_.push_back(timing);
47 VerifyExpectedTimings();
48 }
49
50 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698