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.
5 #include "include/v8-platform.h"
6 #include "src/base/platform/platform.h"
7 #include "src/libplatform/task-queue.h"
8 #include "testing/gmock/include/gmock/gmock.h"
10 using testing::InSequence;
11 using testing::IsNull;
12 using testing::StrictMock;
19 struct MockTask : public Task {
20 MOCK_METHOD0(Run, void());
24 class TaskQueueThread FINAL : public base::Thread {
26 explicit TaskQueueThread(TaskQueue* queue)
27 : Thread(Options("libplatform TaskQueueThread")), queue_(queue) {}
29 virtual void Run() OVERRIDE { EXPECT_THAT(queue_->GetNext(), IsNull()); }
38 TEST(TaskQueueTest, Basic) {
42 EXPECT_EQ(&task, queue.GetNext());
44 EXPECT_THAT(queue.GetNext(), IsNull());
48 TEST(TaskQueueTest, TerminateMultipleReaders) {
50 TaskQueueThread thread1(&queue);
51 TaskQueueThread thread2(&queue);
59 } // namespace platform