Set metainfo ID for enhanced bookmarks extension
[chromium-blink-merge.git] / base / barrier_closure_unittest.cc
blobab05cb8af540f82f53420a7df47b99fdc0685d39
1 // Copyright 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.
5 #include "base/barrier_closure.h"
7 #include "base/bind.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace {
12 void Increment(int* count) { (*count)++; }
14 TEST(BarrierClosureTest, RunImmediatelyForZeroClosures) {
15 int count = 0;
16 base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
18 base::Closure barrierClosure = base::BarrierClosure(0, doneClosure);
19 EXPECT_EQ(1, count);
22 TEST(BarrierClosureTest, RunAfterNumClosures) {
23 int count = 0;
24 base::Closure doneClosure(base::Bind(&Increment, base::Unretained(&count)));
26 base::Closure barrierClosure = base::BarrierClosure(2, doneClosure);
27 EXPECT_EQ(0, count);
29 barrierClosure.Run();
30 EXPECT_EQ(0, count);
32 barrierClosure.Run();
33 EXPECT_EQ(1, count);
36 } // namespace