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

Unified Diff: chrome/browser/ui/webui/log_web_ui_url_browsertest.cc

Issue 1367343002: Add browser test for WebUI URL logging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: histogram_tester Created 5 years, 3 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
« no previous file with comments | « chrome/browser/ui/webui/log_web_ui_url.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/log_web_ui_url_browsertest.cc
diff --git a/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc b/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eaa593e9ea7bb6ad022c17fcddef9ee7580d2e28
--- /dev/null
+++ b/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc
@@ -0,0 +1,54 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/log_web_ui_url.h"
+
+#include <vector>
+
+#include "base/hash.h"
+#include "base/test/histogram_tester.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "url/gurl.h"
+
+using base::Bucket;
+using testing::ElementsAre;
+
+namespace webui {
+
+class LogWebUIUrlTest : public InProcessBrowserTest {
+ public:
+ LogWebUIUrlTest() {}
+ ~LogWebUIUrlTest() override {}
+
+ std::vector<Bucket> GetSamples() {
+ return histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl);
+ }
+
+ private:
+ base::HistogramTester histogram_tester_;
+
+ DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest);
+};
+
+IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestHistoryFrame) {
+ GURL history_frame_url(chrome::kChromeUIHistoryFrameURL);
+
+ ui_test_utils::NavigateToURL(browser(), history_frame_url);
+
+ uint32 history_frame_url_hash = base::Hash(history_frame_url.spec());
+ EXPECT_THAT(GetSamples(), ElementsAre(Bucket(history_frame_url_hash, 1)));
+
+ chrome::Reload(browser(), CURRENT_TAB);
+
+ EXPECT_THAT(GetSamples(), ElementsAre(Bucket(history_frame_url_hash, 2)));
+}
+
+// TODO(dbeam): test an uber page URL like chrome://history.
+
+} // namespace webui
« no previous file with comments | « chrome/browser/ui/webui/log_web_ui_url.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698