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

Unified Diff: base/mac/bind_objc_block_unittest.mm

Issue 2522943003: [iOS/ARC] Fix a violation of ODR in base::BindBlock under ARC. (Closed)
Patch Set: Use EXPECT_NSEQ instead of EXPECT_EQ/EXPECT_TRUE. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/bind_objc_block.h ('k') | base/mac/bind_objc_block_unittest_arc.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/bind_objc_block_unittest.mm
diff --git a/base/mac/bind_objc_block_unittest.mm b/base/mac/bind_objc_block_unittest.mm
index f3c189cd4b7dd4108c5b80f8e12fde49446ee768..1b1a50c2000094f3dc86bdd34c96dc218f54aef3 100644
--- a/base/mac/bind_objc_block_unittest.mm
+++ b/base/mac/bind_objc_block_unittest.mm
@@ -9,18 +9,17 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
+#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
-// See bind_objc_block_unittest_arc.mm for why this is necessary. Remove once
-// gyp support is dropped.
-void BindObjcBlockUnittestArcLinkerWorkaround();
+#if defined(OS_IOS)
+#include "base/ios/weak_nsobject.h"
+#include "base/mac/scoped_nsautorelease_pool.h"
+#endif
namespace {
-TEST(BindObjcBlockTest, EnableARCTests) {
- BindObjcBlockUnittestArcLinkerWorkaround();
-}
-
TEST(BindObjcBlockTest, TestScopedClosureRunnerExitScope) {
int run_count = 0;
int* ptr = &run_count;
@@ -104,4 +103,22 @@ TEST(BindObjcBlockTest, TestSixArguments) {
EXPECT_EQ(result2, 6);
}
+#if defined(OS_IOS)
+
+TEST(BindObjcBlockTest, TestBlockReleased) {
+ base::WeakNSObject<NSObject> weak_nsobject;
+ {
+ base::mac::ScopedNSAutoreleasePool autorelease_pool;
+ NSObject* nsobject = [[[NSObject alloc] init] autorelease];
+ weak_nsobject.reset(nsobject);
+
+ auto callback = base::BindBlock(^{
+ [nsobject description];
+ });
+ }
+ EXPECT_NSEQ(nil, weak_nsobject);
+}
+
+#endif
+
} // namespace
« no previous file with comments | « base/mac/bind_objc_block.h ('k') | base/mac/bind_objc_block_unittest_arc.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698