| 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 "base/bind.h" | 5 #include "base/bind.h" | 
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" | 
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" | 
|  | 8 #include "base/run_loop.h" | 
|  | 9 #include "base/single_thread_task_runner.h" | 
| 8 #include "remoting/base/auto_thread_task_runner.h" | 10 #include "remoting/base/auto_thread_task_runner.h" | 
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" | 
| 10 | 12 | 
| 11 namespace { | 13 namespace { | 
| 12 | 14 | 
| 13 void SetFlagTask(bool* success) { | 15 void SetFlagTask(bool* success) { | 
| 14   *success = true; | 16   *success = true; | 
| 15 } | 17 } | 
| 16 | 18 | 
| 17 }  // namespace | 19 }  // namespace | 
| 18 | 20 | 
| 19 namespace remoting { | 21 namespace remoting { | 
| 20 | 22 | 
| 21 TEST(AutoThreadTaskRunnerTest, StartAndStop) { | 23 TEST(AutoThreadTaskRunnerTest, StartAndStop) { | 
| 22   // Create a task runner. | 24   // Create a task runner. | 
| 23   base::MessageLoop message_loop; | 25   base::MessageLoop message_loop; | 
| 24   scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( | 26   scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner( | 
| 25       message_loop.task_runner(), base::MessageLoop::QuitWhenIdleClosure()); | 27       message_loop.task_runner(), base::MessageLoop::QuitWhenIdleClosure()); | 
| 26 | 28 | 
| 27   // Post a task to make sure it is executed. | 29   // Post a task to make sure it is executed. | 
| 28   bool success = false; | 30   bool success = false; | 
| 29   message_loop.PostTask(FROM_HERE, base::Bind(&SetFlagTask, &success)); | 31   message_loop.task_runner()->PostTask(FROM_HERE, | 
|  | 32                                        base::Bind(&SetFlagTask, &success)); | 
| 30 | 33 | 
| 31   task_runner = NULL; | 34   task_runner = NULL; | 
| 32   message_loop.Run(); | 35   base::RunLoop().Run(); | 
| 33   EXPECT_TRUE(success); | 36   EXPECT_TRUE(success); | 
| 34 } | 37 } | 
| 35 | 38 | 
| 36 }  // namespace remoting | 39 }  // namespace remoting | 
| OLD | NEW | 
|---|