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 MockWebUIProvider(); | |
27 ~MockWebUIProvider(); | |
28 | |
29 MOCK_METHOD2(NewWebUI, WebUI*(TabContents* tab_contents, const GURL& url)); | |
30 }; | |
31 | |
32 class WebUIAssertionsTest : public WebUIBrowserTest { | |
33 public: | |
34 WebUIAssertionsTest(); | |
35 | |
36 virtual void SetUpOnMainThread() OVERRIDE { | |
37 WebUIBrowserTest::SetUpOnMainThread(); | |
38 TestChromeWebUIFactory::AddFactoryOverride( | |
39 GURL(kDummyURL).host(), &mock_provider_); | |
40 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(GURL(kDummyURL)))) | |
41 .WillOnce(ReturnNewWebUI()); | |
42 } | |
43 virtual void CleanUpOnMainThread() OVERRIDE { | |
44 WebUIBrowserTest::CleanUpOnMainThread(); | |
45 TestChromeWebUIFactory::RemoveFactoryOverride( | |
46 GURL(kDummyURL).host()); | |
47 } | |
48 | |
49 StrictMock<MockWebUIProvider> mock_provider_; | |
50 | |
51 protected: | |
52 ~WebUIAssertionsTest(); | |
53 | |
54 private: | |
55 DISALLOW_COPY_AND_ASSIGN(WebUIAssertionsTest); | |
56 }; | |
OLD | NEW |