Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions shell/platform/darwin/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ executable("framework_common_unittests") {
"framework/Source/flutter_standard_codec_unittest.mm",
]

cflags_objcc = flutter_cflags_objcc_arc

ldflags = [ "-ObjC" ]

deps = [
":framework_common",
":framework_common_fixtures",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if !__has_feature(objc_arc)
#error ARC must be enabled!
#endif

#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"

#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>

FLUTTER_ASSERT_ARC

@protocol FlutterTaskQueue <NSObject>
@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

#include <Foundation/Foundation.h>

#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"

FLUTTER_ASSERT_ARC

NSBundle* FLTFrameworkBundleInternal(NSString* bundleID, NSURL* searchURL) {
NSDirectoryEnumerator<NSURL*>* frameworkEnumerator = [NSFileManager.defaultManager
enumeratorAtURL:searchURL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "gtest/gtest.h"

FLUTTER_ASSERT_ARC

TEST(FlutterStringCodec, CanEncodeAndDecodeNil) {
FlutterStringCodec* codec = [FlutterStringCodec sharedInstance];
ASSERT_TRUE([codec encode:nil] == nil);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "gtest/gtest.h"

FLUTTER_ASSERT_NOT_ARC
FLUTTER_ASSERT_ARC

@interface Pair : NSObject
@property(atomic, readonly, strong, nullable) NSObject* left;
Expand All @@ -18,17 +18,11 @@ @implementation Pair
- (instancetype)initWithLeft:(NSObject*)left right:(NSObject*)right {
self = [super init];
if (self) {
_left = [left retain];
_right = [right retain];
_left = left;
_right = right;
}
return self;
}

- (void)dealloc {
[_left release];
[_right release];
[super dealloc];
}
@end

static const UInt8 kDATE = 128;
Expand Down Expand Up @@ -71,7 +65,7 @@ - (id)readValueOfType:(UInt8)type {
return [NSDate dateWithTimeIntervalSince1970:time];
}
case kPAIR: {
return [[[Pair alloc] initWithLeft:[self readValue] right:[self readValue]] autorelease];
return [[Pair alloc] initWithLeft:[self readValue] right:[self readValue]];
}
default:
return [super readValueOfType:type];
Expand All @@ -86,10 +80,10 @@ - (FlutterStandardReader*)readerWithData:(NSData*)data;

@implementation ExtendedReaderWriter
- (FlutterStandardWriter*)writerWithData:(NSMutableData*)data {
return [[[ExtendedWriter alloc] initWithData:data] autorelease];
return [[ExtendedWriter alloc] initWithData:data];
}
- (FlutterStandardReader*)readerWithData:(NSData*)data {
return [[[ExtendedReader alloc] initWithData:data] autorelease];
return [[ExtendedReader alloc] initWithData:data];
}
@end

Expand Down Expand Up @@ -341,10 +335,10 @@ static void CheckEncodeDecode(id value) {
}

TEST(FlutterStandardCodec, HandlesSubclasses) {
ExtendedReaderWriter* extendedReaderWriter = [[[ExtendedReaderWriter alloc] init] autorelease];
ExtendedReaderWriter* extendedReaderWriter = [[ExtendedReaderWriter alloc] init];
FlutterStandardMessageCodec* codec =
[FlutterStandardMessageCodec codecWithReaderWriter:extendedReaderWriter];
Pair* pair = [[[Pair alloc] initWithLeft:@1 right:@2] autorelease];
Pair* pair = [[Pair alloc] initWithLeft:@1 right:@2];
NSData* encoded = [codec encode:pair];
Pair* decoded = [codec decode:encoded];
ASSERT_TRUE([pair.left isEqual:decoded.left]);
Expand Down