OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 6 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" |
| 7 #include "googleurl/src/gurl.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 |
| 10 using ::testing::_; |
| 11 using ::testing::Eq; |
| 12 using ::testing::StrictMock; |
| 13 |
| 14 // Dummy URL location for us to override. |
| 15 const char kDummyURL[] = "chrome://DummyURL/"; |
| 16 |
| 17 // Returns a new WebUI object for the TabContents from |arg0|. |
| 18 ACTION(ReturnNewWebUI) { |
| 19 return new ChromeWebUI(arg0); |
| 20 } |
| 21 |
| 22 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as |
| 23 // expected. |
| 24 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { |
| 25 public: |
| 26 MOCK_METHOD2(NewWebUI, WebUI*(TabContents* tab_contents, const GURL& url)); |
| 27 }; |
| 28 |
| 29 class WebUIAssertionsTest : public WebUIBrowserTest { |
| 30 public: |
| 31 virtual void SetUpOnMainThread() OVERRIDE { |
| 32 WebUIBrowserTest::SetUpOnMainThread(); |
| 33 TestChromeWebUIFactory::AddFactoryOverride( |
| 34 GURL(kDummyURL).host(), &mock_provider_); |
| 35 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(GURL(kDummyURL)))) |
| 36 .WillOnce(ReturnNewWebUI()); |
| 37 } |
| 38 virtual void CleanUpOnMainThread() OVERRIDE { |
| 39 WebUIBrowserTest::CleanUpOnMainThread(); |
| 40 TestChromeWebUIFactory::RemoveFactoryOverride( |
| 41 GURL(kDummyURL).host()); |
| 42 } |
| 43 |
| 44 StrictMock<MockWebUIProvider> mock_provider_; |
| 45 |
| 46 }; |
OLD | NEW |