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

Unified Diff: chrome/renderer/page_load_metrics/fake_page_load_metrics.cc

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: update Created 3 years, 8 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: chrome/renderer/page_load_metrics/fake_page_load_metrics.cc
diff --git a/chrome/renderer/page_load_metrics/fake_page_load_metrics.cc b/chrome/renderer/page_load_metrics/fake_page_load_metrics.cc
new file mode 100644
index 0000000000000000000000000000000000000000..877f7efc5da55c1b1d4487bf66bb69d4fc5f438b
--- /dev/null
+++ b/chrome/renderer/page_load_metrics/fake_page_load_metrics.cc
@@ -0,0 +1,50 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/page_load_metrics/fake_page_load_metrics.h"
+
+#include "base/feature_list.h"
+#include "chrome/common/chrome_features.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace page_load_metrics {
+
+FakePageLoadMetricsImpl::FakePageLoadMetricsImpl() : binding_(this) {}
+
+void FakePageLoadMetricsImpl::Bind(mojom::PageLoadMetricsRequest request) {
+ binding_.Close();
+ binding_.Bind(std::move(request));
+}
+
+FakePageLoadMetricsImpl::~FakePageLoadMetricsImpl() {
+ VerifyExpectedTimings();
+}
+
+void FakePageLoadMetricsImpl::ExpectPageLoadTiming(
+ const PageLoadTiming& timing) {
+ VerifyExpectedTimings();
+ expected_timings_.push_back(timing);
+}
+
+void FakePageLoadMetricsImpl::VerifyExpectedTimings() const {
+ if (!base::FeatureList::IsEnabled(features::kPageLoadMetricsMojofication))
+ return;
+ // Ideally we'd just call ASSERT_EQ(actual_timings_, expected_timings_) here,
+ // but this causes the generated gtest code to fail to build on Windows. See
+ // the comments in the header file for additional details.
+ ASSERT_EQ(actual_timings_.size(), expected_timings_.size());
+ for (size_t i = 0; i < actual_timings_.size(); ++i) {
+ if (actual_timings_.at(i) == expected_timings_.at(i))
+ continue;
+ ADD_FAILURE() << "Actual timing != expected timing at index " << i;
+ }
+}
+
+void FakePageLoadMetricsImpl::UpdateTiming(const PageLoadTiming& timing,
+ const PageLoadMetadata& metadata) {
+ actual_timings_.push_back(timing);
+ VerifyExpectedTimings();
+}
+
+} // namespace page_load_metrics

Powered by Google App Engine
This is Rietveld 408576698