| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/test/histogram_tester.h" | |
| 6 #include "chrome/test/base/in_process_browser_test.h" | |
| 7 #include "chrome/test/base/ui_test_utils.h" | |
| 8 #include "net/test/spawned_test_server/spawned_test_server.h" | |
| 9 | |
| 10 namespace page_load_metrics { | |
| 11 | |
| 12 class MetricsWebContentsObserverBrowserTest : public InProcessBrowserTest { | |
| 13 public: | |
| 14 const char* kHistogramNameFirstLayout = | |
| 15 "PageLoad.Timing.NavigationToFirstLayout"; | |
| 16 const char* kHistogramNameDomContent = | |
| 17 "PageLoad.Timing.NavigationToDOMContentLoadedEventFired"; | |
| 18 const char* kHistogramNameLoad = "PageLoad.Timing.NavigationToLoadEventFired"; | |
| 19 MetricsWebContentsObserverBrowserTest() {}; | |
| 20 ~MetricsWebContentsObserverBrowserTest() override {}; | |
| 21 | |
| 22 protected: | |
| 23 base::HistogramTester histogram_tester_; | |
| 24 | |
| 25 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserverBrowserTest); | |
| 26 }; | |
| 27 | |
| 28 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, NoNavigation) { | |
| 29 ASSERT_TRUE(test_server()->Start()); | |
| 30 | |
| 31 histogram_tester_.ExpectTotalCount(kHistogramNameDomContent, 0); | |
| 32 histogram_tester_.ExpectTotalCount(kHistogramNameLoad, 0); | |
| 33 histogram_tester_.ExpectTotalCount(kHistogramNameFirstLayout, 0); | |
| 34 } | |
| 35 | |
| 36 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, NewPage) { | |
| 37 ASSERT_TRUE(test_server()->Start()); | |
| 38 | |
| 39 ui_test_utils::NavigateToURL(browser(), | |
| 40 test_server()->GetURL("/title1.html")); | |
| 41 ui_test_utils::NavigateToURL(browser(), | |
| 42 test_server()->GetURL("/title2.html")); | |
| 43 | |
| 44 histogram_tester_.ExpectTotalCount(kHistogramNameDomContent, 1); | |
| 45 histogram_tester_.ExpectTotalCount(kHistogramNameLoad, 1); | |
| 46 histogram_tester_.ExpectTotalCount(kHistogramNameFirstLayout, 1); | |
| 47 } | |
| 48 | |
| 49 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, AnchorLink) { | |
| 50 ASSERT_TRUE(test_server()->Start()); | |
| 51 | |
| 52 ui_test_utils::NavigateToURL(browser(), | |
| 53 test_server()->GetURL("/title1.html")); | |
| 54 ui_test_utils::NavigateToURL(browser(), | |
| 55 test_server()->GetURL("/title1.html#hash")); | |
| 56 ui_test_utils::NavigateToURL(browser(), | |
| 57 test_server()->GetURL("/title2.html")); | |
| 58 | |
| 59 histogram_tester_.ExpectTotalCount(kHistogramNameDomContent, 1); | |
| 60 histogram_tester_.ExpectTotalCount(kHistogramNameLoad, 1); | |
| 61 histogram_tester_.ExpectTotalCount(kHistogramNameFirstLayout, 1); | |
| 62 } | |
| 63 | |
| 64 } // namespace page_load_metrics | |
| OLD | NEW |