OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 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 "include/v8-platform.h" | 5 #include "include/v8-platform.h" |
6 #include "src/base/platform/platform.h" | 6 #include "src/base/platform/platform.h" |
7 #include "src/libplatform/task-queue.h" | 7 #include "src/libplatform/task-queue.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 | 9 |
10 using testing::InSequence; | 10 using testing::InSequence; |
11 using testing::IsNull; | 11 using testing::IsNull; |
12 using testing::StrictMock; | 12 using testing::StrictMock; |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace platform { | 15 namespace platform { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 struct MockTask : public Task { | 19 struct MockTask : public Task { |
20 MOCK_METHOD0(Run, void()); | 20 MOCK_METHOD0(Run, void()); |
21 }; | 21 }; |
22 | 22 |
23 | 23 |
24 class TaskQueueThread final : public base::Thread { | 24 class TaskQueueThread final : public base::Thread { |
25 public: | 25 public: |
26 explicit TaskQueueThread(TaskQueue* queue) | 26 explicit TaskQueueThread(TaskQueue* queue) |
27 : Thread(Options("libplatform TaskQueueThread")), queue_(queue) {} | 27 : Thread(Options("libplatform TaskQueueThread")), queue_(queue) {} |
28 | 28 |
29 virtual void Run() override { EXPECT_THAT(queue_->GetNext(), IsNull()); } | 29 void Run() override { EXPECT_THAT(queue_->GetNext(), IsNull()); } |
30 | 30 |
31 private: | 31 private: |
32 TaskQueue* queue_; | 32 TaskQueue* queue_; |
33 }; | 33 }; |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 | 37 |
38 TEST(TaskQueueTest, Basic) { | 38 TEST(TaskQueueTest, Basic) { |
39 TaskQueue queue; | 39 TaskQueue queue; |
(...skipping 11 matching lines...) Expand all Loading... |
51 TaskQueueThread thread2(&queue); | 51 TaskQueueThread thread2(&queue); |
52 thread1.Start(); | 52 thread1.Start(); |
53 thread2.Start(); | 53 thread2.Start(); |
54 queue.Terminate(); | 54 queue.Terminate(); |
55 thread1.Join(); | 55 thread1.Join(); |
56 thread2.Join(); | 56 thread2.Join(); |
57 } | 57 } |
58 | 58 |
59 } // namespace platform | 59 } // namespace platform |
60 } // namespace v8 | 60 } // namespace v8 |
OLD | NEW |