OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/ui_test_utils.h" | 5 #include "chrome/test/ui_test_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 void RegisterAndWait(NotificationType::Type type, | 496 void RegisterAndWait(NotificationType::Type type, |
497 NotificationObserver* observer, | 497 NotificationObserver* observer, |
498 int64 timeout_ms) { | 498 int64 timeout_ms) { |
499 NotificationRegistrar registrar; | 499 NotificationRegistrar registrar; |
500 registrar.Add(observer, type, NotificationService::AllSources()); | 500 registrar.Add(observer, type, NotificationService::AllSources()); |
501 MessageLoop::current()->PostDelayedTask( | 501 MessageLoop::current()->PostDelayedTask( |
502 FROM_HERE, new MessageLoop::QuitTask, timeout_ms); | 502 FROM_HERE, new MessageLoop::QuitTask, timeout_ms); |
503 RunMessageLoop(); | 503 RunMessageLoop(); |
504 } | 504 } |
505 | 505 |
| 506 TimedMessageLoopRunner::TimedMessageLoopRunner() |
| 507 : loop_(new MessageLoopForUI()), |
| 508 owned_(true) { |
| 509 } |
| 510 |
| 511 TimedMessageLoopRunner::~TimedMessageLoopRunner() { |
| 512 if (owned_) |
| 513 delete loop_; |
| 514 } |
| 515 |
| 516 void TimedMessageLoopRunner::RunFor(int ms) { |
| 517 QuitAfter(ms); |
| 518 loop_->Run(); |
| 519 } |
| 520 |
| 521 void TimedMessageLoopRunner::Quit() { |
| 522 loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
| 523 } |
| 524 |
| 525 void TimedMessageLoopRunner::QuitAfter(int ms) { |
| 526 loop_->PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, ms); |
| 527 } |
| 528 |
506 } // namespace ui_test_utils | 529 } // namespace ui_test_utils |
OLD | NEW |