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

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

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: Add Finch trial check and rebase 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/metrics_render_frame_observer_unittest.cc
diff --git a/chrome/renderer/page_load_metrics/metrics_render_frame_observer_unittest.cc b/chrome/renderer/page_load_metrics/metrics_render_frame_observer_unittest.cc
index 453f15b3740b6264a7220cdc420d5767c5e99eaf..b685f4278ca9dec4270ec961f352ee20606b55ce 100644
--- a/chrome/renderer/page_load_metrics/metrics_render_frame_observer_unittest.cc
+++ b/chrome/renderer/page_load_metrics/metrics_render_frame_observer_unittest.cc
@@ -8,10 +8,14 @@
#include <utility>
#include "base/memory/ptr_util.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/time/time.h"
#include "base/timer/mock_timer.h"
#include "chrome/common/page_load_metrics/page_load_timing.h"
+#include "chrome/renderer/page_load_metrics/fake_page_load_metrics.h"
#include "chrome/renderer/page_load_metrics/fake_page_timing_metrics_ipc_sender.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace page_load_metrics {
@@ -30,6 +34,20 @@ class TestMetricsRenderFrameObserver : public MetricsRenderFrameObserver {
}
// We intercept sent messages and dispatch them to our
+ // FakePageLoadMetricsImpl, which we use to verify that the expected timing
+ // get sent.
+ void SendTiming(const PageLoadTiming& timing,
+ const PageLoadMetadata& metadata) override {
+ if (!page_load_metrics_ptr_) {
+ mojom::PageLoadMetricsRequest request =
+ MakeRequest(&page_load_metrics_ptr_);
+ fake_page_load_metrics_.Bind(std::move(request));
+ }
+ page_load_metrics_ptr_->UpdateTiming(timing, metadata);
+ base::RunLoop().RunUntilIdle();
+ }
+
+ // We intercept sent messages and dispatch them to our
// FakePageTimingMetricsIPCSender, which we use to verify that the expected
// IPC messages get sent.
bool Send(IPC::Message* message) override {
@@ -48,6 +66,7 @@ class TestMetricsRenderFrameObserver : public MetricsRenderFrameObserver {
void ExpectPageLoadTiming(const PageLoadTiming& timing) {
SetFakePageLoadTiming(timing);
fake_timing_ipc_sender_.ExpectPageLoadTiming(timing);
+ fake_page_load_metrics_.ExpectPageLoadTiming(timing);
}
void SetFakePageLoadTiming(const PageLoadTiming& timing) {
@@ -64,6 +83,7 @@ class TestMetricsRenderFrameObserver : public MetricsRenderFrameObserver {
void VerifyExpectedTimings() const {
EXPECT_TRUE(fake_timing_.IsEmpty());
fake_timing_ipc_sender_.VerifyExpectedTimings();
+ fake_page_load_metrics_.VerifyExpectedTimings();
}
bool ShouldSendMetrics() const override { return true; }
@@ -71,7 +91,10 @@ class TestMetricsRenderFrameObserver : public MetricsRenderFrameObserver {
bool IsMainFrame() const override { return is_main_frame_; }
private:
+ base::MessageLoop loop_;
FakePageTimingMetricsIPCSender fake_timing_ipc_sender_;
+ mojom::PageLoadMetricsPtr page_load_metrics_ptr_;
+ FakePageLoadMetricsImpl fake_page_load_metrics_;
mutable PageLoadTiming fake_timing_;
mutable std::unique_ptr<base::Timer> mock_timer_;
bool is_main_frame_ = true;

Powered by Google App Engine
This is Rietveld 408576698