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/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" |
| 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "url/gurl.h" |
| 18 |
| 19 namespace webui { |
| 20 |
| 21 class LogWebUIUrlTest : public InProcessBrowserTest { |
| 22 public: |
| 23 LogWebUIUrlTest() { |
| 24 SetHashFunctionForTesting( |
| 25 base::Bind(&LogWebUIUrlTest::Hash, base::Unretained(this))); |
| 26 } |
| 27 |
| 28 ~LogWebUIUrlTest() override { |
| 29 SetHashFunctionForTesting(WebUIUrlHash()); |
| 30 } |
| 31 |
| 32 const std::vector<GURL>& logged_urls() { return logged_urls_; } |
| 33 |
| 34 private: |
| 35 uint32 Hash(const GURL& web_ui_url) { |
| 36 logged_urls_.push_back(web_ui_url); |
| 37 return 0; |
| 38 } |
| 39 |
| 40 std::vector<GURL> logged_urls_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(LogWebUIUrlTest); |
| 43 }; |
| 44 |
| 45 IN_PROC_BROWSER_TEST_F(LogWebUIUrlTest, ExtensionLoadAndSendPolicy) { |
| 46 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); |
| 47 EXPECT_EQ(1U, logged_urls().size()); |
| 48 EXPECT_EQ(GURL("chrome://downloads"), logged_urls()[0]); |
| 49 |
| 50 chrome::Reload(browser(), CURRENT_TAB); |
| 51 EXPECT_EQ(2U, logged_urls().size()); |
| 52 EXPECT_EQ(GURL("chrome://downloads"), logged_urls()[1]); |
| 53 } |
| 54 |
| 55 // TODO(dbeam): test an uber page URL like chrome://history. |
| 56 |
| 57 } // namespace webui |
OLD | NEW |