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

Unified Diff: base/mac/bind_objc_block_unittest_arc.mm

Issue 1855483004: [iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing copy constructor from scoped_nsobject<subclass> to scoped_nsobject<class> Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/bind_objc_block_unittest.mm ('k') | base/mac/scoped_block.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/bind_objc_block_unittest_arc.mm
diff --git a/base/mac/bind_objc_block_unittest.mm b/base/mac/bind_objc_block_unittest_arc.mm
similarity index 74%
copy from base/mac/bind_objc_block_unittest.mm
copy to base/mac/bind_objc_block_unittest_arc.mm
index c0e690c00832be63638f2505cec385a778bb06df..ded1c338e47d29b159038f9c5821dfa2139017c4 100644
--- a/base/mac/bind_objc_block_unittest.mm
+++ b/base/mac/bind_objc_block_unittest_arc.mm
@@ -11,9 +11,19 @@
#include "base/callback_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+// This free-function is there to ensure that the object file in not discarded
+// at link time when building with gyp (it is required because targets is built
+// as a static library with gyp and not source set which cause the object file
+// to be discarded if no symbol is used). Remove once gyp support is dropped.
+void BindObjcBlockUnittestArcLinkerWorkaround() {}
+
namespace {
-TEST(BindObjcBlockTest, TestScopedClosureRunnerExitScope) {
+TEST(BindObjcBlockTestARC, TestScopedClosureRunnerExitScope) {
int run_count = 0;
int* ptr = &run_count;
{
@@ -25,7 +35,7 @@ TEST(BindObjcBlockTest, TestScopedClosureRunnerExitScope) {
EXPECT_EQ(1, run_count);
}
-TEST(BindObjcBlockTest, TestScopedClosureRunnerRelease) {
+TEST(BindObjcBlockTestARC, TestScopedClosureRunnerRelease) {
int run_count = 0;
int* ptr = &run_count;
base::Closure c;
@@ -41,19 +51,19 @@ TEST(BindObjcBlockTest, TestScopedClosureRunnerRelease) {
EXPECT_EQ(1, run_count);
}
-TEST(BindObjcBlockTest, TestReturnValue) {
+TEST(BindObjcBlockTestARC, TestReturnValue) {
const int kReturnValue = 42;
base::Callback<int(void)> c = base::BindBlock(^{return kReturnValue;});
EXPECT_EQ(kReturnValue, c.Run());
}
-TEST(BindObjcBlockTest, TestArgument) {
+TEST(BindObjcBlockTestARC, TestArgument) {
const int kArgument = 42;
base::Callback<int(int)> c = base::BindBlock(^(int a){return a + 1;});
EXPECT_EQ(kArgument + 1, c.Run(kArgument));
}
-TEST(BindObjcBlockTest, TestTwoArguments) {
+TEST(BindObjcBlockTestARC, TestTwoArguments) {
std::string result;
std::string* ptr = &result;
base::Callback<void(const std::string&, const std::string&)> c =
@@ -64,7 +74,7 @@ TEST(BindObjcBlockTest, TestTwoArguments) {
EXPECT_EQ(result, "fortytwo");
}
-TEST(BindObjcBlockTest, TestThreeArguments) {
+TEST(BindObjcBlockTestARC, TestThreeArguments) {
std::string result;
std::string* ptr = &result;
base::Callback<void(const std::string&,
@@ -79,7 +89,7 @@ TEST(BindObjcBlockTest, TestThreeArguments) {
EXPECT_EQ(result, "sixtimesnine");
}
-TEST(BindObjcBlockTest, TestSixArguments) {
+TEST(BindObjcBlockTestARC, TestSixArguments) {
std::string result1;
std::string* ptr = &result1;
int result2;
« no previous file with comments | « base/mac/bind_objc_block_unittest.mm ('k') | base/mac/scoped_block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698