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

Side by Side Diff: base/barrier_closure_unittest.cc

Issue 22859056: Add a BarrierClosure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium 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.
4
5 #include "base/barrier_closure.h"
6
7 #include "base/bind.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 void Increment(int* count) { (*count)++; }
11
12 TEST(BarrierClosureTest, RunImmediatelyForZeroClosures) {
13 int count = 0;
14 base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
15
16 base::Closure barrierClosure = base::BarrierClosure(0, doneClosure);
17 EXPECT_EQ(1, count);
18 }
19
20 TEST(BarrierClosureTest, RunAfterNumClosures) {
21 int count = 0;
22 base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
23
24 base::Closure barrierClosure = base::BarrierClosure(2, doneClosure);
25 EXPECT_EQ(0, count);
26
27 barrierClosure.Run();
28 EXPECT_EQ(0, count);
29
30 barrierClosure.Run();
31 EXPECT_EQ(1, count);
32 }
OLDNEW
« 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