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 #include "chrome/browser/ui/webui/web_ui_browsertest.h" | 4 #include "chrome/browser/ui/webui/web_ui_browsertest.h" |
5 | 5 |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/printing/print_preview_tab_controller.h" | 15 #include "chrome/browser/printing/print_preview_tab_controller.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_navigator.h" | 17 #include "chrome/browser/ui/browser_navigator.h" |
18 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 18 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
19 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" | 19 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "chrome/test/base/test_tab_strip_model_observer.h" | 23 #include "chrome/test/base/test_tab_strip_model_observer.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
25 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_ui_controller.h" |
27 #include "content/public/browser/web_ui_message_handler.h" | 28 #include "content/public/browser/web_ui_message_handler.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest-spi.h" | 30 #include "testing/gtest/include/gtest/gtest-spi.h" |
30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
31 | 32 |
32 using content::NavigationController; | 33 using content::NavigationController; |
33 using content::WebContents; | 34 using content::WebContents; |
34 using content::WebUIMessageHandler; | 35 using content::WebUIMessageHandler; |
35 | 36 |
36 namespace { | 37 namespace { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 237 } |
237 | 238 |
238 namespace { | 239 namespace { |
239 | 240 |
240 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { | 241 class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { |
241 public: | 242 public: |
242 MockWebUIProvider() {} | 243 MockWebUIProvider() {} |
243 | 244 |
244 // Returns a new WebUI | 245 // Returns a new WebUI |
245 WebUI* NewWebUI(WebContents* web_contents, const GURL& url) OVERRIDE { | 246 WebUI* NewWebUI(WebContents* web_contents, const GURL& url) OVERRIDE { |
246 return new WebUI(web_contents); | 247 static content::WebUIController temp_controller; |
| 248 return new WebUI(web_contents, &temp_controller); |
247 } | 249 } |
248 }; | 250 }; |
249 | 251 |
250 base::LazyInstance<MockWebUIProvider> mock_provider_ = | 252 base::LazyInstance<MockWebUIProvider> mock_provider_ = |
251 LAZY_INSTANCE_INITIALIZER; | 253 LAZY_INSTANCE_INITIALIZER; |
252 | 254 |
253 } // namespace | 255 } // namespace |
254 | 256 |
255 void WebUIBrowserTest::SetUpOnMainThread() { | 257 void WebUIBrowserTest::SetUpOnMainThread() { |
256 InProcessBrowserTest::SetUpOnMainThread(); | 258 InProcessBrowserTest::SetUpOnMainThread(); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 // testDone directly and expect pass result. | 645 // testDone directly and expect pass result. |
644 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 646 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
645 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 647 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
646 } | 648 } |
647 | 649 |
648 // Test that calling testDone during RunJavascriptTest still completes when | 650 // Test that calling testDone during RunJavascriptTest still completes when |
649 // waiting for async result. | 651 // waiting for async result. |
650 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 652 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
651 ASSERT_TRUE(RunJavascriptTest("testDone")); | 653 ASSERT_TRUE(RunJavascriptTest("testDone")); |
652 } | 654 } |
OLD | NEW |