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

Side by Side Diff: chrome/browser/page_load_metrics/observers/media_page_load_metrics_observer_unittest.cc

Issue 2874663005: [Page Load Metrics] Add mojom file to page load metrics. (Closed)
Patch Set: Remove unnecessary variable 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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/media_page_load_metrics_obs erver.h" 5 #include "chrome/browser/page_load_metrics/observers/media_page_load_metrics_obs erver.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 11 matching lines...) Expand all
22 22
23 } // namespace 23 } // namespace
24 24
25 class MediaPageLoadMetricsObserverTest 25 class MediaPageLoadMetricsObserverTest
26 : public page_load_metrics::PageLoadMetricsObserverTestHarness { 26 : public page_load_metrics::PageLoadMetricsObserverTestHarness {
27 public: 27 public:
28 MediaPageLoadMetricsObserverTest() {} 28 MediaPageLoadMetricsObserverTest() {}
29 ~MediaPageLoadMetricsObserverTest() override = default; 29 ~MediaPageLoadMetricsObserverTest() override = default;
30 30
31 void ResetTest() { 31 void ResetTest() {
32 page_load_metrics::InitPageLoadTimingForTest(&timing_);
32 // Reset to the default testing state. Does not reset histogram state. 33 // Reset to the default testing state. Does not reset histogram state.
33 timing_.navigation_start = base::Time::FromDoubleT(1); 34 timing_.navigation_start = base::Time::FromDoubleT(1);
34 timing_.response_start = base::TimeDelta::FromSeconds(2); 35 timing_.response_start = base::TimeDelta::FromSeconds(2);
35 timing_.parse_timing.parse_start = base::TimeDelta::FromSeconds(3); 36 timing_.parse_timing->parse_start = base::TimeDelta::FromSeconds(3);
36 timing_.paint_timing.first_contentful_paint = 37 timing_.paint_timing->first_contentful_paint =
37 base::TimeDelta::FromSeconds(4); 38 base::TimeDelta::FromSeconds(4);
38 timing_.paint_timing.first_image_paint = base::TimeDelta::FromSeconds(5); 39 timing_.paint_timing->first_image_paint = base::TimeDelta::FromSeconds(5);
39 timing_.paint_timing.first_text_paint = base::TimeDelta::FromSeconds(6); 40 timing_.paint_timing->first_text_paint = base::TimeDelta::FromSeconds(6);
40 timing_.document_timing.load_event_start = base::TimeDelta::FromSeconds(7); 41 timing_.document_timing->load_event_start = base::TimeDelta::FromSeconds(7);
41 PopulateRequiredTimingFields(&timing_); 42 PopulateRequiredTimingFields(&timing_);
42 43
43 network_bytes_ = 0; 44 network_bytes_ = 0;
44 cache_bytes_ = 0; 45 cache_bytes_ = 0;
45 } 46 }
46 47
47 void SimulatePageLoad(bool simulate_play_media, 48 void SimulatePageLoad(bool simulate_play_media,
48 bool simulate_app_background) { 49 bool simulate_app_background) {
49 NavigateAndCommit(GURL(kDefaultTestUrl)); 50 NavigateAndCommit(GURL(kDefaultTestUrl));
50 51
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 protected: 102 protected:
102 void RegisterObservers(page_load_metrics::PageLoadTracker* tracker) override { 103 void RegisterObservers(page_load_metrics::PageLoadTracker* tracker) override {
103 tracker->AddObserver(base::MakeUnique<MediaPageLoadMetricsObserver>()); 104 tracker->AddObserver(base::MakeUnique<MediaPageLoadMetricsObserver>());
104 } 105 }
105 106
106 // Simulated byte usage since the last time the test was reset. 107 // Simulated byte usage since the last time the test was reset.
107 int64_t network_bytes_; 108 int64_t network_bytes_;
108 int64_t cache_bytes_; 109 int64_t cache_bytes_;
109 110
110 private: 111 private:
111 page_load_metrics::PageLoadTiming timing_; 112 page_load_metrics::mojom::PageLoadTiming timing_;
112 113
113 DISALLOW_COPY_AND_ASSIGN(MediaPageLoadMetricsObserverTest); 114 DISALLOW_COPY_AND_ASSIGN(MediaPageLoadMetricsObserverTest);
114 }; 115 };
115 116
116 TEST_F(MediaPageLoadMetricsObserverTest, MediaPlayed) { 117 TEST_F(MediaPageLoadMetricsObserverTest, MediaPlayed) {
117 ResetTest(); 118 ResetTest();
118 SimulatePageLoad(true /* simulate_play_media */, 119 SimulatePageLoad(true /* simulate_play_media */,
119 false /* simulate_app_background */); 120 false /* simulate_app_background */);
120 121
121 histogram_tester().ExpectUniqueSample( 122 histogram_tester().ExpectUniqueSample(
(...skipping 28 matching lines...) Expand all
150 SimulatePageLoad(false /* simulate_play_media */, 151 SimulatePageLoad(false /* simulate_play_media */,
151 false /* simulate_app_background */); 152 false /* simulate_app_background */);
152 153
153 histogram_tester().ExpectTotalCount( 154 histogram_tester().ExpectTotalCount(
154 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0); 155 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Network", 0);
155 histogram_tester().ExpectTotalCount( 156 histogram_tester().ExpectTotalCount(
156 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0); 157 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Cache", 0);
157 histogram_tester().ExpectTotalCount( 158 histogram_tester().ExpectTotalCount(
158 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0); 159 "PageLoad.Clients.MediaPageLoad.Experimental.Bytes.Total", 0);
159 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698