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

Side by Side Diff: ios/chrome/browser/callback_counter_unittest.mm

Issue 2684263003: [ObjC ARC] Converts ios/chrome/browser:unit_tests to ARC. (Closed)
Patch Set: comments Created 3 years, 10 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
« no previous file with comments | « ios/chrome/browser/BUILD.gn ('k') | ios/chrome/browser/chrome_url_util_unittest.mm » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/callback_counter.h" 5 #include "ios/chrome/browser/callback_counter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/mac/bind_objc_block.h" 8 #include "base/mac/bind_objc_block.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #import "base/test/ios/wait_util.h" 10 #import "base/test/ios/wait_util.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 12
13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support."
15 #endif
16
13 // Tests that CallbackCounter works with 2 callbacks. 17 // Tests that CallbackCounter works with 2 callbacks.
14 TEST(CallbackCounterTest, Basic) { 18 TEST(CallbackCounterTest, Basic) {
15 __block BOOL block_was_called = NO; 19 __block BOOL block_was_called = NO;
16 scoped_refptr<CallbackCounter> callback_counter = 20 scoped_refptr<CallbackCounter> callback_counter =
17 new CallbackCounter(base::BindBlock(^{ 21 new CallbackCounter(base::BindBlockArc(^{
18 block_was_called = YES; 22 block_was_called = YES;
19 })); 23 }));
20 24
21 // Enqueue the first callback. 25 // Enqueue the first callback.
22 callback_counter->IncrementCount(); 26 callback_counter->IncrementCount();
23 dispatch_async(dispatch_get_main_queue(), ^{ 27 dispatch_async(dispatch_get_main_queue(), ^{
24 callback_counter->DecrementCount(); 28 callback_counter->DecrementCount();
25 }); 29 });
26 30
27 // Enqueue the second callback. 31 // Enqueue the second callback.
28 callback_counter->IncrementCount(); 32 callback_counter->IncrementCount();
29 dispatch_async(dispatch_get_main_queue(), ^{ 33 dispatch_async(dispatch_get_main_queue(), ^{
30 callback_counter->DecrementCount(); 34 callback_counter->DecrementCount();
31 }); 35 });
32 36
33 base::test::ios::WaitUntilCondition(^bool() { 37 base::test::ios::WaitUntilCondition(^bool() {
34 return block_was_called; 38 return block_was_called;
35 }); 39 });
36 } 40 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/BUILD.gn ('k') | ios/chrome/browser/chrome_url_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698