Browse Source

iOS - add tests to RNNCommandsHandler

Ran Greenberg 7 years ago
parent
commit
69eb8f54d1

+ 30
- 26
playground/ios/playground.xcodeproj/project.pbxproj View File

@@ -7,26 +7,27 @@
7 7
 	objects = {
8 8
 
9 9
 /* Begin PBXBuildFile section */
10
-		00C302E51ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
11
-		00C302E71ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
12
-		00C302E81ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
13
-		00C302E91ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
14
-		00C302EA1ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
15
-		133E29F31AD74F7200F7D852 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
16
-		139105C61AF99C1200B5F7CC /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
17
-		139FDEF61B0652A700C62182 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; };
10
+		00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
11
+		00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
12
+		00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
13
+		00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
14
+		00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
15
+		133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
16
+		139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
17
+		139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; };
18 18
 		13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
19 19
 		13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
20 20
 		13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
21 21
 		13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
22
-		146834051AC3E58100842450 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
22
+		146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
23 23
 		26070FD01E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */; };
24 24
 		261F0E671E6EE9EC00989DE2 /* RNNModalManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 261F0E661E6EE9EC00989DE2 /* RNNModalManagerTest.m */; };
25
-		2647D65F1DB175C200B23722 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
25
+		2647D65F1DB175C200B23722 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
26 26
 		268692851E50572700E2C612 /* RNNStoreTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 268692841E50572700E2C612 /* RNNStoreTest.m */; };
27
-		7B9B39861DEB4091004A6281 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B9B39631DEB4076004A6281 /* libRCTAnimation.a */; };
28
-		7BD721FF1E2E421E00724059 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
29
-		832341BD1AAA6AB300B99B32 /* ReferenceProxy in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
27
+		26DB71671E82C65600A69712 /* RNNCommandsHandlerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DB71661E82C65600A69712 /* RNNCommandsHandlerTest.m */; };
28
+		7B9B39861DEB4091004A6281 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B9B39631DEB4076004A6281 /* libRCTAnimation.a */; };
29
+		7BD721FF1E2E421E00724059 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
30
+		832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
30 31
 /* End PBXBuildFile section */
31 32
 
32 33
 /* Begin PBXContainerItemProxy section */
@@ -257,6 +258,7 @@
257 258
 		261F0E661E6EE9EC00989DE2 /* RNNModalManagerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNModalManagerTest.m; sourceTree = "<group>"; };
258 259
 		2647D6591DB175B300B23722 /* ReactNativeNavigation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeNavigation.xcodeproj; path = "../node_modules/react-native-navigation/ios/ReactNativeNavigation.xcodeproj"; sourceTree = "<group>"; };
259 260
 		268692841E50572700E2C612 /* RNNStoreTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNStoreTest.m; sourceTree = "<group>"; };
261
+		26DB71661E82C65600A69712 /* RNNCommandsHandlerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNCommandsHandlerTest.m; sourceTree = "<group>"; };
260 262
 		78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
261 263
 		7B9B395C1DEB4076004A6281 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
262 264
 		832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
@@ -267,7 +269,7 @@
267 269
 			isa = PBXFrameworksBuildPhase;
268 270
 			buildActionMask = 2147483647;
269 271
 			files = (
270
-				7BD721FF1E2E421E00724059 /* ReferenceProxy in Frameworks */,
272
+				7BD721FF1E2E421E00724059 /* libReactNativeNavigation.a in Frameworks */,
271 273
 			);
272 274
 			runOnlyForDeploymentPostprocessing = 0;
273 275
 		};
@@ -275,18 +277,18 @@
275 277
 			isa = PBXFrameworksBuildPhase;
276 278
 			buildActionMask = 2147483647;
