[email protected] | ef948e6 | 2012-09-04 22:27:43 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "base/bind.h" | ||||
6 | #include "base/memory/ref_counted.h" | ||||
[email protected] | f368eeb | 2013-07-17 23:53:32 | [diff] [blame^] | 7 | #include "base/message_loop/message_loop.h" |
[email protected] | ef948e6 | 2012-09-04 22:27:43 | [diff] [blame] | 8 | #include "remoting/base/auto_thread_task_runner.h" |
9 | #include "testing/gtest/include/gtest/gtest.h" | ||||
10 | |||||
11 | namespace { | ||||
12 | |||||
[email protected] | 3d871d9 | 2012-12-07 07:36:45 | [diff] [blame] | 13 | void SetFlagTask(bool* success) { |
[email protected] | ef948e6 | 2012-09-04 22:27:43 | [diff] [blame] | 14 | *success = true; |
15 | } | ||||
16 | |||||
17 | } // namespace | ||||
18 | |||||
19 | namespace remoting { | ||||
20 | |||||
[email protected] | 3d871d9 | 2012-12-07 07:36:45 | [diff] [blame] | 21 | TEST(AutoThreadTaskRunnerTest, StartAndStop) { |
[email protected] | ef948e6 | 2012-09-04 22:27:43 | [diff] [blame] | 22 | // Create a task runner. |
[email protected] | faea9d2d | 2013-04-30 03:18:44 | [diff] [blame] | 23 | base::MessageLoop message_loop; |
24 | scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( | ||||
25 | message_loop.message_loop_proxy(), base::MessageLoop::QuitClosure()); | ||||
[email protected] | ef948e6 | 2012-09-04 22:27:43 | [diff] [blame] | 26 | |
27 | // Post a task to make sure it is executed. | ||||
28 | bool success = false; | ||||
[email protected] | 3d871d9 | 2012-12-07 07:36:45 | [diff] [blame] | 29 | message_loop.PostTask(FROM_HERE, base::Bind(&SetFlagTask, &success)); |
[email protected] | ef948e6 | 2012-09-04 22:27:43 | [diff] [blame] | 30 | |
31 | task_runner = NULL; | ||||
32 | message_loop.Run(); | ||||
33 | EXPECT_TRUE(success); | ||||
34 | } | ||||
35 | |||||
[email protected] | ef948e6 | 2012-09-04 22:27:43 | [diff] [blame] | 36 | } // namespace remoting |