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

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
« no previous file with comments | « base/barrier_closure.cc ('k') | base/base.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 namespace {
11
12 void Increment(int* count) { (*count)++; }
13
14 TEST(BarrierClosureTest, RunImmediatelyForZeroClosures) {
15 int count = 0;
16 base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
17
18 base::Closure barrierClosure = base::BarrierClosure(0, doneClosure);
19 EXPECT_EQ(1, count);
20 }
21
22 TEST(BarrierClosureTest, RunAfterNumClosures) {
23 int count = 0;
24 base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
25
26 base::Closure barrierClosure = base::BarrierClosure(2, doneClosure);
27 EXPECT_EQ(0, count);
28
29 barrierClosure.Run();
30 EXPECT_EQ(0, count);
31
32 barrierClosure.Run();
33 EXPECT_EQ(1, count);
34 }
35
36 } // namespace
OLDNEW
« no previous file with comments | « base/barrier_closure.cc ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698