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