blob: cf8e0e876a20e5e514e9afae5e820678adc9036c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/task.h"
#include "base/waitable_event.h"
#include "base/threading/worker_pool.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
typedef PlatformTest WorkerPoolTest;
namespace base {
namespace {
class PostTaskTestTask : public Task {
public:
explicit PostTaskTestTask(WaitableEvent* event) : event_(event) {
}
void Run() {
event_->Signal();
}
private:
WaitableEvent* event_;
};
} // namespace
TEST_F(WorkerPoolTest, PostTask) {
WaitableEvent test_event(false, false);
WaitableEvent long_test_event(false, false);
bool signaled;
WorkerPool::PostTask(FROM_HERE, new PostTaskTestTask(&test_event), false);
WorkerPool::PostTask(FROM_HERE, new PostTaskTestTask(&long_test_event), true);
signaled = test_event.Wait();
EXPECT_TRUE(signaled);
signaled = long_test_event.Wait();
EXPECT_TRUE(signaled);
}
} // namespace base
|