| 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/test_chrome_web_ui_factory.h" | 6 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" |
| 6 #include "chrome/test/in_process_browser_test.h" | 7 #include "chrome/test/in_process_browser_test.h" |
| 7 #include "chrome/test/ui_test_utils.h" | 8 #include "chrome/test/ui_test_utils.h" |
| 8 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 using ::testing::_; | 13 using ::testing::_; |
| 13 using ::testing::Eq; | 14 using ::testing::Eq; |
| 14 using ::testing::StrictMock; | 15 using ::testing::StrictMock; |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Returns a new WebUI object for the TabContents from |arg0|. | 19 // Returns a new WebUI object for the TabContents from |arg0|. |
| 19 ACTION(ReturnNewWebUI) { | 20 ACTION(ReturnNewWebUI) { |
| 20 return new WebUI(arg0); | 21 return new ChromeWebUI(arg0); |
| 21 } | 22 } |
| 22 | 23 |
| 23 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as | 24 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as |
| 24 // expected. | 25 // expected. |
| 25 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { | 26 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { |
| 26 public: | 27 public: |
| 27 MOCK_METHOD2(NewWebUI, WebUI*(TabContents* tab_contents, const GURL& url)); | 28 MOCK_METHOD2(NewWebUI, WebUI*(TabContents* tab_contents, const GURL& url)); |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 // Dummy URL location for us to override. | 31 // Dummy URL location for us to override. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 | 55 |
| 55 } // namespace | 56 } // namespace |
| 56 | 57 |
| 57 // Test that browsing to our test url causes us to be called once. | 58 // Test that browsing to our test url causes us to be called once. |
| 58 IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) { | 59 IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) { |
| 59 const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory); | 60 const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory); |
| 60 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL))) | 61 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL))) |
| 61 .WillOnce(ReturnNewWebUI()); | 62 .WillOnce(ReturnNewWebUI()); |
| 62 ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL); | 63 ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL); |
| 63 } | 64 } |
| OLD | NEW |