| 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 "content/public/test/content_browser_test_utils.h" | 5 #include "content/public/test/content_browser_test_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "content/browser/frame_host/frame_tree_node.h" |
| 12 #include "content/browser/frame_host/navigator.h" |
| 11 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
| 12 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
| 13 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/common/content_paths.h" | 16 #include "content/public/common/content_paths.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
| 16 #include "content/public/test/test_navigation_observer.h" | 18 #include "content/public/test/test_navigation_observer.h" |
| 17 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
| 18 #include "content/shell/browser/shell.h" | 20 #include "content/shell/browser/shell.h" |
| 19 #include "content/shell/browser/shell_javascript_dialog_manager.h" | 21 #include "content/shell/browser/shell_javascript_dialog_manager.h" |
| 22 #include "content/test/test_frame_navigation_observer.h" |
| 20 #include "net/base/filename_util.h" | 23 #include "net/base/filename_util.h" |
| 21 | 24 |
| 22 namespace content { | 25 namespace content { |
| 23 | 26 |
| 24 base::FilePath GetTestFilePath(const char* dir, const char* file) { | 27 base::FilePath GetTestFilePath(const char* dir, const char* file) { |
| 25 base::FilePath path; | 28 base::FilePath path; |
| 26 PathService::Get(DIR_TEST_DATA, &path); | 29 PathService::Get(DIR_TEST_DATA, &path); |
| 27 return path.Append(base::FilePath().AppendASCII(dir).Append( | 30 return path.Append(base::FilePath().AppendASCII(dir).Append( |
| 28 base::FilePath().AppendASCII(file))); | 31 base::FilePath().AppendASCII(file))); |
| 29 } | 32 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 49 TestNavigationObserver same_tab_observer(window->web_contents(), 1); | 52 TestNavigationObserver same_tab_observer(window->web_contents(), 1); |
| 50 | 53 |
| 51 window->LoadDataWithBaseURL(url, data, base_url); | 54 window->LoadDataWithBaseURL(url, data, base_url); |
| 52 same_tab_observer.Wait(); | 55 same_tab_observer.Wait(); |
| 53 } | 56 } |
| 54 | 57 |
| 55 void NavigateToURL(Shell* window, const GURL& url) { | 58 void NavigateToURL(Shell* window, const GURL& url) { |
| 56 NavigateToURLBlockUntilNavigationsComplete(window, url, 1); | 59 NavigateToURLBlockUntilNavigationsComplete(window, url, 1); |
| 57 } | 60 } |
| 58 | 61 |
| 62 void NavigateFrameToURL(FrameTreeNode* node, const GURL& url) { |
| 63 TestFrameNavigationObserver observer(node); |
| 64 NavigationController::LoadURLParams params(url); |
| 65 params.transition_type = PageTransitionFromInt(PAGE_TRANSITION_LINK); |
| 66 params.frame_tree_node_id = node->frame_tree_node_id(); |
| 67 node->navigator()->GetController()->LoadURLWithParams(params); |
| 68 observer.Wait(); |
| 69 } |
| 70 |
| 59 void WaitForAppModalDialog(Shell* window) { | 71 void WaitForAppModalDialog(Shell* window) { |
| 60 ShellJavaScriptDialogManager* dialog_manager= | 72 ShellJavaScriptDialogManager* dialog_manager= |
| 61 static_cast<ShellJavaScriptDialogManager*>( | 73 static_cast<ShellJavaScriptDialogManager*>( |
| 62 window->GetJavaScriptDialogManager()); | 74 window->GetJavaScriptDialogManager()); |
| 63 | 75 |
| 64 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); | 76 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); |
| 65 dialog_manager->set_dialog_request_callback(runner->QuitClosure()); | 77 dialog_manager->set_dialog_request_callback(runner->QuitClosure()); |
| 66 runner->Run(); | 78 runner->Run(); |
| 67 } | 79 } |
| 68 | 80 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 } | 97 } |
| 86 | 98 |
| 87 void ShellAddedObserver::ShellCreated(Shell* shell) { | 99 void ShellAddedObserver::ShellCreated(Shell* shell) { |
| 88 DCHECK(!shell_); | 100 DCHECK(!shell_); |
| 89 shell_ = shell; | 101 shell_ = shell; |
| 90 if (runner_.get()) | 102 if (runner_.get()) |
| 91 runner_->QuitClosure().Run(); | 103 runner_->QuitClosure().Run(); |
| 92 } | 104 } |
| 93 | 105 |
| 94 } // namespace content | 106 } // namespace content |
| OLD | NEW |