| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/printing/print_preview_tab_controller.h" | 16 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_navigator.h" | 19 #include "chrome/browser/ui/browser_navigator.h" |
| 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 20 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h" |
| 21 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h" | 21 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "chrome/test/base/test_tab_strip_model_observer.h" | 25 #include "chrome/test/base/test_tab_strip_model_observer.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/browser/web_ui_controller.h" | 29 #include "content/public/browser/web_ui_controller.h" |
| 30 #include "content/public/browser/web_ui_message_handler.h" | 30 #include "content/public/browser/web_ui_message_handler.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // testing. | 273 // testing. |
| 274 class MockWebUIProvider | 274 class MockWebUIProvider |
| 275 : public TestChromeWebUIControllerFactory::WebUIProvider { | 275 : public TestChromeWebUIControllerFactory::WebUIProvider { |
| 276 public: | 276 public: |
| 277 MockWebUIProvider() {} | 277 MockWebUIProvider() {} |
| 278 | 278 |
| 279 // Returns a new WebUI | 279 // Returns a new WebUI |
| 280 WebUIController* NewWebUI(content::WebUI* web_ui, const GURL& url) OVERRIDE { | 280 WebUIController* NewWebUI(content::WebUI* web_ui, const GURL& url) OVERRIDE { |
| 281 WebUIController* controller = new content::WebUIController(web_ui); | 281 WebUIController* controller = new content::WebUIController(web_ui); |
| 282 Profile* profile = Profile::FromWebUI(web_ui); | 282 Profile* profile = Profile::FromWebUI(web_ui); |
| 283 profile->GetChromeURLDataManager()->AddDataSource( | 283 ChromeURLDataManagerFactory::GetForProfile(profile)-> |
| 284 new MockWebUIDataSource()); | 284 AddDataSource(new MockWebUIDataSource()); |
| 285 return controller; | 285 return controller; |
| 286 } | 286 } |
| 287 | 287 |
| 288 private: | 288 private: |
| 289 DISALLOW_COPY_AND_ASSIGN(MockWebUIProvider); | 289 DISALLOW_COPY_AND_ASSIGN(MockWebUIProvider); |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 base::LazyInstance<MockWebUIProvider> mock_provider_ = | 292 base::LazyInstance<MockWebUIProvider> mock_provider_ = |
| 293 LAZY_INSTANCE_INITIALIZER; | 293 LAZY_INSTANCE_INITIALIZER; |
| 294 | 294 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 // testDone directly and expect pass result. | 686 // testDone directly and expect pass result. |
| 687 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 687 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
| 688 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 688 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
| 689 } | 689 } |
| 690 | 690 |
| 691 // Test that calling testDone during RunJavascriptTest still completes when | 691 // Test that calling testDone during RunJavascriptTest still completes when |
| 692 // waiting for async result. | 692 // waiting for async result. |
| 693 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 693 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
| 694 ASSERT_TRUE(RunJavascriptTest("testDone")); | 694 ASSERT_TRUE(RunJavascriptTest("testDone")); |
| 695 } | 695 } |
| OLD | NEW |