| 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" |
| 16 #include "webrtc/base/timeutils.h" | 17 #include "webrtc/base/timeutils.h" |
| 17 #include "webrtc/modules/include/module.h" | 18 #include "webrtc/modules/include/module.h" |
| 18 #include "webrtc/modules/utility/source/process_thread_impl.h" | 19 #include "webrtc/modules/utility/source/process_thread_impl.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| 22 using ::testing::_; | 23 using ::testing::_; |
| 23 using ::testing::DoAll; | 24 using ::testing::DoAll; |
| 24 using ::testing::InSequence; | 25 using ::testing::InSequence; |
| 25 using ::testing::Invoke; | 26 using ::testing::Invoke; |
| 26 using ::testing::Return; | 27 using ::testing::Return; |
| 27 using ::testing::SetArgPointee; | 28 using ::testing::SetArgPointee; |
| 28 | 29 |
| 29 class MockModule : public Module { | 30 class MockModule : public Module { |
| 30 public: | 31 public: |
| 31 MOCK_METHOD0(TimeUntilNextProcess, int64_t()); | 32 MOCK_METHOD0(TimeUntilNextProcess, int64_t()); |
| 32 MOCK_METHOD0(Process, void()); | 33 MOCK_METHOD0(Process, void()); |
| 33 MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*)); | 34 MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*)); |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 class RaiseEventTask : public ProcessTask { | 37 class RaiseEventTask : public rtc::QueuedTask { |
| 37 public: | 38 public: |
| 38 RaiseEventTask(EventWrapper* event) : event_(event) {} | 39 RaiseEventTask(EventWrapper* event) : event_(event) {} |
| 39 void Run() override { event_->Set(); } | 40 bool Run() override { |
| 41 event_->Set(); |
| 42 return true; |
| 43 } |
| 40 | 44 |
| 41 private: | 45 private: |
| 42 EventWrapper* event_; | 46 EventWrapper* event_; |
| 43 }; | 47 }; |
| 44 | 48 |
| 45 ACTION_P(SetEvent, event) { | 49 ACTION_P(SetEvent, event) { |
| 46 event->Set(); | 50 event->Set(); |
| 47 } | 51 } |
| 48 | 52 |
| 49 ACTION_P(Increment, counter) { | 53 ACTION_P(Increment, counter) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 ProcessThreadImpl thread("ProcessThread"); | 300 ProcessThreadImpl thread("ProcessThread"); |
| 297 std::unique_ptr<EventWrapper> task_ran(EventWrapper::Create()); | 301 std::unique_ptr<EventWrapper> task_ran(EventWrapper::Create()); |
| 298 std::unique_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get())); | 302 std::unique_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get())); |
| 299 thread.Start(); | 303 thread.Start(); |
| 300 thread.PostTask(std::move(task)); | 304 thread.PostTask(std::move(task)); |
| 301 EXPECT_EQ(kEventSignaled, task_ran->Wait(100)); | 305 EXPECT_EQ(kEventSignaled, task_ran->Wait(100)); |
| 302 thread.Stop(); | 306 thread.Stop(); |
| 303 } | 307 } |
| 304 | 308 |
| 305 } // namespace webrtc | 309 } // namespace webrtc |
| OLD | NEW |