OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/test/histogram_tester.h" | 6 #include "base/test/histogram_tester.h" |
7 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" | 7 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" |
8 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h" | 8 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h" |
9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 browser(), embedded_test_server()->GetURL( | 129 browser(), embedded_test_server()->GetURL( |
130 "/page_load_metrics/document_write_script_block.html")); | 130 "/page_load_metrics/document_write_script_block.html")); |
131 | 131 |
132 ui_test_utils::NavigateToURL( | 132 ui_test_utils::NavigateToURL( |
133 browser(), embedded_test_server()->GetURL( | 133 browser(), embedded_test_server()->GetURL( |
134 "/page_load_metrics/document_write_script_block.html")); | 134 "/page_load_metrics/document_write_script_block.html")); |
135 | 135 |
136 histogram_tester_.ExpectTotalCount( | 136 histogram_tester_.ExpectTotalCount( |
137 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | 137 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); |
138 | 138 |
139 histogram_tester_.ExpectTotalCount( | |
140 internal::kHistogramDocWriteBlockReloadCount, 1); | |
141 | |
142 ui_test_utils::NavigateToURL(browser(), | 139 ui_test_utils::NavigateToURL(browser(), |
143 embedded_test_server()->GetURL("/title2.html")); | 140 embedded_test_server()->GetURL("/title2.html")); |
144 | 141 |
145 histogram_tester_.ExpectTotalCount( | 142 histogram_tester_.ExpectTotalCount( |
146 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | 143 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); |
147 | 144 |
145 // Testing this histogram's value only in the end else the test will be | |
Bryan McQuade
2016/06/17 13:24:03
yeah, i had encountered similar issues with timing
| |
146 // dependent on IPC timing. | |
148 histogram_tester_.ExpectTotalCount( | 147 histogram_tester_.ExpectTotalCount( |
149 internal::kHistogramDocWriteBlockReloadCount, 2); | 148 internal::kHistogramDocWriteBlockReloadCount, 2); |
150 } | 149 } |
151 | 150 |
152 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, | 151 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, |
153 DocumentWriteASync) { | 152 DocumentWriteASync) { |
154 ASSERT_TRUE(embedded_test_server()->Start()); | 153 ASSERT_TRUE(embedded_test_server()->Start()); |
155 | 154 |
156 ui_test_utils::NavigateToURL( | 155 ui_test_utils::NavigateToURL( |
157 browser(), embedded_test_server()->GetURL( | 156 browser(), embedded_test_server()->GetURL( |
(...skipping 25 matching lines...) Expand all Loading... | |
183 | 182 |
184 ui_test_utils::NavigateToURL( | 183 ui_test_utils::NavigateToURL( |
185 browser(), embedded_test_server()->GetURL( | 184 browser(), embedded_test_server()->GetURL( |
186 "/page_load_metrics/document_write_no_script.html")); | 185 "/page_load_metrics/document_write_no_script.html")); |
187 ui_test_utils::NavigateToURL(browser(), | 186 ui_test_utils::NavigateToURL(browser(), |
188 embedded_test_server()->GetURL("/title2.html")); | 187 embedded_test_server()->GetURL("/title2.html")); |
189 | 188 |
190 histogram_tester_.ExpectTotalCount( | 189 histogram_tester_.ExpectTotalCount( |
191 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); | 190 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); |
192 } | 191 } |
OLD | NEW |