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

Unified Diff: base/barrier_closure_unittest.cc

Issue 22859056: Add a BarrierClosure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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: base/barrier_closure_unittest.cc
diff --git a/base/barrier_closure_unittest.cc b/base/barrier_closure_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..15e0f48c5f457c51c2ed65b0a887acade154f39c
--- /dev/null
+++ b/base/barrier_closure_unittest.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2013 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/barrier_closure.h"
+
+#include "base/bind.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+void Increment(int* count) { (*count)++; }
+
+TEST(BarrierClosureTest, RunImmediatelyForZeroClosures) {
+ int count = 0;
+ base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
+
+ base::Closure barrierClosure=base::BarrierClosure(0, doneClosure);
awong 2013/08/22 21:28:33 spaces around = please.
groby-ooo-7-16 2013/08/22 21:59:45 Done.
+ EXPECT_EQ(1, count);
+}
+
+TEST(BarrierClosureTest, RunAfterNumClosures) {
+ int count = 0;
+ base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
+
+ base::Closure barrierClosure=base::BarrierClosure(2, doneClosure);
awong 2013/08/22 21:28:33 spaces around = please.
groby-ooo-7-16 2013/08/22 21:59:45 Done.
+ EXPECT_EQ(0, count);
+
+ barrierClosure.Run();
+ EXPECT_EQ(0, count);
+
+ barrierClosure.Run();
+ EXPECT_EQ(1, count);
+}
« base/barrier_closure.cc ('K') | « base/barrier_closure.cc ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698