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 AppModalDialogWaiterImpl : public AppModalDialogWaiter { |
| 111 public: |
| 112 AppModalDialogWaiterImpl() |
| 113 : dialog_(NULL), |
| 114 running_(false) { |
| 115 } |
| 116 virtual ~AppModalDialogWaiterImpl() { |
| 117 } |
| 118 |
| 119 // AppModalDialogWaiter: |
| 120 virtual AppModalDialog* Wait() override { |
| 121 if (dialog_) |
| 122 return dialog_; |
| 123 running_ = true; |
| 124 message_loop_runner_ = new content::MessageLoopRunner; |
| 125 message_loop_runner_->Run(); |
| 126 EXPECT_TRUE(dialog_); |
| 127 return dialog_; |
| 128 } |
| 129 |
| 130 virtual void Notify(AppModalDialog* dialog) override { |
| 131 DCHECK(!dialog_); |
| 132 dialog_ = dialog; |
| 133 if (!running_) |
| 134 return; |
| 135 message_loop_runner_->Quit(); |
| 136 running_ = false; |
| 137 } |
| 138 |
| 139 private: |
| 140 AppModalDialog* dialog_; |
| 141 bool running_; |
| 142 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(AppModalDialogWaiterImpl); |
| 145 }; |
| 146 |
110 } // namespace | 147 } // namespace |
111 | 148 |
112 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { | 149 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { |
113 WebContents* web_contents = | 150 WebContents* web_contents = |
114 browser->tab_strip_model()->GetActiveWebContents(); | 151 browser->tab_strip_model()->GetActiveWebContents(); |
115 if (!web_contents) | 152 if (!web_contents) |
116 return false; | 153 return false; |
117 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); | 154 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); |
118 if (!last_entry) | 155 if (!last_entry) |
119 return false; | 156 return false; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 322 |
286 // Create a relative path. | 323 // Create a relative path. |
287 *build_dir = base::FilePath(); | 324 *build_dir = base::FilePath(); |
288 for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) | 325 for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) |
289 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); | 326 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); |
290 for (; match < exe_size; ++match) | 327 for (; match < exe_size; ++match) |
291 *build_dir = build_dir->Append(exe_parts[match]); | 328 *build_dir = build_dir->Append(exe_parts[match]); |
292 return true; | 329 return true; |
293 } | 330 } |
294 | 331 |
| 332 scoped_ptr<AppModalDialogWaiter> CreateAppModalDialogWaiter() { |
| 333 return make_scoped_ptr(new AppModalDialogWaiterImpl()); |
| 334 } |
| 335 |
295 AppModalDialog* WaitForAppModalDialog() { | 336 AppModalDialog* WaitForAppModalDialog() { |
296 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 337 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
297 if (dialog_queue->HasActiveDialog()) | 338 if (dialog_queue->HasActiveDialog()) |
298 return dialog_queue->active_dialog(); | 339 return dialog_queue->active_dialog(); |
299 | 340 return CreateAppModalDialogWaiter()->Wait(); |
300 content::WindowedNotificationObserver observer( | |
301 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | |
302 content::NotificationService::AllSources()); | |
303 observer.Wait(); | |
304 return content::Source<AppModalDialog>(observer.source()).ptr(); | |
305 } | 341 } |
306 | 342 |
307 int FindInPage(WebContents* tab, | 343 int FindInPage(WebContents* tab, |
308 const base::string16& search_string, | 344 const base::string16& search_string, |
309 bool forward, | 345 bool forward, |
310 bool match_case, | 346 bool match_case, |
311 int* ordinal, | 347 int* ordinal, |
312 gfx::Rect* selection_rect) { | 348 gfx::Rect* selection_rect) { |
313 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); | 349 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); |
314 find_tab_helper->StartFinding(search_string, forward, match_case); | 350 find_tab_helper->StartFinding(search_string, forward, match_case); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 542 |
507 void HistoryEnumerator::HistoryQueryComplete( | 543 void HistoryEnumerator::HistoryQueryComplete( |
508 const base::Closure& quit_task, | 544 const base::Closure& quit_task, |
509 history::QueryResults* results) { | 545 history::QueryResults* results) { |
510 for (size_t i = 0; i < results->size(); ++i) | 546 for (size_t i = 0; i < results->size(); ++i) |
511 urls_.push_back((*results)[i].url()); | 547 urls_.push_back((*results)[i].url()); |
512 quit_task.Run(); | 548 quit_task.Run(); |
513 } | 549 } |
514 | 550 |
515 } // namespace ui_test_utils | 551 } // namespace ui_test_utils |
OLD | NEW |