277 279
 			files = (
278
-				7B9B39861DEB4091004A6281 /* ReferenceProxy in Frameworks */,
279
-				2647D65F1DB175C200B23722 /* ReferenceProxy in Frameworks */,
280
-				146834051AC3E58100842450 /* ReferenceProxy in Frameworks */,
281
-				00C302E51ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */,
282
-				00C302E71ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */,
283
-				00C302E81ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */,
284
-				133E29F31AD74F7200F7D852 /* ReferenceProxy in Frameworks */,
285
-				00C302E91ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */,
286
-				139105C61AF99C1200B5F7CC /* ReferenceProxy in Frameworks */,
287
-				832341BD1AAA6AB300B99B32 /* ReferenceProxy in Frameworks */,
288
-				00C302EA1ABCBA2D00DB3ED1 /* ReferenceProxy in Frameworks */,
289
-				139FDEF61B0652A700C62182 /* ReferenceProxy in Frameworks */,
280
+				7B9B39861DEB4091004A6281 /* libRCTAnimation.a in Frameworks */,
281
+				2647D65F1DB175C200B23722 /* libReactNativeNavigation.a in Frameworks */,
282
+				146834051AC3E58100842450 /* libReact.a in Frameworks */,
283
+				00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
284
+				00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
285
+				00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,
286
+				133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
287
+				00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
288
+				139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
289
+				832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
290
+				00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
291
+				139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
290 292
 			);
291 293
 			runOnlyForDeploymentPostprocessing = 0;
292 294
 		};
@@ -341,6 +343,7 @@
341 343
 				26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */,
342 344
 				268692841E50572700E2C612 /* RNNStoreTest.m */,
343 345
 				261F0E661E6EE9EC00989DE2 /* RNNModalManagerTest.m */,
346
+				26DB71661E82C65600A69712 /* RNNCommandsHandlerTest.m */,
344 347
 				00E356F01AD99517003FC87E /* Supporting Files */,
345 348
 			);
346 349
 			path = playgroundTests;
@@ -832,6 +835,7 @@
832 835
 			buildActionMask = 2147483647;
833 836
 			files = (
834 837
 				268692851E50572700E2C612 /* RNNStoreTest.m in Sources */,
838
+				26DB71671E82C65600A69712 /* RNNCommandsHandlerTest.m in Sources */,
835 839
 				261F0E671E6EE9EC00989DE2 /* RNNModalManagerTest.m in Sources */,
836 840
 				26070FD01E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m in Sources */,
837 841
 			);

+ 58
- 0
playground/ios/playgroundTests/RNNCommandsHandlerTest.m View File

@@ -0,0 +1,58 @@
1
+#import <XCTest/XCTest.h>
2
+#import <objc/runtime.h>
3
+#import "RNNCommandsHandler.m"
4
+
5
+@interface RNNCommandsHandlerTest : XCTestCase
6
+
7
+@end
8
+
9
+@implementation RNNCommandsHandlerTest
10
+
11
+- (void)setUp {
12
+	[super setUp];
13
+	
14
+	
15
+}
16
+
17
+
18
+- (void)testAssertReadyForEachMethodThrowsExceptoins {
19
+	RNNStore *store = [RNNStore new];
20
+	[store setReadyToReceiveCommands:NO];
21
+	RNNCommandsHandler *uut = [[RNNCommandsHandler alloc] initWithStore:store controllerFactory:nil];
22
+	
23
+	NSArray* methods = [self getPublicMethodNamesForObject:uut];
24
+	
25
+	for (NSString* methodName in methods) {
26
+		SEL s = NSSelectorFromString(methodName);
27
+		XCTAssertThrowsSpecificNamed([uut performSelector:s withObject:nil], NSException, @"BridgeNotLoadedError");
28
+	}
29
+}
30
+
31
+-(NSArray*) getPublicMethodNamesForObject:(NSObject*)obj{
32
+	NSMutableArray* skipMethods = [NSMutableArray new];
33
+	[skipMethods addObject:@"initWithStore:controllerFactory:"];
34
+	[skipMethods addObject:@"assertReady"];
35
+	[skipMethods addObject:@".cxx_destruct"];
36
+	
37
+	NSMutableArray* result = [NSMutableArray new];
38
+	
39
+	// count and names:
40
+	int i=0;
41
+	unsigned int mc = 0;
42
+	Method * mlist = class_copyMethodList(object_getClass(obj), &mc);
43
+	
44
+	for(i=0; i<mc; i++) {
45
+		NSString *methodName = [NSString stringWithUTF8String:sel_getName(method_getName(mlist[i]))];
46
+		
47
+		// filter skippedMethods
48
+		if (![skipMethods containsObject:methodName]) {
49
+			[result addObject:methodName];
50
+		}
51
+	}
52
+	
53
+	return result;
54
+}
55
+
56
+
57
+
58
+@end