diff --git a/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/project.pbxproj index 88aca9f4d27e..9423d51e274b 100644 --- a/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 03881030233DD43A004581F5 /* instrumentation_adapter_exampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0388102F233DD43A004581F5 /* instrumentation_adapter_exampleTests.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; @@ -21,6 +22,16 @@ F81AEF02CE63DA0020B29F57 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 241E53603CE376E3BCB194D3 /* libPods-Runner.a */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 03881032233DD43A004581F5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ 9705A1C41CF9048500538489 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; @@ -37,6 +48,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0388102D233DD43A004581F5 /* instrumentation_adapter_exampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = instrumentation_adapter_exampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 0388102F233DD43A004581F5 /* instrumentation_adapter_exampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = instrumentation_adapter_exampleTests.m; sourceTree = ""; }; + 03881031233DD43A004581F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 0D6F1CB5DBBEBCC75AFAD041 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; @@ -60,6 +74,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 0388102A233DD43A004581F5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EB1CF9000F007C117D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -73,6 +94,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0388102E233DD43A004581F5 /* instrumentation_adapter_exampleTests */ = { + isa = PBXGroup; + children = ( + 0388102F233DD43A004581F5 /* instrumentation_adapter_exampleTests.m */, + 03881031233DD43A004581F5 /* Info.plist */, + ); + path = instrumentation_adapter_exampleTests; + sourceTree = ""; + }; 42D734D13B733A64B01A24A9 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -99,6 +129,7 @@ children = ( 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, + 0388102E233DD43A004581F5 /* instrumentation_adapter_exampleTests */, 97C146EF1CF9000F007C117D /* Products */, BAB55133DD7BD81A2557E916 /* Pods */, 42D734D13B733A64B01A24A9 /* Frameworks */, @@ -109,6 +140,7 @@ isa = PBXGroup; children = ( 97C146EE1CF9000F007C117D /* Runner.app */, + 0388102D233DD43A004581F5 /* instrumentation_adapter_exampleTests.xctest */, ); name = Products; sourceTree = ""; @@ -144,13 +176,30 @@ 0D6F1CB5DBBEBCC75AFAD041 /* Pods-Runner.release.xcconfig */, E23EF4D45DAE46B9DDB9B445 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 0388102C233DD43A004581F5 /* instrumentation_adapter_exampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 03881037233DD43A004581F5 /* Build configuration list for PBXNativeTarget "instrumentation_adapter_exampleTests" */; + buildPhases = ( + 03881029233DD43A004581F5 /* Sources */, + 0388102A233DD43A004581F5 /* Frameworks */, + 0388102B233DD43A004581F5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 03881033233DD43A004581F5 /* PBXTargetDependency */, + ); + name = instrumentation_adapter_exampleTests; + productName = instrumentation_adapter_exampleTests; + productReference = 0388102D233DD43A004581F5 /* instrumentation_adapter_exampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 97C146ED1CF9000F007C117D /* Runner */ = { isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; @@ -182,6 +231,11 @@ LastUpgradeCheck = 1020; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { + 0388102C233DD43A004581F5 = { + CreatedOnToolsVersion = 10.1; + ProvisioningStyle = Automatic; + TestTargetID = 97C146ED1CF9000F007C117D; + }; 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; }; @@ -201,11 +255,19 @@ projectRoot = ""; targets = ( 97C146ED1CF9000F007C117D /* Runner */, + 0388102C233DD43A004581F5 /* instrumentation_adapter_exampleTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 0388102B233DD43A004581F5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EC1CF9000F007C117D /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -288,6 +350,14 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 03881029233DD43A004581F5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 03881030233DD43A004581F5 /* instrumentation_adapter_exampleTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EA1CF9000F007C117D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -300,6 +370,14 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 03881033233DD43A004581F5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 03881032233DD43A004581F5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 97C146FA1CF9000F007C117D /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -320,6 +398,76 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 03881034233DD43A004581F5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = instrumentation_adapter_exampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "dev.flutter.instrumentation-adapter-exampleTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Debug; + }; + 03881035233DD43A004581F5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = instrumentation_adapter_exampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "dev.flutter.instrumentation-adapter-exampleTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Release; + }; + 03881036233DD43A004581F5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = instrumentation_adapter_exampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "dev.flutter.instrumentation-adapter-exampleTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Profile; + }; 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; @@ -550,6 +698,16 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 03881037233DD43A004581F5 /* Build configuration list for PBXNativeTarget "instrumentation_adapter_exampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 03881034233DD43A004581F5 /* Debug */, + 03881035233DD43A004581F5 /* Release */, + 03881036233DD43A004581F5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140cfdb3f..13678c929d71 100644 --- a/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/instrumentation_adapter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -28,6 +28,16 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/packages/instrumentation_adapter/example/ios/instrumentation_adapter_exampleTests/instrumentation_adapter_exampleTests.m b/packages/instrumentation_adapter/example/ios/instrumentation_adapter_exampleTests/instrumentation_adapter_exampleTests.m new file mode 100644 index 000000000000..a3d28d4bf41b --- /dev/null +++ b/packages/instrumentation_adapter/example/ios/instrumentation_adapter_exampleTests/instrumentation_adapter_exampleTests.m @@ -0,0 +1,36 @@ +// +// instrumentation_adapter_exampleTests.m +// instrumentation_adapter_exampleTests +// +// Created by Tong Wu on 9/26/19. +// Copyright © 2019 The Chromium Authors. All rights reserved. +// + +#import +#import + +@interface instrumentation_adapter_exampleTests : XCTestCase +@end + +@implementation instrumentation_adapter_exampleTests + +- (void)testMirrorChannelTests { + InstrumentationAdapterPlugin* plugin = InstrumentationAdapterPlugin.sharedInstance; + + [self keyValueObservingExpectationForObject:plugin + keyPath:@"testResultsByDescription" + handler:^BOOL(InstrumentationAdapterPlugin* plugin, NSDictionary* change) { + id newValue = change[NSKeyValueChangeNewKey]; + if (newValue != nil && newValue != [NSNull null]) { + NSDictionary* testResultsByDescription = newValue; + [testResultsByDescription enumerateKeysAndObjectsUsingBlock:^(NSString *description, IAPTestResult result, BOOL * _Nonnull stop) { + XCTAssertEqualObjects(result, IAPTestResultSuccess, @"Failed channel test: %@", description); + }]; + return YES; + } + return NO; + }]; + [self waitForExpectationsWithTimeout:30.0 handler:nil]; +} + +@end diff --git a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h index 3d92ba91bf34..924f4756204e 100644 --- a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h +++ b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h @@ -1,4 +1,19 @@ #import +NS_ASSUME_NONNULL_BEGIN + +typedef NSString* IAPTestResult NS_TYPED_EXTENSIBLE_ENUM; + +/// Success string from underlying tests. +extern IAPTestResult const IAPTestResultSuccess; + @interface InstrumentationAdapterPlugin : NSObject + +@property (class, readonly) InstrumentationAdapterPlugin* sharedInstance; + +/// Set when the underlying tests are complete. +@property (copy, readonly, nullable) NSDictionary* testResultsByDescription; + @end + +NS_ASSUME_NONNULL_END diff --git a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m index 704a5b05e031..314c049db4e0 100644 --- a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m +++ b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m @@ -1,16 +1,34 @@ #import "InstrumentationAdapterPlugin.h" +IAPTestResult const IAPTestResultSuccess = @"success"; + +@interface InstrumentationAdapterPlugin () +@property (copy, readwrite, nullable) NSDictionary* testResultsByDescription; +@end + @implementation InstrumentationAdapterPlugin + ++ (instancetype)sharedInstance { + static InstrumentationAdapterPlugin *singleton; + dispatch_once_t once_token; + dispatch_once(&once_token, ^{ + singleton = [[InstrumentationAdapterPlugin alloc] init]; + }); + return singleton; +} + + (void)registerWithRegistrar:(NSObject*)registrar { FlutterMethodChannel* channel = [FlutterMethodChannel methodChannelWithName:@"dev.flutter/InstrumentationAdapterFlutterBinding" binaryMessenger:[registrar messenger]]; - InstrumentationAdapterPlugin* instance = [[InstrumentationAdapterPlugin alloc] init]; + InstrumentationAdapterPlugin* instance = self.sharedInstance; [registrar addMethodCallDelegate:instance channel:channel]; } - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - if ([@"allTestsFinished" isEqualToString:call.method]) { + if ([call.method isEqualToString:@"allTestsFinished"]) { + NSDictionary* arguments = [call arguments]; + self.testResultsByDescription = arguments; result(nil); } else { result(FlutterMethodNotImplemented);