summaryrefslogtreecommitdiffstats
path: root/base/worker_pool_unittest.cc
diff options
context:
space:
mode:
authordsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 21:07:24 +0000
committerdsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 21:07:24 +0000
commit0c3e3ed3f85afe7483ed476d2b185d7b21c31a84 (patch)
tree31269374aa45ec5de0a92a5ad1a22d1528bd60d8 /base/worker_pool_unittest.cc
parente1a64ca263731e00a8629e97f9bbc8027cafdb5b (diff)
downloadchromium_src-0c3e3ed3f85afe7483ed476d2b185d7b21c31a84.zip
chromium_src-0c3e3ed3f85afe7483ed476d2b185d7b21c31a84.tar.gz
chromium_src-0c3e3ed3f85afe7483ed476d2b185d7b21c31a84.tar.bz2
Add unit tests for WorkerPool and add a working but poor implementation for Linux.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1466 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/worker_pool_unittest.cc')
-rw-r--r--base/worker_pool_unittest.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/base/worker_pool_unittest.cc b/base/worker_pool_unittest.cc
new file mode 100644
index 0000000..ba79766
--- /dev/null
+++ b/base/worker_pool_unittest.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2006-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/worker_pool.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using base::WaitableEvent;
+
+namespace {
+
+class PostTaskTestTask : public Task {
+ public:
+ PostTaskTestTask(WaitableEvent* event) : event_(event) {
+ }
+
+ void Run() {
+ event_->Signal();
+ }
+
+ private:
+ WaitableEvent* event_;
+};
+
+TEST(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