OLD | NEW |
(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 |
OLD | NEW |