Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 379283002: Rework UMAHistogramHelper and StatisticsDeltaReader into [Chrome]HistogramTester. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_browsertest.cc
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 4c966623970cc68000bafebd65c58a580c13318a..65d4bb9485f739608996d48904e501e9eb630aac 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/navigation_controller.h"
@@ -1503,6 +1503,8 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest {
js).c_str()));
}
+ const base::HistogramTester& histogram_tester() { return histogram_tester_; }
+
protected:
bool autostart_test_server_;
@@ -1653,21 +1655,21 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest {
std::string loader_path_;
std::string loader_query_;
Browser* explicitly_set_browser_;
+ base::HistogramTester histogram_tester_;
};
// 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(
@@ -1675,10 +1677,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());
@@ -1686,21 +1688,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);
}
@@ -2079,7 +2080,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");
@@ -2105,14 +2105,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?" +
@@ -2130,15 +2131,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.
@@ -3343,24 +3345,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);
}
@@ -3368,8 +3370,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;
-
// Arrange for a URL to hang.
const GURL kNoCommitUrl("http://never-respond.example.com");
base::FilePath file(FILE_PATH_LITERAL(
@@ -3386,11 +3386,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.
@@ -3403,13 +3404,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);
}
@@ -3792,7 +3794,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.
@@ -3804,11 +3805,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(),
@@ -3824,11 +3826,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);
}
@@ -4173,14 +4176,12 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPing) {
}
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPPLTNormalNavigation) {
- UMAHistogramHelper histograms;
-
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,
« no previous file with comments | « chrome/browser/chromeos/external_metrics_unittest.cc ('k') | chrome/browser/signin/account_reconcilor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698