| 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" | |
| 16 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_navigator.h" | 16 #include "chrome/browser/ui/browser_navigator.h" |
| 18 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 17 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 19 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" | 18 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 21 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/base/test_tab_strip_model_observer.h" | 22 #include "chrome/test/base/test_tab_strip_model_observer.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // Remember for callback OnJsInjectionReady(). | 199 // Remember for callback OnJsInjectionReady(). |
| 201 preload_test_fixture_ = preload_test_fixture; | 200 preload_test_fixture_ = preload_test_fixture; |
| 202 preload_test_name_ = preload_test_name; | 201 preload_test_name_ = preload_test_name; |
| 203 | 202 |
| 204 ui_test_utils::NavigateToURL(browser(), browse_to); | 203 ui_test_utils::NavigateToURL(browser(), browse_to); |
| 205 | 204 |
| 206 TestTabStripModelObserver tabstrip_observer( | 205 TestTabStripModelObserver tabstrip_observer( |
| 207 browser()->tabstrip_model(), this); | 206 browser()->tabstrip_model(), this); |
| 208 browser()->Print(); | 207 browser()->Print(); |
| 209 tabstrip_observer.WaitForObservation(); | 208 tabstrip_observer.WaitForObservation(); |
| 210 printing::PrintPreviewTabController* tab_controller = | |
| 211 printing::PrintPreviewTabController::GetInstance(); | |
| 212 ASSERT_TRUE(tab_controller); | |
| 213 TabContentsWrapper* preview_tab = tab_controller->GetPrintPreviewForTab( | |
| 214 browser()->GetSelectedTabContentsWrapper()); | |
| 215 ASSERT_TRUE(preview_tab); | |
| 216 SetWebUIInstance(preview_tab->web_ui()); | |
| 217 } | 209 } |
| 218 | 210 |
| 219 const char WebUIBrowserTest::kDummyURL[] = "chrome://DummyURL"; | 211 const char WebUIBrowserTest::kDummyURL[] = "chrome://DummyURL"; |
| 220 | 212 |
| 221 WebUIBrowserTest::WebUIBrowserTest() | 213 WebUIBrowserTest::WebUIBrowserTest() |
| 222 : test_handler_(new WebUITestHandler()), | 214 : test_handler_(new WebUITestHandler()), |
| 223 libraries_preloaded_(false), | 215 libraries_preloaded_(false), |
| 224 override_selected_web_ui_(NULL) {} | 216 override_selected_web_ui_(NULL) {} |
| 225 | 217 |
| 226 namespace { | 218 namespace { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 // testDone directly and expect pass result. | 620 // testDone directly and expect pass result. |
| 629 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 621 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
| 630 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 622 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
| 631 } | 623 } |
| 632 | 624 |
| 633 // Test that calling testDone during RunJavascriptTest still completes when | 625 // Test that calling testDone during RunJavascriptTest still completes when |
| 634 // waiting for async result. | 626 // waiting for async result. |
| 635 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 627 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
| 636 ASSERT_TRUE(RunJavascriptTest("testDone")); | 628 ASSERT_TRUE(RunJavascriptTest("testDone")); |
| 637 } | 629 } |
| OLD | NEW |