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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // testDone directly and expect pass result. | 603 // testDone directly and expect pass result. |
596 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 604 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
597 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 605 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
598 } | 606 } |
599 | 607 |
600 // Test that calling testDone during RunJavascriptTest still completes when | 608 // Test that calling testDone during RunJavascriptTest still completes when |
601 // waiting for async result. | 609 // waiting for async result. |
602 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 610 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
603 ASSERT_TRUE(RunJavascriptTest("testDone")); | 611 ASSERT_TRUE(RunJavascriptTest("testDone")); |
604 } | 612 } |
OLD | NEW |