72 {
73
74 NSURL* flutterFrameworkURL =
75 [NSBundle.mainBundle.privateFrameworksURL URLByAppendingPathComponent:@"Flutter.framework"];
76 NSBundle* flutterBundle = [NSBundle bundleWithURL:flutterFrameworkURL];
77 XCTAssertEqualObjects(flutterBundle.bundleIdentifier, @"io.flutter.flutter");
78
79 NSDictionary<NSString*, id>* infoDictionary = flutterBundle.infoDictionary;
80
81
82 NSError* regexError = NULL;
83 NSRegularExpression* osVersionRegex =
84 [NSRegularExpression regularExpressionWithPattern:@"((0|[1-9]\\d*)\\.)*(0|[1-9]\\d*)"
85 options:NSRegularExpressionCaseInsensitive
86 error:®exError];
87 XCTAssertNil(regexError);
88
89
90 NSString* testString = @"9";
91 NSUInteger versionMatches =
92 [osVersionRegex numberOfMatchesInString:testString
93 options:NSMatchingAnchored
94 range:NSMakeRange(0, testString.length)];
95 XCTAssertEqual(versionMatches, 1
UL);
96 testString = @"9.1";
97 versionMatches = [osVersionRegex numberOfMatchesInString:testString
98 options:NSMatchingAnchored
99 range:NSMakeRange(0, testString.length)];
100 XCTAssertEqual(versionMatches, 1
UL);
101 testString = @"9.0.1";
102 versionMatches = [osVersionRegex numberOfMatchesInString:testString
103 options:NSMatchingAnchored
104 range:NSMakeRange(0, testString.length)];
105 XCTAssertEqual(versionMatches, 1
UL);
106 testString = @".0.1";
107 versionMatches = [osVersionRegex numberOfMatchesInString:testString
108 options:NSMatchingAnchored
109 range:NSMakeRange(0, testString.length)];
110 XCTAssertEqual(versionMatches, 0
UL);
111
112
113 NSString* minimumOSVersion = infoDictionary[@"MinimumOSVersion"];
114 versionMatches = [osVersionRegex numberOfMatchesInString:minimumOSVersion
115 options:NSMatchingAnchored
116 range:NSMakeRange(0, minimumOSVersion.length)];
117 XCTAssertEqual(versionMatches, 1
UL);
118
119
120 XCTAssertEqual(((NSString*)infoDictionary[
@"FlutterEngine"]).
length, 40
UL);
121
122
123
124
125 XCTAssertTrue(((NSString*)infoDictionary[
@"ClangVersion"]).
length > 15
UL);
126}