From e8d6f23def1f62720379116e0cccab16b6671ae9 Mon Sep 17 00:00:00 2001 From: Tong Wu Date: Thu, 26 Sep 2019 22:36:46 -0700 Subject: [PATCH 1/2] Report Flutter test result via XCTest. --- .../ios/Runner.xcodeproj/project.pbxproj | 160 +++++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 10 ++ .../Info.plist | 22 +++ .../instrumentation_adapter_exampleTests.m | 42 +++++ .../Classes/InstrumentationAdapterPlugin.h | 6 + .../Classes/InstrumentationAdapterPlugin.m | 25 ++- 6 files changed, 262 insertions(+), 3 deletions(-) create mode 100644 packages/instrumentation_adapter/example/ios/instrumentation_adapter_exampleTests/Info.plist create mode 100644 packages/instrumentation_adapter/example/ios/instrumentation_adapter_exampleTests/instrumentation_adapter_exampleTests.m 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..7aeaeb308b5f --- /dev/null +++ b/packages/instrumentation_adapter/example/ios/instrumentation_adapter_exampleTests/instrumentation_adapter_exampleTests.m @@ -0,0 +1,42 @@ +// +// 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)setUp { + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + + [NSThread sleepForTimeInterval:5.0f]; + NSLog(@"==== Begin Test Results ===="); + NSLog(@"%@", [[InstrumentationAdapterPlugin sharedInstance] getTestResults]); +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h index 3d92ba91bf34..0736f915a61b 100644 --- a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h +++ b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h @@ -1,4 +1,10 @@ #import @interface InstrumentationAdapterPlugin : NSObject + ++ (instancetype)sharedInstance; + +- (NSDictionary *)getTestResults; + @end + diff --git a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m index 704a5b05e031..93d7e825340f 100644 --- a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m +++ b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m @@ -1,20 +1,41 @@ #import "InstrumentationAdapterPlugin.h" @implementation InstrumentationAdapterPlugin +{ + NSMutableDictionary *testResults; +}; + ++ (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 = [InstrumentationAdapterPlugin sharedInstance]; [registrar addMethodCallDelegate:instance channel:channel]; } - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([@"allTestsFinished" isEqualToString:call.method]) { - result(nil); + NSDictionary *arguments = [call arguments]; + testResults = arguments[@"results"]; + result(nil); + NSLog(@"debug all test done!!!!!!!!!!!!!!!!"); + NSLog(@"%@", testResults); } else { result(FlutterMethodNotImplemented); } } +- (NSDictionary *)getTestResults { + return testResults; +} + @end From 12a448a893787ff9c7e560ba22dc1ec313435d81 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 27 Sep 2019 17:04:30 -0700 Subject: [PATCH 2/2] Report test results in XCTest --- .../instrumentation_adapter_exampleTests.m | 40 ++++++++----------- .../Classes/InstrumentationAdapterPlugin.h | 13 +++++- .../Classes/InstrumentationAdapterPlugin.m | 25 +++++------- 3 files changed, 39 insertions(+), 39 deletions(-) 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 index 7aeaeb308b5f..a3d28d4bf41b 100644 --- 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 @@ -10,33 +10,27 @@ #import @interface instrumentation_adapter_exampleTests : XCTestCase - @end @implementation instrumentation_adapter_exampleTests -- (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - - [NSThread sleepForTimeInterval:5.0f]; - NSLog(@"==== Begin Test Results ===="); - NSLog(@"%@", [[InstrumentationAdapterPlugin sharedInstance] getTestResults]); -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; +- (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 0736f915a61b..924f4756204e 100644 --- a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h +++ b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.h @@ -1,10 +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 -+ (instancetype)sharedInstance; +@property (class, readonly) InstrumentationAdapterPlugin* sharedInstance; -- (NSDictionary *)getTestResults; +/// 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 93d7e825340f..314c049db4e0 100644 --- a/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m +++ b/packages/instrumentation_adapter/ios/Classes/InstrumentationAdapterPlugin.m @@ -1,9 +1,12 @@ #import "InstrumentationAdapterPlugin.h" +IAPTestResult const IAPTestResultSuccess = @"success"; + +@interface InstrumentationAdapterPlugin () +@property (copy, readwrite, nullable) NSDictionary* testResultsByDescription; +@end + @implementation InstrumentationAdapterPlugin -{ - NSMutableDictionary *testResults; -}; + (instancetype)sharedInstance { static InstrumentationAdapterPlugin *singleton; @@ -18,24 +21,18 @@ + (void)registerWithRegistrar:(NSObject*)registrar { FlutterMethodChannel* channel = [FlutterMethodChannel methodChannelWithName:@"dev.flutter/InstrumentationAdapterFlutterBinding" binaryMessenger:[registrar messenger]]; - InstrumentationAdapterPlugin* instance = [InstrumentationAdapterPlugin sharedInstance]; + InstrumentationAdapterPlugin* instance = self.sharedInstance; [registrar addMethodCallDelegate:instance channel:channel]; } - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - if ([@"allTestsFinished" isEqualToString:call.method]) { - NSDictionary *arguments = [call arguments]; - testResults = arguments[@"results"]; - result(nil); - NSLog(@"debug all test done!!!!!!!!!!!!!!!!"); - NSLog(@"%@", testResults); + if ([call.method isEqualToString:@"allTestsFinished"]) { + NSDictionary* arguments = [call arguments]; + self.testResultsByDescription = arguments; + result(nil); } else { result(FlutterMethodNotImplemented); } } -- (NSDictionary *)getTestResults { - return testResults; -} - @end