OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/task.h" | 7 #include "base/task.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 EXPECT_TRUE(was_deleted); | 108 EXPECT_TRUE(was_deleted); |
109 } | 109 } |
110 | 110 |
111 void Increment(int* value) { | 111 void Increment(int* value) { |
112 (*value)++; | 112 (*value)++; |
113 } | 113 } |
114 | 114 |
115 TEST(TaskTest, TestScopedClosureRunnerExitScope) { | 115 TEST(TaskTest, TestScopedClosureRunnerExitScope) { |
116 int run_count = 0; | 116 int run_count = 0; |
117 { | 117 { |
118 base::ScopedClosureRunner runner(base::Bind(Increment, &run_count)); | 118 base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count)); |
119 EXPECT_EQ(0, run_count); | 119 EXPECT_EQ(0, run_count); |
120 } | 120 } |
121 EXPECT_EQ(1, run_count); | 121 EXPECT_EQ(1, run_count); |
122 } | 122 } |
123 | 123 |
124 TEST(TaskTest, TestScopedClosureRunnerRelease) { | 124 TEST(TaskTest, TestScopedClosureRunnerRelease) { |
125 int run_count = 0; | 125 int run_count = 0; |
126 base::Closure c; | 126 base::Closure c; |
127 { | 127 { |
128 base::ScopedClosureRunner runner(base::Bind(Increment, &run_count)); | 128 base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count)); |
129 c = runner.Release(); | 129 c = runner.Release(); |
130 EXPECT_EQ(0, run_count); | 130 EXPECT_EQ(0, run_count); |
131 } | 131 } |
132 EXPECT_EQ(0, run_count); | 132 EXPECT_EQ(0, run_count); |
133 c.Run(); | 133 c.Run(); |
134 EXPECT_EQ(1, run_count); | 134 EXPECT_EQ(1, run_count); |
135 } | 135 } |
136 | 136 |
137 } // namespace | 137 } // namespace |
OLD | NEW |