OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_browser_test.h" | 5 #include "chrome/test/base/web_ui_browser_test.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "content/public/browser/url_data_source.h" | 25 #include "content/public/browser/url_data_source.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_contents_observer.h" | 27 #include "content/public/browser/web_contents_observer.h" |
28 #include "content/public/browser/web_ui_controller.h" | 28 #include "content/public/browser/web_ui_controller.h" |
29 #include "content/public/browser/web_ui_message_handler.h" | 29 #include "content/public/browser/web_ui_message_handler.h" |
30 #include "content/public/test/browser_test_utils.h" | 30 #include "content/public/test/browser_test_utils.h" |
31 #include "content/public/test/test_navigation_observer.h" | 31 #include "content/public/test/test_navigation_observer.h" |
32 #include "net/base/filename_util.h" | 32 #include "net/base/filename_util.h" |
33 #include "ui/base/resource/resource_handle.h" | 33 #include "ui/base/resource/resource_handle.h" |
34 | 34 |
35 #if defined(ENABLE_FULL_PRINTING) | 35 #if defined(ENABLE_PRINT_PREVIEW) |
36 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 36 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
37 #endif | 37 #endif |
38 | 38 |
39 using content::RenderViewHost; | 39 using content::RenderViewHost; |
40 using content::WebContents; | 40 using content::WebContents; |
41 using content::WebUIController; | 41 using content::WebUIController; |
42 using content::WebUIMessageHandler; | 42 using content::WebUIMessageHandler; |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 WebUIJsInjectionReadyObserver injection_observer( | 213 WebUIJsInjectionReadyObserver injection_observer( |
214 web_contents, this, preload_test_fixture_, preload_test_name_); | 214 web_contents, this, preload_test_fixture_, preload_test_name_); |
215 content::TestNavigationObserver navigation_observer(web_contents); | 215 content::TestNavigationObserver navigation_observer(web_contents); |
216 chrome::NavigateParams params( | 216 chrome::NavigateParams params( |
217 browser(), GURL(browse_to), ui::PAGE_TRANSITION_TYPED); | 217 browser(), GURL(browse_to), ui::PAGE_TRANSITION_TYPED); |
218 params.disposition = CURRENT_TAB; | 218 params.disposition = CURRENT_TAB; |
219 chrome::Navigate(¶ms); | 219 chrome::Navigate(¶ms); |
220 navigation_observer.Wait(); | 220 navigation_observer.Wait(); |
221 } | 221 } |
222 | 222 |
223 #if defined(ENABLE_FULL_PRINTING) | 223 #if defined(ENABLE_PRINT_PREVIEW) |
224 | 224 |
225 // This custom ContentBrowserClient is used to get notified when a WebContents | 225 // This custom ContentBrowserClient is used to get notified when a WebContents |
226 // for the print preview dialog gets created. | 226 // for the print preview dialog gets created. |
227 class PrintContentBrowserClient : public chrome::ChromeContentBrowserClient { | 227 class PrintContentBrowserClient : public chrome::ChromeContentBrowserClient { |
228 public: | 228 public: |
229 PrintContentBrowserClient(WebUIBrowserTest* browser_test, | 229 PrintContentBrowserClient(WebUIBrowserTest* browser_test, |
230 const std::string& preload_test_fixture, | 230 const std::string& preload_test_fixture, |
231 const std::string& preload_test_name) | 231 const std::string& preload_test_name) |
232 : browser_test_(browser_test), | 232 : browser_test_(browser_test), |
233 preload_test_fixture_(preload_test_fixture), | 233 preload_test_fixture_(preload_test_fixture), |
(...skipping 22 matching lines...) Expand all Loading... |
256 WebUIBrowserTest* browser_test_; | 256 WebUIBrowserTest* browser_test_; |
257 scoped_ptr<WebUIJsInjectionReadyObserver> observer_; | 257 scoped_ptr<WebUIJsInjectionReadyObserver> observer_; |
258 std::string preload_test_fixture_; | 258 std::string preload_test_fixture_; |
259 std::string preload_test_name_; | 259 std::string preload_test_name_; |
260 content::WebContents* preview_dialog_; | 260 content::WebContents* preview_dialog_; |
261 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 261 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
262 }; | 262 }; |
263 #endif | 263 #endif |
264 | 264 |
265 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { | 265 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { |
266 #if defined(ENABLE_FULL_PRINTING) | 266 #if defined(ENABLE_PRINT_PREVIEW) |
267 ui_test_utils::NavigateToURL(browser(), browse_to); | 267 ui_test_utils::NavigateToURL(browser(), browse_to); |
268 | 268 |
269 PrintContentBrowserClient new_client( | 269 PrintContentBrowserClient new_client( |
270 this, preload_test_fixture_, preload_test_name_); | 270 this, preload_test_fixture_, preload_test_name_); |
271 content::ContentBrowserClient* old_client = | 271 content::ContentBrowserClient* old_client = |
272 SetBrowserClientForTesting(&new_client); | 272 SetBrowserClientForTesting(&new_client); |
273 | 273 |
274 chrome::Print(browser()); | 274 chrome::Print(browser()); |
275 new_client.Wait(); | 275 new_client.Wait(); |
276 | 276 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 475 } |
476 | 476 |
477 GURL WebUIBrowserTest::WebUITestDataPathToURL( | 477 GURL WebUIBrowserTest::WebUITestDataPathToURL( |
478 const base::FilePath::StringType& path) { | 478 const base::FilePath::StringType& path) { |
479 base::FilePath dir_test_data; | 479 base::FilePath dir_test_data; |
480 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); | 480 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &dir_test_data)); |
481 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); | 481 base::FilePath test_path(dir_test_data.Append(kWebUITestFolder).Append(path)); |
482 EXPECT_TRUE(base::PathExists(test_path)); | 482 EXPECT_TRUE(base::PathExists(test_path)); |
483 return net::FilePathToFileURL(test_path); | 483 return net::FilePathToFileURL(test_path); |
484 } | 484 } |
OLD | NEW |