| 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/browser/ui/webui/web_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/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/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/printing/print_preview_tab_controller.h" | 17 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/browser_navigator.h" | 21 #include "chrome/browser/ui/browser_navigator.h" |
| 22 #include "chrome/browser/ui/browser_tabstrip.h" | 22 #include "chrome/browser/ui/browser_tabstrip.h" |
| 23 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 24 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 24 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h" | 25 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h" |
| 25 #include "chrome/browser/ui/webui/web_ui_test_handler.h" | 26 #include "chrome/browser/ui/webui/web_ui_test_handler.h" |
| 26 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "chrome/test/base/test_tab_strip_model_observer.h" | 29 #include "chrome/test/base/test_tab_strip_model_observer.h" |
| 30 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
| 31 #include "content/public/browser/navigation_controller.h" | 31 #include "content/public/browser/navigation_controller.h" |
| 32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/browser/web_ui_controller.h" | 33 #include "content/public/browser/web_ui_controller.h" |
| 34 #include "content/public/browser/web_ui_message_handler.h" | 34 #include "content/public/browser/web_ui_message_handler.h" |
| 35 #include "net/base/net_util.h" | 35 #include "net/base/net_util.h" |
| 36 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 RunJavascriptUsingHandler( | 193 RunJavascriptUsingHandler( |
| 194 "preloadJavascriptLibraries", args, false, false, preload_host); | 194 "preloadJavascriptLibraries", args, false, false, preload_host); |
| 195 libraries_preloaded_ = true; | 195 libraries_preloaded_ = true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) { | 198 void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) { |
| 199 content::TestNavigationObserver navigation_observer( | 199 content::TestNavigationObserver navigation_observer( |
| 200 content::Source<NavigationController>( | 200 content::Source<NavigationController>( |
| 201 &chrome::GetActiveWebContents(browser())->GetController()), | 201 &chrome::GetActiveWebContents(browser())->GetController()), |
| 202 this, 1); | 202 this, 1); |
| 203 browser::NavigateParams params( | 203 chrome::NavigateParams params(browser(), GURL(browse_to), |
| 204 browser(), GURL(browse_to), content::PAGE_TRANSITION_TYPED); | 204 content::PAGE_TRANSITION_TYPED); |
| 205 params.disposition = CURRENT_TAB; | 205 params.disposition = CURRENT_TAB; |
| 206 browser::Navigate(¶ms); | 206 chrome::Navigate(¶ms); |
| 207 navigation_observer.WaitForObservation( | 207 navigation_observer.WaitForObservation( |
| 208 base::Bind(&ui_test_utils::RunMessageLoop), | 208 base::Bind(&ui_test_utils::RunMessageLoop), |
| 209 base::Bind(&MessageLoop::Quit, | 209 base::Bind(&MessageLoop::Quit, |
| 210 base::Unretained(MessageLoopForUI::current()))); | 210 base::Unretained(MessageLoopForUI::current()))); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { | 213 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { |
| 214 ui_test_utils::NavigateToURL(browser(), browse_to); | 214 ui_test_utils::NavigateToURL(browser(), browse_to); |
| 215 | 215 |
| 216 TestTabStripModelObserver tabstrip_observer( | 216 TestTabStripModelObserver tabstrip_observer( |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 // testDone directly and expect pass result. | 698 // testDone directly and expect pass result. |
| 699 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 699 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
| 700 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 700 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
| 701 } | 701 } |
| 702 | 702 |
| 703 // Test that calling testDone during RunJavascriptTest still completes when | 703 // Test that calling testDone during RunJavascriptTest still completes when |
| 704 // waiting for async result. | 704 // waiting for async result. |
| 705 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 705 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
| 706 ASSERT_TRUE(RunJavascriptTest("testDone")); | 706 ASSERT_TRUE(RunJavascriptTest("testDone")); |
| 707 } | 707 } |
| OLD | NEW |