5#import <OCMock/OCMock.h>
6#import <XCTest/XCTest.h>
8#include "flutter/common/constants.h"
9#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
10#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
27 int64_t old_gen_heap_size =
34 CGFloat
scale = [UIScreen mainScreen].scale;
35 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width *
scale;
36 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height *
scale;
37 size_t resource_cache_max_bytes_threshold = screenWidth * screenHeight * 12 * 4;
39 resource_cache_max_bytes_threshold);
43 NSBundle* mainBundle = [NSBundle mainBundle];
44 NSDictionary* appTransportSecurity =
45 [mainBundle objectForInfoDictionaryKey:@"NSAppTransportSecurity"];
47 XCTAssertEqualObjects(
48 @"[[\"invalid-site.com\
",true,false],[\"sub.invalid-site.com\",false,false]]",
54 NSBundle* mainBundle = [NSBundle mainBundle];
55 NSNumber* leakDartVM = [mainBundle objectForInfoDictionaryKey:@"FLTLeakDartVM"];
56 XCTAssertEqual(leakDartVM.boolValue, NO);
60 XCTAssertEqual(
settings.leak_vm, NO);
70 NSString* presentBundleID =
@"io.flutter.flutter";
73 XCTAssertNotNil(found);
78 XCTAssertEqual(bundle, [NSBundle mainBundle]);
82 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
83 NSURL* url = [[NSBundle mainBundle].bundleURL URLByAppendingPathComponent:@"foo/ext.appex"];
84 OCMStub([mockMainBundle bundleURL]).andReturn(url);
86 [mockMainBundle stopMocking];
87 XCTAssertEqualObjects(bundle.bundleURL, [NSBundle mainBundle].bundleURL);
93 id mockBundle = OCMClassMock([NSBundle
class]);
94 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(
@"foo/assets");
95 NSString* resultAssetsPath =
@"path/to/foo/assets";
96 OCMStub([mockBundle pathForResource:
@"foo/assets" ofType:nil]).andReturn(resultAssetsPath);
98 XCTAssertEqualObjects(
path,
@"path/to/foo/assets");
102 id mockBundle = OCMClassMock([NSBundle
class]);
103 id mockMainBundle = OCMPartialMock(NSBundle.mainBundle);
104 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(
@"foo/assets");
105 OCMStub([mockMainBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(nil);
106 NSString* resultAssetsPath =
@"path/to/foo/assets";
107 OCMStub([mockBundle pathForResource:
@"foo/assets" ofType:nil]).andReturn(resultAssetsPath);
109 XCTAssertEqualObjects(
path,
@"path/to/foo/assets");
110 [mockMainBundle stopMocking];
114 id mockBundle = OCMClassMock([NSBundle
class]);
115 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
116 NSString* resultAssetsPath =
@"path/to/foo/assets";
117 OCMStub([mockBundle pathForResource:
@"Frameworks/App.framework/flutter_assets" ofType:nil])
119 OCMStub([mockMainBundle pathForResource:
@"Frameworks/App.framework/flutter_assets" ofType:nil])
120 .andReturn(resultAssetsPath);
122 XCTAssertEqualObjects(
path,
@"path/to/foo/assets");
123 [mockMainBundle stopMocking];
130 id mockBundle = OCMClassMock([NSBundle
class]);
131 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(
@"foo/assets");
132 XCTAssertEqualObjects(
FLTAssetPath(mockBundle),
@"foo/assets");
136 id mockBundle = OCMClassMock([NSBundle
class]);
137 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(nil);
144 id mockBundle = OCMPartialMock([NSBundle mainBundle]);
146 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(
@"foo/assets");
149 XCTAssertEqualObjects(assetsPath,
@"foo/assets/bar");
150 [mockBundle stopMocking];
153 id mockBundle = OCMPartialMock([NSBundle mainBundle]);
155 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(nil);
158 XCTAssertEqualObjects(assetsPath,
@"Frameworks/App.framework/flutter_assets/bar");
159 [mockBundle stopMocking];
165 id mockBundle = OCMClassMock([NSBundle
class]);
167 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(
@"foo/assets");
170 XCTAssertEqualObjects(assetsPath,
@"foo/assets/bar");
174 id mockBundle = OCMClassMock([NSBundle
class]);
175 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(nil);
178 XCTAssertEqualObjects(assetsPath,
@"Frameworks/App.framework/flutter_assets/bar");
184 id mockBundle = OCMPartialMock([NSBundle mainBundle]);
186 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(
@"foo/assets");
189 XCTAssertEqualObjects(assetsPath,
@"foo/assets/packages/bar_package/bar");
190 [mockBundle stopMocking];
193 id mockBundle = OCMPartialMock([NSBundle mainBundle]);
195 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(nil);
198 XCTAssertEqualObjects(assetsPath,
199 @"Frameworks/App.framework/flutter_assets/packages/bar_package/bar");
200 [mockBundle stopMocking];
206 id mockBundle = OCMClassMock([NSBundle
class]);
208 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(
@"foo/assets");
213 XCTAssertEqualObjects(assetsPath,
@"foo/assets/packages/bar_package/bar");
216 id mockBundle = OCMClassMock([NSBundle
class]);
218 OCMStub([mockBundle objectForInfoDictionaryKey:
@"FLTAssetsPath"]).andReturn(nil);
223 XCTAssertEqualObjects(assetsPath,
224 @"Frameworks/App.framework/flutter_assets/packages/bar_package/bar");
229 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
230 OCMStub([mockMainBundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"]).andReturn(
@"NO");
234 XCTAssertEqual(
settings.enable_impeller, NO);
235 [mockMainBundle stopMocking];
240 XCTAssertEqual(
settings.warn_on_impeller_opt_out, YES);
244 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
245 OCMStub([mockMainBundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"]).andReturn(
@"YES");
249 XCTAssertEqual(
settings.enable_impeller, YES);
250 [mockMainBundle stopMocking];
254 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
255 OCMStub([mockMainBundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"]).andReturn(
@"NO");
256 id mockProcessInfo = OCMPartialMock([NSProcessInfo processInfo]);
257 NSArray* arguments = @[ @"process_name", @"--enable-impeller" ];
258 OCMStub([mockProcessInfo arguments]).andReturn(arguments);
262 XCTAssertEqual(
settings.enable_impeller, YES);
263 [mockMainBundle stopMocking];
267 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
268 OCMStub([mockMainBundle objectForInfoDictionaryKey:
@"FLTEnableDartAsserts"]).andReturn(
@"YES");
269 id mockProcessInfo = OCMPartialMock([NSProcessInfo processInfo]);
270 NSArray* arguments = @[ @"process_name" ];
271 OCMStub([mockProcessInfo arguments]).andReturn(arguments);
275 XCTAssertEqual(
settings.dart_flags.size(), 1u);
276 XCTAssertEqual(
settings.dart_flags[0],
"--enable-asserts");
277 [mockMainBundle stopMocking];
281 id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
282 OCMStub([mockMainBundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"]).andReturn(
@"YES");
283 id mockProcessInfo = OCMPartialMock([NSProcessInfo processInfo]);
284 NSArray* arguments = @[ @"process_name", @"--enable-impeller=false" ];
285 OCMStub([mockProcessInfo arguments]).andReturn(arguments);
289 XCTAssertEqual(
settings.enable_impeller, NO);
290 [mockMainBundle stopMocking];
295 id mockAppBundle = OCMClassMock([NSBundle
class]);
296 OCMStub([mockAppBundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"]).andReturn(
@"NO");
297 OCMStub([mockAppBundle bundleWithIdentifier:bundleId]).andReturn(mockAppBundle);
301 XCTAssertEqual(
settings.enable_impeller, NO);
303 [mockAppBundle stopMocking];
308 id mockAppBundle = OCMClassMock([NSBundle
class]);
309 OCMStub([mockAppBundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"]).andReturn(
@"YES");
310 OCMStub([mockAppBundle bundleWithIdentifier:bundleId]).andReturn(mockAppBundle);
318 XCTAssertEqual(
settings.enable_impeller, YES);
320 [mockAppBundle stopMocking];
324 NSBundle* mainBundle = [NSBundle mainBundle];
325 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:@"FLTTraceSystrace"];
326 XCTAssertNotNil(enableTraceSystrace);
327 XCTAssertEqual(enableTraceSystrace.boolValue, NO);
329 XCTAssertEqual(
settings.trace_systrace, NO);
333 NSBundle* mainBundle = [NSBundle mainBundle];
334 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:@"FLTEnableDartProfiling"];
335 XCTAssertNotNil(enableTraceSystrace);
336 XCTAssertEqual(enableTraceSystrace.boolValue, NO);
338 XCTAssertEqual(
settings.trace_systrace, NO);
347 XCTAssertFalse([
FlutterDartProject allowsArbitraryLoads:@{
@"NSAllowsArbitraryLoads" : @
false}]);
348 XCTAssertTrue([
FlutterDartProject allowsArbitraryLoads:@{
@"NSAllowsArbitraryLoads" : @
true}]);
352 NSDictionary* domainInfoOne = @{
353 @"NSIncludesSubdomains" : @
false,
354 @"NSExceptionAllowsInsecureHTTPLoads" : @
true,
355 @"NSExceptionMinimumTLSVersion" :
@"4.0"
357 NSDictionary* domainInfoTwo = @{
358 @"NSIncludesSubdomains" : @
true,
359 @"NSExceptionAllowsInsecureHTTPLoads" : @
false,
360 @"NSExceptionMinimumTLSVersion" :
@"4.0"
362 NSDictionary* domainInfoThree = @{
363 @"NSIncludesSubdomains" : @
false,
364 @"NSExceptionAllowsInsecureHTTPLoads" : @
true,
365 @"NSExceptionMinimumTLSVersion" :
@"4.0"
367 NSDictionary* exceptionDomains = @{
368 @"domain.name" : domainInfoOne,
369 @"sub.domain.name" : domainInfoTwo,
370 @"sub.two.domain.name" : domainInfoThree
372 NSDictionary* appTransportSecurity = @{
@"NSExceptionDomains" : exceptionDomains};
373 XCTAssertEqualObjects(
@"[[\"domain.name\
",false,true],[\"sub.domain.name\",true,false],"
374 @"[\"sub.two.domain.name\
",false,true]]",
379 NSDictionary* domainInfoOne = @{
@"NSExceptionMinimumTLSVersion" :
@"4.0"};
380 NSDictionary* domainInfoTwo = @{
381 @"NSIncludesSubdomains" : @
true,
383 NSDictionary* domainInfoThree = @{};
384 NSDictionary* exceptionDomains = @{
385 @"domain.name" : domainInfoOne,
386 @"sub.domain.name" : domainInfoTwo,
387 @"sub.two.domain.name" : domainInfoThree
389 NSDictionary* appTransportSecurity = @{
@"NSExceptionDomains" : exceptionDomains};
390 XCTAssertEqualObjects(
@"[[\"domain.name\
",false,false],[\"sub.domain.name\",true,false],"
391 @"[\"sub.two.domain.name\
",false,false]]",
static bool invalid(const SkISize &size)
NSString * FLTAssetsPathFromBundle(NSBundle *bundle)
NSBundle * FLTGetApplicationBundle()
NS_ASSUME_NONNULL_BEGIN const NSString * kDefaultAssetPath
NSBundle * FLTFrameworkBundleInternal(NSString *flutterFrameworkBundleID, NSURL *searchURL)
NSString * FLTAssetPath(NSBundle *bundle)
static void round(SkPoint *p)
void testEnableImpellerSettingIsCorrectlyParsed()
void testMainBundleSettingsAreCorrectlyParsed()
void testEnableImpellerSettingIsCorrectlyOverriddenByCommandLine()
void testFLTFrameworkBundleInternalWhenBundleIsNotPresent()
void testFLTAssetsURLFromBundle()
void testDisableImpellerSettingIsCorrectlyParsed()
void testEnableImpellerAppBundleSettingIsCorrectlyParsed()
void testResourceCacheMaxBytesThresholdSetting()
void testFLTFrameworkBundleInternalWhenBundleIsPresent()
void testLookUpForAssetsFromBundle()
void testExceptionDomainsWithMissingInfo()
void testAllowsArbitraryLoads()
void testOldGenHeapSizeSetting()
void testFLTAssetPathReturnsTheCorrectValue()
void testEmptySettingsAreCorrect()
void testLookUpForAssets()
void testDisableImpellerAppBundleSettingIsCorrectlyParsed()
void testEnableDartAssertsCommandLineArgument()
void testEnableDartProflingSettingIsCorrectlyParsed()
void testRequestsWarningWhenImpellerOptOut()
void testFLTGetApplicationBundleWhenCurrentTargetIsExtension()
void testLookUpForAssetsFromPackageFromBundle()
void testFLTGetApplicationBundleWhenCurrentTargetIsNotExtension()
void testEnableTraceSystraceSettingIsCorrectlyParsed()
void testLeakDartVMSettingsAreCorrectlyParsed()
void testProperlyFormedExceptionDomains()
void testDisableImpellerSettingIsCorrectlyOverriddenByCommandLine()
void testLookUpForAssetsFromPackage()
NSString * lookupKeyForAsset:fromBundle:(NSString *asset,[fromBundle] nullable NSBundle *bundle)
NSString * defaultBundleIdentifier()
const flutter::Settings & settings()
NSString * lookupKeyForAsset:fromPackage:(NSString *asset,[fromPackage] NSString *package)
NSString * lookupKeyForAsset:fromPackage:fromBundle:(NSString *asset,[fromPackage] NSString *package,[fromBundle] nullable NSBundle *bundle)
NSString * lookupKeyForAsset:(NSString *asset)
flutter::Settings FLTDefaultSettingsForBundle(NSBundle *bundle, NSProcessInfo *processInfoOrNil)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
constexpr double kMegaByteSizeInBytes
int64_t old_gen_heap_size
size_t resource_cache_max_bytes_threshold