Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h" | 5 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/run_loop.h" | |
| 12 #include "chrome/browser/page_load_metrics/page_load_metrics_embedder_interface. h" | 13 #include "chrome/browser/page_load_metrics/page_load_metrics_embedder_interface. h" |
| 13 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 14 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
| 15 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h" | |
| 14 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h" | 16 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" |
| 16 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
| 19 #include "content/public/test/web_contents_tester.h" | 21 #include "content/public/test/web_contents_tester.h" |
| 20 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 22 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 21 | 23 |
| 22 namespace page_load_metrics { | 24 namespace page_load_metrics { |
| 23 | 25 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 } | 139 } |
| 138 | 140 |
| 139 void PageLoadMetricsObserverTestHarness::SimulateTimingUpdate( | 141 void PageLoadMetricsObserverTestHarness::SimulateTimingUpdate( |
| 140 const PageLoadTiming& timing) { | 142 const PageLoadTiming& timing) { |
| 141 SimulateTimingAndMetadataUpdate(timing, PageLoadMetadata()); | 143 SimulateTimingAndMetadataUpdate(timing, PageLoadMetadata()); |
| 142 } | 144 } |
| 143 | 145 |
| 144 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate( | 146 void PageLoadMetricsObserverTestHarness::SimulateTimingAndMetadataUpdate( |
| 145 const PageLoadTiming& timing, | 147 const PageLoadTiming& timing, |
| 146 const PageLoadMetadata& metadata) { | 148 const PageLoadMetadata& metadata) { |
| 147 observer_->OnMessageReceived(PageLoadMetricsMsg_TimingUpdated( | 149 observer_->OnMessageReceived(PageLoadMetricsMsg_TimingUpdated( |
|
Bryan McQuade
2017/04/26 16:04:34
let's switch this to invoke OnTimingUpdated direct
lpy
2017/04/27 10:58:35
Done. Forgot to change this part
| |
| 148 observer_->routing_id(), timing, metadata), | 150 observer_->routing_id(), timing, metadata), |
| 149 web_contents()->GetMainFrame()); | 151 web_contents()->GetMainFrame()); |
| 152 observer_->page_load_metrics_binding_for_testing() | |
| 153 .SetCurrentTargetFrameForTesting(web_contents()->GetMainFrame()); | |
| 154 mojo::Binding<page_load_metrics::mojom::PageLoadMetrics> binding(observer_); | |
| 155 mojom::PageLoadMetricsPtr ptr; | |
| 156 mojom::PageLoadMetricsRequest request = MakeRequest(&ptr); | |
| 157 binding.Bind(std::move(request)); | |
| 158 ptr->UpdateTiming(timing, metadata); | |
| 159 base::RunLoop().RunUntilIdle(); | |
| 150 } | 160 } |
| 151 | 161 |
| 152 void PageLoadMetricsObserverTestHarness::SimulateStartedResource( | 162 void PageLoadMetricsObserverTestHarness::SimulateStartedResource( |
| 153 const ExtraRequestStartInfo& info) { | 163 const ExtraRequestStartInfo& info) { |
| 154 observer_->OnRequestStarted(content::GlobalRequestID(), info.resource_type, | 164 observer_->OnRequestStarted(content::GlobalRequestID(), info.resource_type, |
| 155 base::TimeTicks::Now()); | 165 base::TimeTicks::Now()); |
| 156 } | 166 } |
| 157 | 167 |
| 158 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( | 168 void PageLoadMetricsObserverTestHarness::SimulateLoadedResource( |
| 159 const ExtraRequestCompleteInfo& info) { | 169 const ExtraRequestCompleteInfo& info) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 } | 205 } |
| 196 | 206 |
| 197 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( | 207 void PageLoadMetricsObserverTestHarness::NavigateWithPageTransitionAndCommit( |
| 198 const GURL& url, | 208 const GURL& url, |
| 199 ui::PageTransition transition) { | 209 ui::PageTransition transition) { |
| 200 controller().LoadURL(url, content::Referrer(), transition, std::string()); | 210 controller().LoadURL(url, content::Referrer(), transition, std::string()); |
| 201 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); | 211 content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
| 202 } | 212 } |
| 203 | 213 |
| 204 } // namespace page_load_metrics | 214 } // namespace page_load_metrics |
| OLD | NEW |