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 "jingle/glue/task_pump.h" | 5 #include "jingle/glue/task_pump.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "jingle/glue/mock_task.h" | 8 #include "jingle/glue/mock_task.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace jingle_glue { | 11 namespace jingle_glue { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 using ::testing::Return; | 15 using ::testing::Return; |
16 | 16 |
17 class TaskPumpTest : public testing::Test { | 17 class TaskPumpTest : public testing::Test { |
18 private: | 18 private: |
19 base::MessageLoop message_loop_; | 19 base::MessageLoop message_loop_; |
20 }; | 20 }; |
21 | 21 |
22 TEST_F(TaskPumpTest, Basic) { | 22 TEST_F(TaskPumpTest, Basic) { |
23 TaskPump task_pump; | 23 TaskPump task_pump; |
24 MockTask* task = new MockTask(&task_pump); | 24 MockTask* task = new MockTask(&task_pump); |
25 // We have to do this since the state enum is protected in | 25 // We have to do this since the state enum is protected in |
26 // talk_base::Task. | 26 // rtc::Task. |
27 const int TASK_STATE_DONE = 2; | 27 const int TASK_STATE_DONE = 2; |
28 EXPECT_CALL(*task, ProcessStart()).WillOnce(Return(TASK_STATE_DONE)); | 28 EXPECT_CALL(*task, ProcessStart()).WillOnce(Return(TASK_STATE_DONE)); |
29 task->Start(); | 29 task->Start(); |
30 | 30 |
31 base::MessageLoop::current()->RunUntilIdle(); | 31 base::MessageLoop::current()->RunUntilIdle(); |
32 } | 32 } |
33 | 33 |
34 TEST_F(TaskPumpTest, Stop) { | 34 TEST_F(TaskPumpTest, Stop) { |
35 TaskPump task_pump; | 35 TaskPump task_pump; |
36 MockTask* task = new MockTask(&task_pump); | 36 MockTask* task = new MockTask(&task_pump); |
37 // We have to do this since the state enum is protected in | 37 // We have to do this since the state enum is protected in |
38 // talk_base::Task. | 38 // rtc::Task. |
39 const int TASK_STATE_ERROR = 3; | 39 const int TASK_STATE_ERROR = 3; |
40 ON_CALL(*task, ProcessStart()).WillByDefault(Return(TASK_STATE_ERROR)); | 40 ON_CALL(*task, ProcessStart()).WillByDefault(Return(TASK_STATE_ERROR)); |
41 EXPECT_CALL(*task, ProcessStart()).Times(0); | 41 EXPECT_CALL(*task, ProcessStart()).Times(0); |
42 task->Start(); | 42 task->Start(); |
43 | 43 |
44 task_pump.Stop(); | 44 task_pump.Stop(); |
45 base::MessageLoop::current()->RunUntilIdle(); | 45 base::MessageLoop::current()->RunUntilIdle(); |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 } // namespace jingle_glue | 50 } // namespace jingle_glue |
OLD | NEW |