OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 5 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
6 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" | 6 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" |
| 7 #include "content/public/browser/web_ui_controller.h" |
7 #include "chrome/test/base/in_process_browser_test.h" | 8 #include "chrome/test/base/in_process_browser_test.h" |
8 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
9 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 using content::WebContents; | 14 using content::WebContents; |
14 using ::testing::_; | 15 using ::testing::_; |
15 using ::testing::Eq; | 16 using ::testing::Eq; |
16 using ::testing::StrictMock; | 17 using ::testing::StrictMock; |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 // Returns a new WebUI object for the TabContents from |arg0|. | 21 // Returns a new WebUI object for the TabContents from |arg0|. |
21 ACTION(ReturnNewWebUI) { | 22 ACTION(ReturnNewWebUI) { |
22 return new WebUI(arg0); | 23 static content::WebUIController temp_controller; |
| 24 return new WebUI(arg0, &temp_controller); |
23 } | 25 } |
24 | 26 |
25 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as | 27 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as |
26 // expected. | 28 // expected. |
27 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { | 29 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { |
28 public: | 30 public: |
29 MOCK_METHOD2(NewWebUI, WebUI*(WebContents* tab_contents, const GURL& url)); | 31 MOCK_METHOD2(NewWebUI, WebUI*(WebContents* tab_contents, const GURL& url)); |
30 }; | 32 }; |
31 | 33 |
32 // Dummy URL location for us to override. | 34 // Dummy URL location for us to override. |
(...skipping 23 matching lines...) Expand all Loading... |
56 | 58 |
57 } // namespace | 59 } // namespace |
58 | 60 |
59 // Test that browsing to our test url causes us to be called once. | 61 // Test that browsing to our test url causes us to be called once. |
60 IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) { | 62 IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) { |
61 const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory); | 63 const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory); |
62 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL))) | 64 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL))) |
63 .WillOnce(ReturnNewWebUI()); | 65 .WillOnce(ReturnNewWebUI()); |
64 ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL); | 66 ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL); |
65 } | 67 } |
OLD | NEW |