Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1641)

Unified Diff: cc/trees/blocking_task_runner_unittest.cc

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/blocking_task_runner_unittest.cc
diff --git a/cc/trees/blocking_task_runner_unittest.cc b/cc/trees/blocking_task_runner_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ba4f96a80d424265994783511d509052f5088488
--- /dev/null
+++ b/cc/trees/blocking_task_runner_unittest.cc
@@ -0,0 +1,42 @@
+// Copyright 2014 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 "cc/trees/blocking_task_runner.h"
+
+#include "base/bind.h"
+#include "base/run_loop.h"
+#include "cc/test/ordered_simple_task_runner.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+void TestTask(bool* result) {
+ *result = true;
+}
+
+TEST(BlockingTaskRunnerTest, NoCapture) {
+ bool did_run = false;
+ scoped_ptr<BlockingTaskRunner> runner(
+ BlockingTaskRunner::Create(base::MessageLoopProxy::current()));
+ runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run));
+ EXPECT_FALSE(did_run);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(did_run);
+}
+
+TEST(BlockingTaskRunnerTest, Capture) {
+ bool did_run = false;
+ scoped_ptr<BlockingTaskRunner> runner(
+ BlockingTaskRunner::Create(base::MessageLoopProxy::current()));
+ {
+ BlockingTaskRunner::CapturePostTasks capture(runner.get());
+ runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run));
+ EXPECT_FALSE(did_run);
+ }
+ EXPECT_TRUE(did_run);
+}
+
+} // namespace
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698