| 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 89 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 { | 110 class AppModalDialogWaiter : public app_modal_dialogs::AppModalDialogObserver { |
| 111 public: | 111 public: |
| 112 AppModalDialogWaiter() | 112 AppModalDialogWaiter() |
| 113 : dialog_(NULL) { | 113 : dialog_(NULL) { |
| 114 } | 114 } |
| 115 ~AppModalDialogWaiter() override { | 115 ~AppModalDialogWaiter() override { |
| 116 } | 116 } |
| 117 | 117 |
| 118 AppModalDialog* Wait() { | 118 app_modal_dialogs::AppModalDialog* Wait() { |
| 119 if (dialog_) | 119 if (dialog_) |
| 120 return dialog_; | 120 return dialog_; |
| 121 message_loop_runner_ = new content::MessageLoopRunner; | 121 message_loop_runner_ = new content::MessageLoopRunner; |
| 122 message_loop_runner_->Run(); | 122 message_loop_runner_->Run(); |
| 123 EXPECT_TRUE(dialog_); | 123 EXPECT_TRUE(dialog_); |
| 124 return dialog_; | 124 return dialog_; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // AppModalDialogWaiter: | 127 // AppModalDialogWaiter: |
| 128 void Notify(AppModalDialog* dialog) override { | 128 void Notify(app_modal_dialogs::AppModalDialog* dialog) override { |
| 129 DCHECK(!dialog_); | 129 DCHECK(!dialog_); |
| 130 dialog_ = dialog; | 130 dialog_ = dialog; |
| 131 if (message_loop_runner_.get() && message_loop_runner_->loop_running()) | 131 if (message_loop_runner_.get() && message_loop_runner_->loop_running()) |
| 132 message_loop_runner_->Quit(); | 132 message_loop_runner_->Quit(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 AppModalDialog* dialog_; | 136 app_modal_dialogs::AppModalDialog* dialog_; |
| 137 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 137 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 138 | 138 |
| 139 DISALLOW_COPY_AND_ASSIGN(AppModalDialogWaiter); | 139 DISALLOW_COPY_AND_ASSIGN(AppModalDialogWaiter); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 } // namespace | 142 } // namespace |
| 143 | 143 |
| 144 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { | 144 bool GetCurrentTabTitle(const Browser* browser, base::string16* title) { |
| 145 WebContents* web_contents = | 145 WebContents* web_contents = |
| 146 browser->tab_strip_model()->GetActiveWebContents(); | 146 browser->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 317 |
| 318 // Create a relative path. | 318 // Create a relative path. |
| 319 *build_dir = base::FilePath(); | 319 *build_dir = base::FilePath(); |
| 320 for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) | 320 for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) |
| 321 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); | 321 *build_dir = build_dir->Append(FILE_PATH_LITERAL("..")); |
| 322 for (; match < exe_size; ++match) | 322 for (; match < exe_size; ++match) |
| 323 *build_dir = build_dir->Append(exe_parts[match]); | 323 *build_dir = build_dir->Append(exe_parts[match]); |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 AppModalDialog* WaitForAppModalDialog() { | 327 app_modal_dialogs::AppModalDialog* WaitForAppModalDialog() { |
| 328 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 328 app_modal_dialogs::AppModalDialogQueue* dialog_queue = |
| 329 app_modal_dialogs::AppModalDialogQueue::GetInstance(); |
| 329 if (dialog_queue->HasActiveDialog()) | 330 if (dialog_queue->HasActiveDialog()) |
| 330 return dialog_queue->active_dialog(); | 331 return dialog_queue->active_dialog(); |
| 331 AppModalDialogWaiter waiter; | 332 AppModalDialogWaiter waiter; |
| 332 return waiter.Wait(); | 333 return waiter.Wait(); |
| 333 } | 334 } |
| 334 | 335 |
| 335 int FindInPage(WebContents* tab, | 336 int FindInPage(WebContents* tab, |
| 336 const base::string16& search_string, | 337 const base::string16& search_string, |
| 337 bool forward, | 338 bool forward, |
| 338 bool match_case, | 339 bool match_case, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 535 |
| 535 void HistoryEnumerator::HistoryQueryComplete( | 536 void HistoryEnumerator::HistoryQueryComplete( |
| 536 const base::Closure& quit_task, | 537 const base::Closure& quit_task, |
| 537 history::QueryResults* results) { | 538 history::QueryResults* results) { |
| 538 for (size_t i = 0; i < results->size(); ++i) | 539 for (size_t i = 0; i < results->size(); ++i) |
| 539 urls_.push_back((*results)[i].url()); | 540 urls_.push_back((*results)[i].url()); |
| 540 quit_task.Run(); | 541 quit_task.Run(); |
| 541 } | 542 } |
| 542 | 543 |
| 543 } // namespace ui_test_utils | 544 } // namespace ui_test_utils |
| OLD | NEW |