Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/ui/webui/test_chrome_web_ui_factory_browsertest.cc

Issue 9288074: Rename WebUIFactory to WebUIControllerFactory since that's what it creates now. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: blah Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "content/public/browser/web_ui_controller.h"
8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "chrome/test/base/ui_test_utils.h"
10 #include "googleurl/src/gurl.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 using content::WebContents;
15 using content::WebUI;
16 using content::WebUIController;
17 using ::testing::_;
18 using ::testing::Eq;
19 using ::testing::StrictMock;
20
21 namespace {
22
23 // Returns a new WebUI object for the TabContents from |arg0|.
24 ACTION(ReturnNewWebUI) {
25 return new WebUIController(arg0);
26 }
27
28 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as
29 // expected.
30 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider {
31 public:
32 MOCK_METHOD2(NewWebUI, WebUIController*(content::WebUI* web_ui,
33 const GURL& url));
34 };
35
36 // Dummy URL location for us to override.
37 const char kChromeTestChromeWebUIFactory[] =
38 "chrome://ChromeTestChromeWebUIFactory/";
39
40 // Sets up and tears down the factory override for our url's host. It is
41 // necessary to do this here, rather than in the test declaration, which is too
42 // late to catch the possibility of an initial browse to about:blank mistakenly
43 // going to this handler.
44 class TestChromeWebUIFactoryTest : public InProcessBrowserTest {
45 public:
46 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
47 InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
48 TestChromeWebUIFactory::AddFactoryOverride(
49 GURL(kChromeTestChromeWebUIFactory).host(), &mock_provider_);
50 }
51
52 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
53 TestChromeWebUIFactory::RemoveFactoryOverride(
54 GURL(kChromeTestChromeWebUIFactory).host());
55 }
56
57 protected:
58 StrictMock<MockWebUIProvider> mock_provider_;
59 };
60
61 } // namespace
62
63 // Test that browsing to our test url causes us to be called once.
64 IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) {
65 const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory);
66 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL)))
67 .WillOnce(ReturnNewWebUI());
68 ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL);
69 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/test_chrome_web_ui_factory.cc ('k') | chrome/browser/ui/webui/uber/uber_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698