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 AppModalDialogNotifier { | |
111 public: | |
112 AppModalDialogWaiter() | |
113 : dialog_(NULL) { | |
114 } | |
115 virtual ~AppModalDialogWaiter() { | |
msw
2014/10/23 18:41:21
nit: I think even this can be marked override with
oshima
2014/10/23 21:44:18
Done.
| |
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()) | |
msw
2014/10/23 18:41:21
nit: reverse to conditionally Quit().
oshima
2014/10/23 21:44:18
Done.
| |
132 return; | |
133 message_loop_runner_->Quit(); | |
134 } | |
135 | |
136 private: | |
137 AppModalDialog* dialog_; | |
138 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | |
139 | |
140 DISALLOW_COPY_AND_ASSIGN(AppModalDialogWaiter); | |
141 }; | |
142 | |
110 } // namespace | 143 } // namespace |
111 | 144 |
112 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { | 145 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { |
113 WebContents* web_contents = | 146 WebContents* web_contents = |
114 browser->tab_strip_model()->GetActiveWebContents(); | 147 browser->tab_strip_model()->GetActiveWebContents(); |
115 if (!web_contents) | 148 if (!web_contents) |
116 return false; | 149 return false; |
117 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); | 150 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); |
118 if (!last_entry) | 151 if (!last_entry) |
119 return false; | 152 return false; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); | 322 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); |
290 for (; match < exe_size; ++match) | 323 for (; match < exe_size; ++match) |
291 *build_dir = build_dir->Append(exe_parts[match]); | 324 *build_dir = build_dir->Append(exe_parts[match]); |
292 return true; | 325 return true; |
293 } | 326 } |
294 | 327 |
295 AppModalDialog* WaitForAppModalDialog() { | 328 AppModalDialog* WaitForAppModalDialog() { |
296 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 329 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
297 if (dialog_queue->HasActiveDialog()) | 330 if (dialog_queue->HasActiveDialog()) |
298 return dialog_queue->active_dialog(); | 331 return dialog_queue->active_dialog(); |
299 | 332 AppModalDialogWaiter waiter; |
300 content::WindowedNotificationObserver observer( | 333 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 } | 334 } |
306 | 335 |
307 int FindInPage(WebContents* tab, | 336 int FindInPage(WebContents* tab, |
308 const base::string16& search_string, | 337 const base::string16& search_string, |
309 bool forward, | 338 bool forward, |
310 bool match_case, | 339 bool match_case, |
311 int* ordinal, | 340 int* ordinal, |
312 gfx::Rect* selection_rect) { | 341 gfx::Rect* selection_rect) { |
313 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); | 342 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); |
314 find_tab_helper->StartFinding(search_string, forward, match_case); | 343 find_tab_helper->StartFinding(search_string, forward, match_case); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 | 535 |
507 void HistoryEnumerator::HistoryQueryComplete( | 536 void HistoryEnumerator::HistoryQueryComplete( |
508 const base::Closure& quit_task, | 537 const base::Closure& quit_task, |
509 history::QueryResults* results) { | 538 history::QueryResults* results) { |
510 for (size_t i = 0; i < results->size(); ++i) | 539 for (size_t i = 0; i < results->size(); ++i) |
511 urls_.push_back((*results)[i].url()); | 540 urls_.push_back((*results)[i].url()); |
512 quit_task.Run(); | 541 quit_task.Run(); |
513 } | 542 } |
514 | 543 |
515 } // namespace ui_test_utils | 544 } // namespace ui_test_utils |
OLD | NEW |