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

Side by Side Diff: base/task_unittest.cc

Issue 8483003: Callback API Change: Reimplement Bind(); support IgnoreResult, full currying, and use less types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 1 month 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/file_util_proxy.cc ('k') | base/template_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « base/file_util_proxy.cc ('k') | base/template_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698