Chromium Code Reviews| 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/metrics_web_contents_observer.h" | 7 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
| 8 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" | 8 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" |
| 9 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" | 9 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" |
| 10 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h" | 10 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 EXPECT_TRUE(content::ExecuteScript( | 370 EXPECT_TRUE(content::ExecuteScript( |
| 371 browser()->tab_strip_model()->GetActiveWebContents(), | 371 browser()->tab_strip_model()->GetActiveWebContents(), |
| 372 "window.location.reload();")); | 372 "window.location.reload();")); |
| 373 } | 373 } |
| 374 | 374 |
| 375 manager.WaitForNavigationFinished(); | 375 manager.WaitForNavigationFinished(); |
| 376 | 376 |
| 377 histogram_tester_.ExpectTotalCount( | 377 histogram_tester_.ExpectTotalCount( |
| 378 internal::kHistogramAbortClientRedirectBeforeCommit, 1); | 378 internal::kHistogramAbortClientRedirectBeforeCommit, 1); |
| 379 } | 379 } |
| 380 | |
| 381 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, | |
| 382 FirstMeaningfulPaintRecorded) { | |
| 383 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 384 | |
| 385 ui_test_utils::NavigateToURL(browser(), | |
| 386 embedded_test_server()->GetURL("/title1.html")); | |
| 387 | |
| 388 // Wait until a FMP is reported, by polling the histogram counter. | |
|
Charlie Harrison
2016/08/08 12:35:44
Can this be avoided? I would slightly prefer using
Kunihiko Sakamoto
2016/08/09 02:32:49
I'm afraid that that will be a source of flakiness
Charlie Harrison
2016/08/09 02:36:43
Yeah, that was my idea. The content API call will
Kunihiko Sakamoto
2016/08/09 03:31:14
Ah, now I got your idea.
Done, thanks!
| |
| 389 while (histogram_tester_.GetAllSamples( | |
| 390 internal::kHistogramFirstMeaningfulPaintStatus).empty()) { | |
| 391 base::RunLoop run_loop; | |
| 392 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 393 FROM_HERE, run_loop.QuitClosure(), | |
| 394 base::TimeDelta::FromMilliseconds(100)); | |
| 395 run_loop.Run(); | |
| 396 } | |
| 397 | |
| 398 NavigateToUntrackedUrl(); | |
| 399 histogram_tester_.ExpectUniqueSample( | |
| 400 internal::kHistogramFirstMeaningfulPaintStatus, | |
| 401 internal::FMP_RECORDED, 1); | |
| 402 histogram_tester_.ExpectTotalCount( | |
| 403 internal::kHistogramFirstMeaningfulPaint, 1); | |
| 404 histogram_tester_.ExpectTotalCount( | |
| 405 internal::kHistogramParseStartToFirstMeaningfulPaint, 1); | |
| 406 } | |
| 407 | |
| 408 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, | |
| 409 FirstMeaningfulPaintNotRecorded) { | |
| 410 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 411 | |
| 412 ui_test_utils::NavigateToURL(browser(), | |
| 413 embedded_test_server()->GetURL("/title1.html")); | |
| 414 | |
| 415 // Navigate away before a FMP is reported. | |
| 416 NavigateToUntrackedUrl(); | |
| 417 | |
| 418 histogram_tester_.ExpectUniqueSample( | |
| 419 internal::kHistogramFirstMeaningfulPaintStatus, | |
| 420 internal::FMP_DID_NOT_REACH_NETWORK_STABLE, 1); | |
| 421 histogram_tester_.ExpectTotalCount( | |
| 422 internal::kHistogramFirstMeaningfulPaint, 0); | |
| 423 histogram_tester_.ExpectTotalCount( | |
| 424 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); | |
| 425 } | |
| OLD | NEW |