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

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

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: addressed comments 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_timing_sender.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace page_load_metrics {
10
11 FakePageTimingSender::FakePageTimingSender(PageTimingValidator* validator)
12 : validator_(validator) {}
13
14 FakePageTimingSender::~FakePageTimingSender() {}
15
16 void FakePageTimingSender::SendTiming(
17 const mojom::PageLoadTimingPtr& timing,
18 const mojom::PageLoadMetadataPtr& metadata) {
19 validator_->UpdateTiming(timing, metadata);
20 }
21
22 FakePageTimingSender::PageTimingValidator::PageTimingValidator() {}
23
24 FakePageTimingSender::PageTimingValidator::~PageTimingValidator() {
25 VerifyExpectedTimings();
26 }
27
28 void FakePageTimingSender::PageTimingValidator::ExpectPageLoadTiming(
29 const mojom::PageLoadTiming& timing) {
30 VerifyExpectedTimings();
31 expected_timings_.push_back(timing.Clone());
32 }
33
34 void FakePageTimingSender::PageTimingValidator::VerifyExpectedTimings() const {
35 // Ideally we'd just call ASSERT_EQ(actual_timings_, expected_timings_) here,
36 // but this causes the generated gtest code to fail to build on Windows. See
37 // the comments in the header file for additional details.
38 ASSERT_EQ(actual_timings_.size(), expected_timings_.size());
39 for (size_t i = 0; i < actual_timings_.size(); ++i) {
40 if (actual_timings_.at(i)->Equals(*expected_timings_.at(i)))
41 continue;
42 ADD_FAILURE() << "Actual timing != expected timing at index " << i;
43 }
44 }
45
46 void FakePageTimingSender::PageTimingValidator::UpdateTiming(
47 const mojom::PageLoadTimingPtr& timing,
48 const mojom::PageLoadMetadataPtr& metadata) {
49 actual_timings_.push_back(timing.Clone());
50 VerifyExpectedTimings();
51 }
52
53 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698