OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project 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 "include/v8-platform.h" |
| 6 #include "src/libplatform/task-queue.h" |
| 7 #include "src/libplatform/worker-thread.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 |
| 10 using testing::InSequence; |
| 11 using testing::IsNull; |
| 12 using testing::StrictMock; |
| 13 |
| 14 namespace v8 { |
| 15 namespace platform { |
| 16 |
| 17 namespace { |
| 18 |
| 19 struct MockTask : public Task { |
| 20 virtual ~MockTask() { Die(); } |
| 21 MOCK_METHOD0(Run, void()); |
| 22 MOCK_METHOD0(Die, void()); |
| 23 }; |
| 24 |
| 25 } // namespace |
| 26 |
| 27 |
| 28 TEST(WorkerThreadTest, Basic) { |
| 29 static const size_t kNumTasks = 10; |
| 30 |
| 31 TaskQueue queue; |
| 32 for (size_t i = 0; i < kNumTasks; ++i) { |
| 33 InSequence s; |
| 34 StrictMock<MockTask>* task = new StrictMock<MockTask>; |
| 35 EXPECT_CALL(*task, Run()); |
| 36 EXPECT_CALL(*task, Die()); |
| 37 queue.Append(task); |
| 38 } |
| 39 |
| 40 WorkerThread thread1(&queue); |
| 41 WorkerThread thread2(&queue); |
| 42 |
| 43 // TaskQueue DCHECKS that it's empty in its destructor. |
| 44 queue.Terminate(); |
| 45 } |
| 46 |
| 47 } // namespace platform |
| 48 } // namespace v8 |
OLD | NEW |