Chromium Code Reviews| Index: chrome/browser/prerender/prerender_browsertest.cc |
| diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc |
| index 20c9d5b6800ea097161ae01f275c3fdf1e1d924a..24862b70340752cd5dfa84fc6a579881dd27b192 100644 |
| --- a/chrome/browser/prerender/prerender_browsertest.cc |
| +++ b/chrome/browser/prerender/prerender_browsertest.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "base/test/histogram_tester.h" |
| #include "base/test/test_timeouts.h" |
| #include "base/values.h" |
| #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| @@ -64,7 +65,6 @@ |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/test_switches.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| -#include "chrome/test/base/uma_histogram_helper.h" |
| #include "content/public/browser/browser_message_filter.h" |
| #include "content/public/browser/devtools_agent_host.h" |
| #include "content/public/browser/devtools_client_host.h" |
| @@ -1507,6 +1507,8 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest { |
| js).c_str())); |
| } |
| + const base::HistogramTester& histogram_tester() { return histograms_; } |
|
mmenke
2014/07/18 14:53:39
nit: Should name the variable histogram_tester_ a
Mike Lerman
2014/07/18 15:55:52
Done.
|
| + |
| protected: |
| bool autostart_test_server_; |
| @@ -1657,21 +1659,21 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest { |
| std::string loader_path_; |
| std::string loader_query_; |
| Browser* explicitly_set_browser_; |
| + base::HistogramTester histograms_; |
| }; |
| // Checks that a page is correctly prerendered in the case of a |
| // <link rel=prerender> tag and then loaded into a tab in response to a |
| // navigation. |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { |
| - UMAHistogramHelper histograms; |
| - |
| PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
| EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0)); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| - histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.websame_PrerenderNotSwappedInPLT", 1); |
| ChannelDestructionWatcher channel_close_watcher; |
| channel_close_watcher.WatchChannel( |
| @@ -1679,10 +1681,10 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { |
| NavigateToDestURL(); |
| channel_close_watcher.WaitForChannelClose(); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", 1); |
| - histograms.ExpectTotalCount( |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", |
| + 1); |
| + histogram_tester().ExpectTotalCount( |
| "Prerender.websame_PerceivedPLTMatchedComplete", 1); |
| ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
| @@ -1690,21 +1692,20 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { |
| // Checks that cross-domain prerenders emit the correct histograms. |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageCrossDomain) { |
| - UMAHistogramHelper histograms; |
| - |
| PrerenderTestURL(GetCrossDomainTestUrl("files/prerender/prerender_page.html"), |
| FINAL_STATUS_USED, 1); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| - histograms.ExpectTotalCount("Prerender.webcross_PrerenderNotSwappedInPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.webcross_PrerenderNotSwappedInPLT", 1); |
| NavigateToDestURL(); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.webcross_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.webcross_PerceivedPLTMatched", 1); |
| - histograms.ExpectTotalCount( |
| + histogram_tester().ExpectTotalCount("Prerender.webcross_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.webcross_PerceivedPLTMatched", |
| + 1); |
| + histogram_tester().ExpectTotalCount( |
| "Prerender.webcross_PerceivedPLTMatchedComplete", 1); |
| } |
| @@ -2083,7 +2084,6 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| PrerenderLocationReplaceGWSHistograms) { |
| DisableJavascriptCalls(); |
| - UMAHistogramHelper histograms; |
| // The loader page should look like Google. |
| const std::string kGoogleDotCom("www.google.com"); |
| @@ -2109,14 +2109,15 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); |
| EXPECT_EQ(1, prerender->number_of_loads()); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| // Although there is a client redirect, it is dropped from histograms because |
| // it is a Google URL. The target page itself does not load until after the |
| // swap. |
| - histograms.ExpectTotalCount("Prerender.gws_PrerenderNotSwappedInPLT", 0); |
| + histogram_tester().ExpectTotalCount("Prerender.gws_PrerenderNotSwappedInPLT", |
| + 0); |
| GURL navigate_url = test_server()->GetURL( |
| "files/prerender/prerender_location_replace.html?" + |
| @@ -2134,15 +2135,16 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.gws_PrerenderNotSwappedInPLT", 0); |
| - histograms.ExpectTotalCount("Prerender.gws_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.gws_PerceivedPLTMatched", 1); |
| - histograms.ExpectTotalCount( |
| + histogram_tester().ExpectTotalCount("Prerender.gws_PrerenderNotSwappedInPLT", |
| + 0); |
| + histogram_tester().ExpectTotalCount("Prerender.gws_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.gws_PerceivedPLTMatched", 1); |
| + histogram_tester().ExpectTotalCount( |
| "Prerender.gws_PerceivedPLTMatchedComplete", 1); |
| // The client redirect does /not/ count as a miss because it's a Google URL. |
| - histograms.ExpectTotalCount("Prerender.PerceivedPLTFirstAfterMiss", 0); |
| + histogram_tester().ExpectTotalCount("Prerender.PerceivedPLTFirstAfterMiss", |
| + 0); |
| } |
| // Checks that client-issued redirects work with prerendering. |
| @@ -3348,24 +3350,24 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, ControlGroupRendererInitiated) { |
| // account for the MatchComplete case, and it must have a final status of |
| // FINAL_STATUS_WOULD_HAVE_BEEN_USED. |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, MatchCompleteDummy) { |
| - UMAHistogramHelper histograms; |
| std::vector<FinalStatus> expected_final_status_queue; |
| expected_final_status_queue.push_back(FINAL_STATUS_INVALID_HTTP_METHOD); |
| expected_final_status_queue.push_back(FINAL_STATUS_WOULD_HAVE_BEEN_USED); |
| PrerenderTestURL("files/prerender/prerender_xhr_put.html", |
| expected_final_status_queue, 1); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| - histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.websame_PrerenderNotSwappedInPLT", 1); |
| NavigateToDestURL(); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount( |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", |
| + 0); |
| + histogram_tester().ExpectTotalCount( |
| "Prerender.websame_PerceivedPLTMatchedComplete", 1); |
| } |
| @@ -3373,7 +3375,6 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, MatchCompleteDummy) { |
| // progress does not also classify the previous navigation as a MatchComplete. |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| MatchCompleteDummyCancelNavigation) { |
| - UMAHistogramHelper histograms; |
|
mmenke
2014/07/18 14:53:39
nit: Remove blank line.
Mike Lerman
2014/07/18 15:55:52
Done.
|
| // Arrange for a URL to hang. |
| const GURL kNoCommitUrl("http://never-respond.example.com"); |
| @@ -3391,11 +3392,12 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| expected_final_status_queue.push_back(FINAL_STATUS_WOULD_HAVE_BEEN_USED); |
| PrerenderTestURL("files/prerender/prerender_xhr_put.html", |
| expected_final_status_queue, 1); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| - histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.websame_PrerenderNotSwappedInPLT", 1); |
| // Open the hanging URL in a new tab. Wait for both the new tab to open and |
| // the hanging request to be scheduled. |
| @@ -3408,13 +3410,14 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
| // should forcibly complete the previous navigation and also complete a |
| // WOULD_HAVE_BEEN_PRERENDERED navigation. |
| NavigateToDestURL(); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 2); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount( |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 2); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", |
| + 0); |
| + histogram_tester().ExpectTotalCount( |
| "Prerender.websame_PerceivedPLTMatchedComplete", 1); |
| } |
| @@ -3797,7 +3800,6 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, CancelMatchCompleteDummy) { |
| // visible. Also test the right histogram events are emitted in this case. |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredImage) { |
| DisableJavascriptCalls(); |
| - UMAHistogramHelper histograms; |
| // The prerender will not completely load until after the swap, so wait for a |
| // title change before calling DidPrerenderPass. |
| @@ -3809,11 +3811,12 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredImage) { |
| EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0)); |
| EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); |
| EXPECT_EQ(0, prerender->number_of_loads()); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| - histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 0); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.websame_PrerenderNotSwappedInPLT", 0); |
| // Swap. |
| NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(), |
| @@ -3829,11 +3832,12 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderDeferredImage) { |
| // Now check DidDisplayPass. |
| EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.websame_PrerenderNotSwappedInPLT", 0); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", 1); |
| - histograms.ExpectTotalCount( |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.websame_PrerenderNotSwappedInPLT", 0); |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLTMatched", |
| + 1); |
| + histogram_tester().ExpectTotalCount( |
| "Prerender.websame_PerceivedPLTMatchedComplete", 1); |
| } |
| @@ -4178,14 +4182,13 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPing) { |
| } |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPPLTNormalNavigation) { |
| - UMAHistogramHelper histograms; |
|
mmenke
2014/07/18 14:53:39
nit: Remove blank line.
Mike Lerman
2014/07/18 15:55:52
Done.
|
| GURL url = test_server()->GetURL("files/prerender/prerender_page.html"); |
| ui_test_utils::NavigateToURL(current_browser(), url); |
| - histograms.Fetch(); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| - histograms.ExpectTotalCount("Prerender.none_PerceivedPLTMatchedComplete", 0); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1); |
| + histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLTMatched", 0); |
| + histogram_tester().ExpectTotalCount( |
| + "Prerender.none_PerceivedPLTMatchedComplete", 0); |
| } |
| IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |