Chromium Code Reviews| 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: | |
|
jochen (gone - plz use gerrit)
2015/09/30 09:44:24
plz add a ctor and dtor
| |
| 14 const char* kHistogramNameFirstLayout = | |
| 15 "PageLoad.Timing.NavigationToFirstLayout"; | |
| 16 const char* kHistogramNameDomContent = | |
| 17 "PageLoad.Timing.NavigationToDOMContentLoadedEventFired"; | |
| 18 const char* kHistogramNameLoad = "PageLoad.Timing.NavigationToLoadEventFired"; | |
| 19 | |
| 20 protected: | |
| 21 base::HistogramTester histogram_tester_; | |
| 22 }; | |
|
jochen (gone - plz use gerrit)
2015/09/30 09:44:24
disallow copy/assign
| |
| 23 | |
| 24 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, NoNavigation) { | |
| 25 ASSERT_TRUE(test_server()->Start()); | |
| 26 | |
| 27 histogram_tester_.ExpectTotalCount(kHistogramNameDomContent, 0); | |
| 28 histogram_tester_.ExpectTotalCount(kHistogramNameLoad, 0); | |
| 29 histogram_tester_.ExpectTotalCount(kHistogramNameFirstLayout, 0); | |
| 30 } | |
| 31 | |
| 32 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, NewPage) { | |
| 33 ASSERT_TRUE(test_server()->Start()); | |
| 34 | |
| 35 ui_test_utils::NavigateToURL(browser(), | |
| 36 test_server()->GetURL("/title1.html")); | |
| 37 ui_test_utils::NavigateToURL(browser(), | |
| 38 test_server()->GetURL("/title2.html")); | |
| 39 | |
| 40 histogram_tester_.ExpectTotalCount(kHistogramNameDomContent, 1); | |
| 41 histogram_tester_.ExpectTotalCount(kHistogramNameLoad, 1); | |
| 42 histogram_tester_.ExpectTotalCount(kHistogramNameFirstLayout, 1); | |
| 43 } | |
| 44 | |
| 45 IN_PROC_BROWSER_TEST_F(MetricsWebContentsObserverBrowserTest, AnchorLink) { | |
| 46 ASSERT_TRUE(test_server()->Start()); | |
| 47 | |
| 48 ui_test_utils::NavigateToURL(browser(), | |
| 49 test_server()->GetURL("/title1.html")); | |
| 50 ui_test_utils::NavigateToURL(browser(), | |
| 51 test_server()->GetURL("/title1.html#hash")); | |
| 52 ui_test_utils::NavigateToURL(browser(), | |
| 53 test_server()->GetURL("/title2.html")); | |
| 54 | |
| 55 histogram_tester_.ExpectTotalCount(kHistogramNameDomContent, 1); | |
| 56 histogram_tester_.ExpectTotalCount(kHistogramNameLoad, 1); | |
| 57 histogram_tester_.ExpectTotalCount(kHistogramNameFirstLayout, 1); | |
| 58 } | |
| 59 | |
| 60 } // namespace page_load_metrics | |
| OLD | NEW |