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

Side by Side Diff: base/cancelable_callback_unittest.cc

Issue 136683004: Removes MessageLoop::TYPE_XXX where possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolve merge Created 6 years, 11 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
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/cancelable_callback.h" 5 #include "base/cancelable_callback.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 base::Unretained(&count))); 152 base::Unretained(&count)));
153 EXPECT_FALSE(cancelable.IsCancelled()); 153 EXPECT_FALSE(cancelable.IsCancelled());
154 154
155 cancelable.Cancel(); 155 cancelable.Cancel();
156 EXPECT_TRUE(cancelable.IsCancelled()); 156 EXPECT_TRUE(cancelable.IsCancelled());
157 } 157 }
158 158
159 // CancelableCallback posted to a MessageLoop with PostTask. 159 // CancelableCallback posted to a MessageLoop with PostTask.
160 // - Callbacks posted to a MessageLoop can be cancelled. 160 // - Callbacks posted to a MessageLoop can be cancelled.
161 TEST(CancelableCallbackTest, PostTask) { 161 TEST(CancelableCallbackTest, PostTask) {
162 MessageLoop loop(MessageLoop::TYPE_DEFAULT); 162 MessageLoop loop;
163 163
164 int count = 0; 164 int count = 0;
165 CancelableClosure cancelable(base::Bind(&Increment, 165 CancelableClosure cancelable(base::Bind(&Increment,
166 base::Unretained(&count))); 166 base::Unretained(&count)));
167 167
168 MessageLoop::current()->PostTask(FROM_HERE, cancelable.callback()); 168 MessageLoop::current()->PostTask(FROM_HERE, cancelable.callback());
169 RunLoop().RunUntilIdle(); 169 RunLoop().RunUntilIdle();
170 170
171 EXPECT_EQ(1, count); 171 EXPECT_EQ(1, count);
172 172
173 MessageLoop::current()->PostTask(FROM_HERE, cancelable.callback()); 173 MessageLoop::current()->PostTask(FROM_HERE, cancelable.callback());
174 174
175 // Cancel before running the message loop. 175 // Cancel before running the message loop.
176 cancelable.Cancel(); 176 cancelable.Cancel();
177 RunLoop().RunUntilIdle(); 177 RunLoop().RunUntilIdle();
178 178
179 // Callback never ran due to cancellation; count is the same. 179 // Callback never ran due to cancellation; count is the same.
180 EXPECT_EQ(1, count); 180 EXPECT_EQ(1, count);
181 } 181 }
182 182
183 } // namespace 183 } // namespace
184 } // namespace base 184 } // namespace base
OLDNEW
« no previous file with comments | « android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc ('k') | base/files/file_util_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698