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 | 4 |
5 #include "chrome/test/base/web_ui_browsertest.h" | 5 #include "chrome/test/base/web_ui_browsertest.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/printing/print_preview_dialog_controller.h" | |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
21 #include "chrome/browser/ui/browser_navigator.h" | 20 #include "chrome/browser/ui/browser_navigator.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/browser/ui/webui/web_ui_test_handler.h" | 22 #include "chrome/browser/ui/webui/web_ui_test_handler.h" |
24 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
26 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" | 25 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" |
27 #include "chrome/test/base/test_tab_strip_model_observer.h" | 26 #include "chrome/test/base/test_tab_strip_model_observer.h" |
28 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
29 #include "content/public/browser/navigation_controller.h" | 28 #include "content/public/browser/navigation_controller.h" |
30 #include "content/public/browser/notification_observer.h" | 29 #include "content/public/browser/notification_observer.h" |
31 #include "content/public/browser/notification_registrar.h" | 30 #include "content/public/browser/notification_registrar.h" |
32 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
34 #include "content/public/browser/render_view_host_observer.h" | 33 #include "content/public/browser/render_view_host_observer.h" |
35 #include "content/public/browser/url_data_source.h" | 34 #include "content/public/browser/url_data_source.h" |
36 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
37 #include "content/public/browser/web_ui_controller.h" | 36 #include "content/public/browser/web_ui_controller.h" |
38 #include "content/public/browser/web_ui_message_handler.h" | 37 #include "content/public/browser/web_ui_message_handler.h" |
39 #include "net/base/net_util.h" | 38 #include "net/base/net_util.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest-spi.h" | 40 #include "testing/gtest/include/gtest/gtest-spi.h" |
42 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
43 #include "ui/base/resource/resource_handle.h" | 42 #include "ui/base/resource/resource_handle.h" |
44 | 43 |
| 44 #if defined(ENABLE_FULL_PRINTING) |
| 45 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 46 #endif |
| 47 |
45 using content::NavigationController; | 48 using content::NavigationController; |
46 using content::RenderViewHost; | 49 using content::RenderViewHost; |
47 using content::WebContents; | 50 using content::WebContents; |
48 using content::WebUIController; | 51 using content::WebUIController; |
49 using content::WebUIMessageHandler; | 52 using content::WebUIMessageHandler; |
50 | 53 |
51 namespace { | 54 namespace { |
52 | 55 |
53 const base::FilePath::CharType kA11yAuditLibraryJSPath[] = FILE_PATH_LITERAL( | 56 const base::FilePath::CharType kA11yAuditLibraryJSPath[] = FILE_PATH_LITERAL( |
54 "third_party/accessibility-developer-tools/gen/axs_testing.js"); | 57 "third_party/accessibility-developer-tools/gen/axs_testing.js"); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 content::PAGE_TRANSITION_TYPED); | 275 content::PAGE_TRANSITION_TYPED); |
273 params.disposition = CURRENT_TAB; | 276 params.disposition = CURRENT_TAB; |
274 chrome::Navigate(¶ms); | 277 chrome::Navigate(¶ms); |
275 navigation_observer.WaitForObservation( | 278 navigation_observer.WaitForObservation( |
276 base::Bind(&content::RunMessageLoop), | 279 base::Bind(&content::RunMessageLoop), |
277 base::Bind(&base::MessageLoop::Quit, | 280 base::Bind(&base::MessageLoop::Quit, |
278 base::Unretained(base::MessageLoopForUI::current()))); | 281 base::Unretained(base::MessageLoopForUI::current()))); |
279 } | 282 } |
280 | 283 |
281 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { | 284 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { |
| 285 #if defined(ENABLE_FULL_PRINTING) |
282 ui_test_utils::NavigateToURL(browser(), browse_to); | 286 ui_test_utils::NavigateToURL(browser(), browse_to); |
283 | 287 |
284 TestTabStripModelObserver tabstrip_observer( | 288 TestTabStripModelObserver tabstrip_observer( |
285 browser()->tab_strip_model(), this); | 289 browser()->tab_strip_model(), this); |
286 chrome::Print(browser()); | 290 chrome::Print(browser()); |
287 tabstrip_observer.WaitForObservation( | 291 tabstrip_observer.WaitForObservation( |
288 base::Bind(&content::RunMessageLoop), | 292 base::Bind(&content::RunMessageLoop), |
289 base::Bind(&base::MessageLoop::Quit, | 293 base::Bind(&base::MessageLoop::Quit, |
290 base::Unretained(base::MessageLoopForUI::current()))); | 294 base::Unretained(base::MessageLoopForUI::current()))); |
291 | 295 |
292 printing::PrintPreviewDialogController* tab_controller = | 296 printing::PrintPreviewDialogController* tab_controller = |
293 printing::PrintPreviewDialogController::GetInstance(); | 297 printing::PrintPreviewDialogController::GetInstance(); |
294 ASSERT_TRUE(tab_controller); | 298 ASSERT_TRUE(tab_controller); |
295 WebContents* preview_dialog = tab_controller->GetPrintPreviewForContents( | 299 WebContents* preview_dialog = tab_controller->GetPrintPreviewForContents( |
296 browser()->tab_strip_model()->GetActiveWebContents()); | 300 browser()->tab_strip_model()->GetActiveWebContents()); |
297 ASSERT_TRUE(preview_dialog); | 301 ASSERT_TRUE(preview_dialog); |
298 SetWebUIInstance(preview_dialog->GetWebUI()); | 302 SetWebUIInstance(preview_dialog->GetWebUI()); |
| 303 #else |
| 304 NOTREACHED(); |
| 305 #endif |
299 } | 306 } |
300 | 307 |
301 const char WebUIBrowserTest::kDummyURL[] = "chrome://DummyURL"; | 308 const char WebUIBrowserTest::kDummyURL[] = "chrome://DummyURL"; |
302 | 309 |
303 WebUIBrowserTest::WebUIBrowserTest() | 310 WebUIBrowserTest::WebUIBrowserTest() |
304 : test_handler_(new WebUITestHandler()), | 311 : test_handler_(new WebUITestHandler()), |
305 libraries_preloaded_(false), | 312 libraries_preloaded_(false), |
306 override_selected_web_ui_(NULL) {} | 313 override_selected_web_ui_(NULL) {} |
307 | 314 |
308 void WebUIBrowserTest::set_preload_test_fixture( | 315 void WebUIBrowserTest::set_preload_test_fixture( |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 // testDone directly and expect pass result. | 776 // testDone directly and expect pass result. |
770 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 777 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
771 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 778 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
772 } | 779 } |
773 | 780 |
774 // Test that calling testDone during RunJavascriptTest still completes when | 781 // Test that calling testDone during RunJavascriptTest still completes when |
775 // waiting for async result. | 782 // waiting for async result. |
776 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 783 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
777 ASSERT_TRUE(RunJavascriptTest("testDone")); | 784 ASSERT_TRUE(RunJavascriptTest("testDone")); |
778 } | 785 } |
OLD | NEW |