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

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

Issue 9003014: Replace WebUI::tab_contents() with web_contents() and switch all users to use web_contents.h inst... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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
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 "chrome/test/base/in_process_browser_test.h" 7 #include "chrome/test/base/in_process_browser_test.h"
8 #include "chrome/test/base/ui_test_utils.h" 8 #include "chrome/test/base/ui_test_utils.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using content::WebContents;
13 using ::testing::_; 14 using ::testing::_;
14 using ::testing::Eq; 15 using ::testing::Eq;
15 using ::testing::StrictMock; 16 using ::testing::StrictMock;
16 17
17 namespace { 18 namespace {
18 19
19 // Returns a new WebUI object for the TabContents from |arg0|. 20 // Returns a new WebUI object for the TabContents from |arg0|.
20 ACTION(ReturnNewWebUI) { 21 ACTION(ReturnNewWebUI) {
21 return new ChromeWebUI(arg0); 22 return new ChromeWebUI(arg0);
22 } 23 }
23 24
24 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as 25 // Mock the TestChromeWebUIFactory::WebUIProvider to prove that we are called as
25 // expected. 26 // expected.
26 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { 27 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider {
27 public: 28 public:
28 MOCK_METHOD2(NewWebUI, WebUI*(TabContents* tab_contents, const GURL& url)); 29 MOCK_METHOD2(NewWebUI, WebUI*(WebContents* tab_contents, const GURL& url));
29 }; 30 };
30 31
31 // Dummy URL location for us to override. 32 // Dummy URL location for us to override.
32 const char kChromeTestChromeWebUIFactory[] = 33 const char kChromeTestChromeWebUIFactory[] =
33 "chrome://ChromeTestChromeWebUIFactory/"; 34 "chrome://ChromeTestChromeWebUIFactory/";
34 35
35 // Sets up and tears down the factory override for our url's host. It is 36 // Sets up and tears down the factory override for our url's host. It is
36 // necessary to do this here, rather than in the test declaration, which is too 37 // necessary to do this here, rather than in the test declaration, which is too
37 // late to catch the possibility of an initial browse to about:blank mistakenly 38 // late to catch the possibility of an initial browse to about:blank mistakenly
38 // going to this handler. 39 // going to this handler.
(...skipping 16 matching lines...) Expand all
55 56
56 } // namespace 57 } // namespace
57 58
58 // Test that browsing to our test url causes us to be called once. 59 // Test that browsing to our test url causes us to be called once.
59 IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) { 60 IN_PROC_BROWSER_TEST_F(TestChromeWebUIFactoryTest, TestWebUIProvider) {
60 const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory); 61 const GURL kChromeTestChromeWebUIFactoryURL(kChromeTestChromeWebUIFactory);
61 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL))) 62 EXPECT_CALL(mock_provider_, NewWebUI(_, Eq(kChromeTestChromeWebUIFactoryURL)))
62 .WillOnce(ReturnNewWebUI()); 63 .WillOnce(ReturnNewWebUI());
63 ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL); 64 ui_test_utils::NavigateToURL(browser(), kChromeTestChromeWebUIFactoryURL);
64 } 65 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/test_chrome_web_ui_factory.h ('k') | chrome/browser/ui/webui/tracing_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698