Chromium Code Reviews| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 false /* not initially signaled */); | 398 false /* not initially signaled */); |
| 399 CHECK(content::BrowserThread::PostTask( | 399 CHECK(content::BrowserThread::PostTask( |
| 400 content::BrowserThread::IO, FROM_HERE, | 400 content::BrowserThread::IO, FROM_HERE, |
| 401 base::Bind(&GetCookiesOnIOThread, url, context_getter, &event, value))); | 401 base::Bind(&GetCookiesOnIOThread, url, context_getter, &event, value))); |
| 402 event.Wait(); | 402 event.Wait(); |
| 403 | 403 |
| 404 *value_size = static_cast<int>(value->size()); | 404 *value_size = static_cast<int>(value->size()); |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 | 407 |
| 408 bool RunLoopUntil(const base::Callback<bool()>& condition) { | |
| 409 const base::TimeTicks start_time = base::TimeTicks::Now(); | |
| 410 while (!condition.Run()) { | |
| 411 const base::TimeTicks current_time = base::TimeTicks::Now(); | |
| 412 if (current_time - start_time > base::TimeDelta::FromSeconds(5)) { | |
|
Lei Zhang
2015/10/21 07:24:52
Didn't some other test have a 10 second timeout? D
tommycli
2015/10/21 18:16:04
Yeah, one of them did. The ConstrainedDialog* test
| |
| 413 ADD_FAILURE() << "Condition not met within five seconds."; | |
| 414 return false; | |
| 415 } | |
| 416 | |
| 417 base::MessageLoop::current()->task_runner()->PostDelayedTask( | |
| 418 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | |
| 419 base::TimeDelta::FromMilliseconds(20)); | |
| 420 content::RunMessageLoop(); | |
| 421 } | |
| 422 return true; | |
| 423 } | |
| 424 | |
| 408 WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( | 425 WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( |
| 409 const content::NotificationSource& source) | 426 const content::NotificationSource& source) |
| 410 : WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source), | 427 : WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source), |
| 411 added_tab_(NULL) { | 428 added_tab_(NULL) { |
| 412 } | 429 } |
| 413 | 430 |
| 414 void WindowedTabAddedNotificationObserver::Observe( | 431 void WindowedTabAddedNotificationObserver::Observe( |
| 415 int type, | 432 int type, |
| 416 const content::NotificationSource& source, | 433 const content::NotificationSource& source, |
| 417 const content::NotificationDetails& details) { | 434 const content::NotificationDetails& details) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 new content::MessageLoopRunner; | 543 new content::MessageLoopRunner; |
| 527 WaitHistoryLoadedObserver observer(runner.get()); | 544 WaitHistoryLoadedObserver observer(runner.get()); |
| 528 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 545 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 529 scoped_observer(&observer); | 546 scoped_observer(&observer); |
| 530 scoped_observer.Add(history_service); | 547 scoped_observer.Add(history_service); |
| 531 runner->Run(); | 548 runner->Run(); |
| 532 } | 549 } |
| 533 } | 550 } |
| 534 | 551 |
| 535 } // namespace ui_test_utils | 552 } // namespace ui_test_utils |
| OLD | NEW |