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/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "base/test/test_timeouts.h" | 24 #include "base/test/test_timeouts.h" |
25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
26 #include "base/values.h" | 26 #include "base/values.h" |
27 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 27 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
28 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 28 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
30 #include "chrome/browser/chrome_notification_types.h" | 30 #include "chrome/browser/chrome_notification_types.h" |
31 #include "chrome/browser/history/history_service_factory.h" | 31 #include "chrome/browser/history/history_service_factory.h" |
32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | |
34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | |
35 #include "chrome/browser/ui/browser.h" | 33 #include "chrome/browser/ui/browser.h" |
36 #include "chrome/browser/ui/browser_commands.h" | 34 #include "chrome/browser/ui/browser_commands.h" |
37 #include "chrome/browser/ui/browser_finder.h" | 35 #include "chrome/browser/ui/browser_finder.h" |
38 #include "chrome/browser/ui/browser_iterator.h" | 36 #include "chrome/browser/ui/browser_iterator.h" |
39 #include "chrome/browser/ui/browser_list.h" | 37 #include "chrome/browser/ui/browser_list.h" |
40 #include "chrome/browser/ui/browser_navigator.h" | 38 #include "chrome/browser/ui/browser_navigator.h" |
41 #include "chrome/browser/ui/browser_window.h" | 39 #include "chrome/browser/ui/browser_window.h" |
42 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 40 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
43 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 41 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
44 #include "chrome/browser/ui/host_desktop.h" | 42 #include "chrome/browser/ui/host_desktop.h" |
45 #include "chrome/browser/ui/location_bar/location_bar.h" | 43 #include "chrome/browser/ui/location_bar/location_bar.h" |
46 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 44 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
47 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
48 #include "chrome/common/chrome_paths.h" | 46 #include "chrome/common/chrome_paths.h" |
49 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
50 #include "chrome/test/base/find_in_page_observer.h" | 48 #include "chrome/test/base/find_in_page_observer.h" |
| 49 #include "components/app_modal_dialogs/app_modal_dialog.h" |
| 50 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" |
51 #include "components/bookmarks/browser/bookmark_model.h" | 51 #include "components/bookmarks/browser/bookmark_model.h" |
52 #include "components/search_engines/template_url_service.h" | 52 #include "components/search_engines/template_url_service.h" |
53 #include "content/public/browser/dom_operation_notification_details.h" | 53 #include "content/public/browser/dom_operation_notification_details.h" |
54 #include "content/public/browser/download_item.h" | 54 #include "content/public/browser/download_item.h" |
55 #include "content/public/browser/download_manager.h" | 55 #include "content/public/browser/download_manager.h" |
56 #include "content/public/browser/geolocation_provider.h" | 56 #include "content/public/browser/geolocation_provider.h" |
57 #include "content/public/browser/navigation_controller.h" | 57 #include "content/public/browser/navigation_controller.h" |
58 #include "content/public/browser/navigation_entry.h" | 58 #include "content/public/browser/navigation_entry.h" |
59 #include "content/public/browser/notification_service.h" | 59 #include "content/public/browser/notification_service.h" |
60 #include "content/public/browser/render_process_host.h" | 60 #include "content/public/browser/render_process_host.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 Browser* new_browser = GetBrowserNotInSet(excluded_browsers); | 100 Browser* new_browser = GetBrowserNotInSet(excluded_browsers); |
101 if (new_browser == NULL) { | 101 if (new_browser == NULL) { |
102 BrowserAddedObserver observer; | 102 BrowserAddedObserver observer; |
103 new_browser = observer.WaitForSingleNewBrowser(); | 103 new_browser = observer.WaitForSingleNewBrowser(); |
104 // The new browser should never be in |excluded_browsers|. | 104 // The new browser should never be in |excluded_browsers|. |
105 DCHECK(!ContainsKey(excluded_browsers, new_browser)); | 105 DCHECK(!ContainsKey(excluded_browsers, new_browser)); |
106 } | 106 } |
107 return new_browser; | 107 return new_browser; |
108 } | 108 } |
109 | 109 |
| 110 class AppModalDialogWaiter : public AppModalDialogObserver { |
| 111 public: |
| 112 AppModalDialogWaiter() |
| 113 : dialog_(NULL) { |
| 114 } |
| 115 ~AppModalDialogWaiter() override { |
| 116 } |
| 117 |
| 118 AppModalDialog* Wait() { |
| 119 if (dialog_) |
| 120 return dialog_; |
| 121 message_loop_runner_ = new content::MessageLoopRunner; |
| 122 message_loop_runner_->Run(); |
| 123 EXPECT_TRUE(dialog_); |
| 124 return dialog_; |
| 125 } |
| 126 |
| 127 // AppModalDialogWaiter: |
| 128 virtual void Notify(AppModalDialog* dialog) override { |
| 129 DCHECK(!dialog_); |
| 130 dialog_ = dialog; |
| 131 if (message_loop_runner_.get() && message_loop_runner_->loop_running()) |
| 132 message_loop_runner_->Quit(); |
| 133 } |
| 134 |
| 135 private: |
| 136 AppModalDialog* dialog_; |
| 137 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 138 |
| 139 DISALLOW_COPY_AND_ASSIGN(AppModalDialogWaiter); |
| 140 }; |
| 141 |
110 } // namespace | 142 } // namespace |
111 | 143 |
112 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { | 144 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { |
113 WebContents* web_contents = | 145 WebContents* web_contents = |
114 browser->tab_strip_model()->GetActiveWebContents(); | 146 browser->tab_strip_model()->GetActiveWebContents(); |
115 if (!web_contents) | 147 if (!web_contents) |
116 return false; | 148 return false; |
117 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); | 149 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); |
118 if (!last_entry) | 150 if (!last_entry) |
119 return false; | 151 return false; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); | 321 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); |
290 for (; match < exe_size; ++match) | 322 for (; match < exe_size; ++match) |
291 *build_dir = build_dir->Append(exe_parts[match]); | 323 *build_dir = build_dir->Append(exe_parts[match]); |
292 return true; | 324 return true; |
293 } | 325 } |
294 | 326 |
295 AppModalDialog* WaitForAppModalDialog() { | 327 AppModalDialog* WaitForAppModalDialog() { |
296 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 328 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
297 if (dialog_queue->HasActiveDialog()) | 329 if (dialog_queue->HasActiveDialog()) |
298 return dialog_queue->active_dialog(); | 330 return dialog_queue->active_dialog(); |
299 | 331 AppModalDialogWaiter waiter; |
300 content::WindowedNotificationObserver observer( | 332 return waiter.Wait(); |
301 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | |
302 content::NotificationService::AllSources()); | |
303 observer.Wait(); | |
304 return content::Source<AppModalDialog>(observer.source()).ptr(); | |
305 } | 333 } |
306 | 334 |
307 int FindInPage(WebContents* tab, | 335 int FindInPage(WebContents* tab, |
308 const base::string16& search_string, | 336 const base::string16& search_string, |
309 bool forward, | 337 bool forward, |
310 bool match_case, | 338 bool match_case, |
311 int* ordinal, | 339 int* ordinal, |
312 gfx::Rect* selection_rect) { | 340 gfx::Rect* selection_rect) { |
313 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); | 341 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); |
314 find_tab_helper->StartFinding(search_string, forward, match_case); | 342 find_tab_helper->StartFinding(search_string, forward, match_case); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 534 |
507 void HistoryEnumerator::HistoryQueryComplete( | 535 void HistoryEnumerator::HistoryQueryComplete( |
508 const base::Closure& quit_task, | 536 const base::Closure& quit_task, |
509 history::QueryResults* results) { | 537 history::QueryResults* results) { |
510 for (size_t i = 0; i < results->size(); ++i) | 538 for (size_t i = 0; i < results->size(); ++i) |
511 urls_.push_back((*results)[i].url()); | 539 urls_.push_back((*results)[i].url()); |
512 quit_task.Run(); | 540 quit_task.Run(); |
513 } | 541 } |
514 | 542 |
515 } // namespace ui_test_utils | 543 } // namespace ui_test_utils |
OLD | NEW |