OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webrtc/base/task_queue.h" | |
17 #include "webrtc/base/timeutils.h" | 16 #include "webrtc/base/timeutils.h" |
18 #include "webrtc/modules/include/module.h" | 17 #include "webrtc/modules/include/module.h" |
19 #include "webrtc/modules/utility/source/process_thread_impl.h" | 18 #include "webrtc/modules/utility/source/process_thread_impl.h" |
20 | 19 |
21 namespace webrtc { | 20 namespace webrtc { |
22 | 21 |
23 using ::testing::_; | 22 using ::testing::_; |
24 using ::testing::DoAll; | 23 using ::testing::DoAll; |
25 using ::testing::InSequence; | 24 using ::testing::InSequence; |
26 using ::testing::Invoke; | 25 using ::testing::Invoke; |
27 using ::testing::Return; | 26 using ::testing::Return; |
28 using ::testing::SetArgPointee; | 27 using ::testing::SetArgPointee; |
29 | 28 |
30 class MockModule : public Module { | 29 class MockModule : public Module { |
31 public: | 30 public: |
32 MOCK_METHOD0(TimeUntilNextProcess, int64_t()); | 31 MOCK_METHOD0(TimeUntilNextProcess, int64_t()); |
33 MOCK_METHOD0(Process, void()); | 32 MOCK_METHOD0(Process, void()); |
34 MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*)); | 33 MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*)); |
35 }; | 34 }; |
36 | 35 |
37 class RaiseEventTask : public rtc::QueuedTask { | 36 class RaiseEventTask : public ProcessTask { |
38 public: | 37 public: |
39 RaiseEventTask(EventWrapper* event) : event_(event) {} | 38 RaiseEventTask(EventWrapper* event) : event_(event) {} |
40 bool Run() override { | 39 void Run() override { event_->Set(); } |
41 event_->Set(); | |
42 return true; | |
43 } | |
44 | 40 |
45 private: | 41 private: |
46 EventWrapper* event_; | 42 EventWrapper* event_; |
47 }; | 43 }; |
48 | 44 |
49 ACTION_P(SetEvent, event) { | 45 ACTION_P(SetEvent, event) { |
50 event->Set(); | 46 event->Set(); |
51 } | 47 } |
52 | 48 |
53 ACTION_P(Increment, counter) { | 49 ACTION_P(Increment, counter) { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 ProcessThreadImpl thread("ProcessThread"); | 296 ProcessThreadImpl thread("ProcessThread"); |
301 std::unique_ptr<EventWrapper> task_ran(EventWrapper::Create()); | 297 std::unique_ptr<EventWrapper> task_ran(EventWrapper::Create()); |
302 std::unique_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get())); | 298 std::unique_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get())); |
303 thread.Start(); | 299 thread.Start(); |
304 thread.PostTask(std::move(task)); | 300 thread.PostTask(std::move(task)); |
305 EXPECT_EQ(kEventSignaled, task_ran->Wait(100)); | 301 EXPECT_EQ(kEventSignaled, task_ran->Wait(100)); |
306 thread.Stop(); | 302 thread.Stop(); |
307 } | 303 } |
308 | 304 |
309 } // namespace webrtc | 305 } // namespace webrtc |
OLD | NEW |