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

Side by Side 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, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 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 "chrome/browser/ui/webui/log_web_ui_url.h"
6
7 #include <vector>
8
9 #include "base/hash.h"
10 #include "base/test/histogram_tester.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h"
16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "url/gurl.h"
18
19 using base::Bucket;
20 using testing::ElementsAre;
21
22 namespace webui {
23
24 class LogWebUIUrlTest : public InProcessBrowserTest {
25 public:
26 LogWebUIUrlTest() {}
27 ~LogWebUIUrlTest() override {}
28
29 std::vector<Bucket> GetSamples() {
30 return histogram_tester_.GetAllSamples(webui::kWebUICreatedForUrl);
31 }
32
33 private:
34 base::HistogramTester histogram_tester_;
35
36 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest);
37 };
38
39 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, TestHistoryFrame) {
40 GURL history_frame_url(chrome::kChromeUIHistoryFrameURL);
41
42 ui_test_utils::NavigateToURL(browser(), history_frame_url);
43
44 uint32 history_frame_url_hash = base::Hash(history_frame_url.spec());
45 EXPECT_THAT(GetSamples(), ElementsAre(Bucket(history_frame_url_hash, 1)));
46
47 chrome::Reload(browser(), CURRENT_TAB);
48
49 EXPECT_THAT(GetSamples(), ElementsAre(Bucket(history_frame_url_hash, 2)));
50 }
51
52 // TODO(dbeam): test an uber page URL like chrome://history.
53
54 } // namespace webui
OLDNEW
« 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