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

Unified Diff: ios/chrome/browser/callback_counter_unittest.mm

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/callback_counter.mm ('k') | ios/chrome/browser/context_menu/context_menu_egtest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/callback_counter_unittest.mm
diff --git a/ios/chrome/browser/callback_counter_unittest.mm b/ios/chrome/browser/callback_counter_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..f257245bd0b8d5f801af96821cd7493922c6d5f9
--- /dev/null
+++ b/ios/chrome/browser/callback_counter_unittest.mm
@@ -0,0 +1,36 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/callback_counter.h"
+
+#include "base/bind.h"
+#include "base/mac/bind_objc_block.h"
+#include "base/memory/ref_counted.h"
+#import "base/test/ios/wait_util.h"
+#include "testing/platform_test.h"
+
+// Tests that CallbackCounter works with 2 callbacks.
+TEST(CallbackCounterTest, Basic) {
+ __block BOOL block_was_called = NO;
+ scoped_refptr<CallbackCounter> callback_counter =
+ new CallbackCounter(base::BindBlock(^{
+ block_was_called = YES;
+ }));
+
+ // Enqueue the first callback.
+ callback_counter->IncrementCount();
+ dispatch_async(dispatch_get_main_queue(), ^{
+ callback_counter->DecrementCount();
+ });
+
+ // Enqueue the second callback.
+ callback_counter->IncrementCount();
+ dispatch_async(dispatch_get_main_queue(), ^{
+ callback_counter->DecrementCount();
+ });
+
+ base::test::ios::WaitUntilCondition(^bool() {
+ return block_was_called;
+ });
+}
« no previous file with comments | « ios/chrome/browser/callback_counter.mm ('k') | ios/chrome/browser/context_menu/context_menu_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698