Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/public/cpp/utility/run_loop.h" | 5 #include "mojo/public/cpp/utility/run_loop.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "mojo/public/cpp/system/core.h" | 9 #include "mojo/public/cpp/system/core.h" |
| 10 #include "mojo/public/cpp/test_support/test_utils.h" | 10 #include "mojo/public/cpp/test_support/test_utils.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 run_loop.PostDelayedTask(Closure(Task(2, &sequence)), 0); | 406 run_loop.PostDelayedTask(Closure(Task(2, &sequence)), 0); |
| 407 run_loop.PostDelayedTask(Closure(Task(3, &sequence)), 0); | 407 run_loop.PostDelayedTask(Closure(Task(3, &sequence)), 0); |
| 408 run_loop.RunUntilIdle(); | 408 run_loop.RunUntilIdle(); |
| 409 | 409 |
| 410 ASSERT_EQ(3u, sequence.size()); | 410 ASSERT_EQ(3u, sequence.size()); |
| 411 EXPECT_EQ(1, sequence[0]); | 411 EXPECT_EQ(1, sequence[0]); |
| 412 EXPECT_EQ(2, sequence[1]); | 412 EXPECT_EQ(2, sequence[1]); |
| 413 EXPECT_EQ(3, sequence[2]); | 413 EXPECT_EQ(3, sequence[2]); |
| 414 } | 414 } |
| 415 | 415 |
| 416 struct QuittingTask { | |
| 417 QuittingTask(RunLoop* run_loop) : run_loop(run_loop) {} | |
|
jamesr
2014/09/24 08:04:32
explicit
qsr
2014/09/24 09:14:15
Done.
| |
| 418 | |
| 419 void Run() const { run_loop->Quit(); } | |
| 420 | |
| 421 RunLoop* run_loop; | |
| 422 }; | |
| 423 | |
| 424 TEST_F(RunLoopTest, QuitFromDelayedTask) { | |
| 425 TestRunLoopHandler handler; | |
| 426 MessagePipe test_pipe; | |
| 427 RunLoop run_loop; | |
| 428 run_loop.AddHandler(&handler, | |
| 429 test_pipe.handle0.get(), | |
| 430 MOJO_HANDLE_SIGNAL_READABLE, | |
| 431 MOJO_DEADLINE_INDEFINITE); | |
| 432 run_loop.PostDelayedTask(Closure(QuittingTask(&run_loop)), 0); | |
| 433 run_loop.Run(); | |
| 434 } | |
| 435 | |
| 416 } // namespace | 436 } // namespace |
| 417 } // namespace mojo | 437 } // namespace mojo |
| OLD | NEW |