瀏覽代碼

add unit test

Ran Greenberg 7 年之前
父節點
當前提交
1caf12615a

+ 6
- 3
ios/RNNBridgeModule.m 查看文件

@@ -2,6 +2,7 @@
2 2
 
3 3
 #import "RNN.h"
4 4
 #import "RNNControllerFactory.h"
5
+#import "RNNReactRootViewCreator.h"
5 6
 
6 7
 @implementation RNNBridgeModule
7 8
 
@@ -15,7 +16,8 @@ RCT_EXPORT_MODULE();
15 16
 RCT_EXPORT_METHOD(setRoot:(NSDictionary*)layout)
16 17
 {
17 18
 	[self assertReady];
18
-	UIApplication.sharedApplication.delegate.window.rootViewController = [[RNNControllerFactory new] createLayout:layout];
19
+	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new]];
20
+	UIApplication.sharedApplication.delegate.window.rootViewController = [factory createLayout:layout];
19 21
 	[UIApplication.sharedApplication.delegate.window makeKeyAndVisible];
20 22
 }
21 23
 
@@ -23,7 +25,8 @@ RCT_EXPORT_METHOD(push:(NSString*)containerId layout:(NSDictionary*)layout)
23 25
 {
24 26
 	[self assertReady];
25 27
 	//TODO implement correctly
26
-	UIViewController* newVc = [[RNNControllerFactory new] createLayout:layout];
28
+	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new]];
29
+	UIViewController *newVc = [factory createLayout:layout];
27 30
 	id vc = [UIApplication.sharedApplication.delegate.window.rootViewController childViewControllers][0];
28 31
 	[[vc navigationController]pushViewController:newVc animated:true];
29 32
 }
@@ -36,7 +39,7 @@ RCT_EXPORT_METHOD(pop:(NSString*)containerId)
36 39
 	[[vc navigationController] popViewControllerAnimated:true];
37 40
 }
38 41
 
39
--(void)assertReady
42
+- (void)assertReady
40 43
 {
41 44
 	if (![RNN instance].isReadyToReceiveCommands) {
42 45
 		@throw [NSException exceptionWithName:@"BridgeNotLoadedError" reason:@"Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called." userInfo:nil];

+ 6
- 0
ios/RNNControllerFactory.h 查看文件

@@ -1,9 +1,15 @@
1 1
 
2 2
 #import <Foundation/Foundation.h>
3 3
 #import <UIKit/UIKit.h>
4
+#import "RNNRootViewCreator.h"
5
+
6
+
7
+
4 8
 
5 9
 @interface RNNControllerFactory : NSObject
6 10
 
11
+-(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator;
12
+
7 13
 -(UIViewController*)createLayout:(NSDictionary*)layout;
8 14
 
9 15
 @end

+ 16
- 1
ios/RNNControllerFactory.m 查看文件

@@ -3,10 +3,25 @@
3 3
 #import "RNNLayoutNode.h"
4 4
 #import "RNNRootViewController.h"
5 5
 
6
+@interface RNNControllerFactory ()
7
+
8
+@property (nonatomic, strong) id<RNNRootViewCreator> creator;
9
+
10
+@end
11
+
6 12
 @implementation RNNControllerFactory
7 13
 
8 14
 # pragma mark public
9 15
 
16
+
17
+-(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator {
18
+	
19
+	self = [super init];
20
+	self.creator = creator;
21
+
22
+	return self;
23
+}
24
+
10 25
 -(UIViewController *)createLayout:(NSDictionary *)layout
11 26
 {
12 27
 	return [self fromTree:layout];
@@ -34,7 +49,7 @@
34 49
 
35 50
 -(UIViewController*)createContainer:(RNNLayoutNode*)node
36 51
 {
37
-	return [[RNNRootViewController alloc]initWithNode:node];
52
+	return [[RNNRootViewController alloc] initWithNode:node rootViewCreator:self.creator];
38 53
 }
39 54
 
40 55
 -(UINavigationController*)createContainerStack:(RNNLayoutNode*)node

+ 14
- 0
ios/RNNReactRootViewCreator.h 查看文件

@@ -0,0 +1,14 @@
1
+//
2
+//  RNNReactRootViewCreator.h
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 08/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+#import "RNNRootViewCreator.h"
11
+
12
+@interface RNNReactRootViewCreator : NSObject <RNNRootViewCreator>
13
+
14
+@end

+ 25
- 0
ios/RNNReactRootViewCreator.m 查看文件

@@ -0,0 +1,25 @@
1
+//
2
+//  RNNReactRootViewCreator.m
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 08/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import "RNNReactRootViewCreator.h"
10
+#import "RNN.h"
11
+#import "RCTRootView.h"
12
+
13
+@implementation RNNReactRootViewCreator
14
+
15
+ - (UIView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId
16
+{
17
+	
18
+	UIView *view = [[RCTRootView alloc] initWithBridge:[RNN instance].bridge
19
+										 moduleName:name
20
+								  initialProperties:@{@"id": rootViewId}];
21
+	
22
+	return view;
23
+}
24
+
25
+@end

+ 2
- 1
ios/RNNRootViewController.h 查看文件

@@ -2,9 +2,10 @@
2 2
 #import <Foundation/Foundation.h>
3 3
 #import <UIKit/UIKit.h>
4 4
 #import "RNNLayoutNode.h"
5
+#import "RNNRootViewCreator.h"
5 6
 
6 7
 @interface RNNRootViewController : UIViewController
7 8
 
8
--(instancetype)initWithNode:(RNNLayoutNode*)node;
9
+-(instancetype)initWithNode:(RNNLayoutNode*)node rootViewCreator:(id<RNNRootViewCreator>)creator;
9 10
 
10 11
 @end

+ 2
- 4
ios/RNNRootViewController.m 查看文件

@@ -10,15 +10,13 @@
10 10
 
11 11
 @implementation RNNRootViewController
12 12
 
13
--(instancetype)initWithNode:(RNNLayoutNode*)node
13
+-(instancetype)initWithNode:(RNNLayoutNode*)node rootViewCreator:(id<RNNRootViewCreator>)creator
14 14
 {
15 15
 	self = [super init];
16 16
 	self.containerId = node.nodeId;
17 17
 	self.containerName = node.data[@"name"];
18 18
 	
19
-	self.view = [[RCTRootView alloc] initWithBridge:[RNN instance].bridge
20
-										 moduleName:self.containerName
21
-								  initialProperties:@{@"id": self.containerId}];
19
+	self.view = [creator createRootView:self.containerName rootViewId:self.containerId];
22 20
 	return self;
23 21
 }
24 22
 

+ 10
- 0
ios/RNNRootViewCreator.h 查看文件

@@ -0,0 +1,10 @@
1
+
2
+#import <UIKit/UIKit.h>
3
+
4
+
5
+@protocol RNNRootViewCreator
6
+
7
+-(UIView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId;
8
+
9
+@end
10
+

+ 10
- 117
ios/ReactNativeNavigation.xcodeproj/project.pbxproj 查看文件

@@ -7,6 +7,8 @@
7 7
 	objects = {
8 8
 
9 9
 /* Begin PBXBuildFile section */
10
+		26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */; };
11
+		26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */; };
10 12
 		7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B11269F1E2D263F00F9B03B /* RNNEventEmitter.m */; };
11 13
 		7B1126A31E2D2B6C00F9B03B /* RNNSplashScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BA500761E254908001B9E1B /* RNNSplashScreen.h */; };
12 14
 		7B1126A41E2D2B6C00F9B03B /* ReactNativeNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BA500731E2544B9001B9E1B /* ReactNativeNavigation.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -14,8 +16,6 @@
14 16
 		7B1126A61E2D2B6C00F9B03B /* RNNBridgeModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BBFE5421E25330E002A6182 /* RNNBridgeModule.h */; };
15 17
 		7B1126A71E2D2B6C00F9B03B /* RNNEventEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B11269E1E2D263F00F9B03B /* RNNEventEmitter.h */; };
16 18
 		7B1126A91E2D2B6C00F9B03B /* RNNControllerFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BC9346C1E26886E00EFA125 /* RNNControllerFactory.h */; };
17
-		7B71261B1E4A22520066D847 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D8AFADBD1BEE6F3F00A4592D /* libReactNativeNavigation.a */; };
18
-		7B7126221E4A23040066D847 /* RNNRootViewControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7126211E4A23040066D847 /* RNNRootViewControllerTest.m */; };
19 19
 		7BA500751E2544B9001B9E1B /* ReactNativeNavigation.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BA500741E2544B9001B9E1B /* ReactNativeNavigation.m */; };
20 20
 		7BA500781E254908001B9E1B /* RNNSplashScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BA500771E254908001B9E1B /* RNNSplashScreen.m */; };
21 21
 		7BBFE5441E25330E002A6182 /* RNNBridgeModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BBFE5431E25330E002A6182 /* RNNBridgeModule.m */; };
@@ -27,16 +27,6 @@
27 27
 		7BEF0D1D1E43771B003E96B0 /* RNNLayoutNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BEF0D1B1E43771B003E96B0 /* RNNLayoutNode.m */; };
28 28
 /* End PBXBuildFile section */
29 29
 
30
-/* Begin PBXContainerItemProxy section */
31
-		7B71261C1E4A22520066D847 /* PBXContainerItemProxy */ = {
32
-			isa = PBXContainerItemProxy;
33
-			containerPortal = D8AFADB51BEE6F3F00A4592D /* Project object */;
34
-			proxyType = 1;
35
-			remoteGlobalIDString = D8AFADBC1BEE6F3F00A4592D;
36
-			remoteInfo = ReactNativeNavigation;
37
-		};
38
-/* End PBXContainerItemProxy section */
39
-
40 30
 /* Begin PBXCopyFilesBuildPhase section */
41 31
 		D8AFADBB1BEE6F3F00A4592D /* CopyFiles */ = {
42 32
 			isa = PBXCopyFilesBuildPhase;
@@ -50,11 +40,11 @@
50 40
 /* End PBXCopyFilesBuildPhase section */
51 41
 
52 42
 /* Begin PBXFileReference section */
43
+		26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNRootViewCreator.h; sourceTree = "<group>"; };
44
+		26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNReactRootViewCreator.h; sourceTree = "<group>"; };
45
+		26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNReactRootViewCreator.m; sourceTree = "<group>"; };
53 46
 		7B11269E1E2D263F00F9B03B /* RNNEventEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNEventEmitter.h; sourceTree = "<group>"; };
54 47
 		7B11269F1E2D263F00F9B03B /* RNNEventEmitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNEventEmitter.m; sourceTree = "<group>"; };
55
-		7B7126161E4A22520066D847 /* ReactNativeNavigationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ReactNativeNavigationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56
-		7B71261A1E4A22520066D847 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
57
-		7B7126211E4A23040066D847 /* RNNRootViewControllerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNRootViewControllerTest.m; sourceTree = "<group>"; };
58 48
 		7BA500731E2544B9001B9E1B /* ReactNativeNavigation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReactNativeNavigation.h; sourceTree = "<group>"; };
59 49
 		7BA500741E2544B9001B9E1B /* ReactNativeNavigation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReactNativeNavigation.m; sourceTree = "<group>"; };
60 50
 		7BA500761E254908001B9E1B /* RNNSplashScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNSplashScreen.h; sourceTree = "<group>"; };
@@ -73,14 +63,6 @@
73 63
 /* End PBXFileReference section */
74 64
 
75 65
 /* Begin PBXFrameworksBuildPhase section */
76
-		7B7126131E4A22520066D847 /* Frameworks */ = {
77
-			isa = PBXFrameworksBuildPhase;
78
-			buildActionMask = 2147483647;
79
-			files = (
80
-				7B71261B1E4A22520066D847 /* libReactNativeNavigation.a in Frameworks */,
81
-			);
82
-			runOnlyForDeploymentPostprocessing = 0;
83
-		};
84 66
 		D8AFADBA1BEE6F3F00A4592D /* Frameworks */ = {
85 67
 			isa = PBXFrameworksBuildPhase;
86 68
 			buildActionMask = 2147483647;
@@ -94,6 +76,9 @@
94 76
 		7B1E4C4B1E2D173700C3A525 /* Controllers */ = {
95 77
 			isa = PBXGroup;
96 78
 			children = (
79
+				26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */,
80
+				26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */,
81
+				26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */,
97 82
 				7BA500761E254908001B9E1B /* RNNSplashScreen.h */,
98 83
 				7BA500771E254908001B9E1B /* RNNSplashScreen.m */,
99 84
 				7BEF0D1A1E43771B003E96B0 /* RNNLayoutNode.h */,
@@ -106,15 +91,6 @@
106 91
 			name = Controllers;
107 92
 			sourceTree = "<group>";
108 93
 		};
109
-		7B7126171E4A22520066D847 /* ReactNativeNavigationTests */ = {
110
-			isa = PBXGroup;
111
-			children = (
112
-				7B7126211E4A23040066D847 /* RNNRootViewControllerTest.m */,
113
-				7B71261A1E4A22520066D847 /* Info.plist */,
114
-			);
115
-			path = ReactNativeNavigationTests;
116
-			sourceTree = "<group>";
117
-		};
118 94
 		7BD721F31E2D3AA100724059 /* Bridge */ = {
119 95
 			isa = PBXGroup;
120 96
 			children = (
@@ -135,7 +111,6 @@
135 111
 				7BBFE5601E253F97002A6182 /* RNN.m */,
136 112
 				7BD721F31E2D3AA100724059 /* Bridge */,
137 113
 				7B1E4C4B1E2D173700C3A525 /* Controllers */,
138
-				7B7126171E4A22520066D847 /* ReactNativeNavigationTests */,
139 114
 				D8AFADBE1BEE6F3F00A4592D /* Products */,
140 115
 			);
141 116
 			sourceTree = "<group>";
@@ -147,7 +122,6 @@
147 122
 			isa = PBXGroup;
148 123
 			children = (
149 124
 				D8AFADBD1BEE6F3F00A4592D /* libReactNativeNavigation.a */,
150
-				7B7126161E4A22520066D847 /* ReactNativeNavigationTests.xctest */,
151 125
 			);
152 126
 			name = Products;
153 127
 			sourceTree = "<group>";
@@ -159,6 +133,7 @@
159 133
 			isa = PBXHeadersBuildPhase;
160 134
 			buildActionMask = 2147483647;
161 135
 			files = (
136
+				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
162 137
 				7B1126A41E2D2B6C00F9B03B /* ReactNativeNavigation.h in Headers */,
163 138
 				7B1126A31E2D2B6C00F9B03B /* RNNSplashScreen.h in Headers */,
164 139
 				7B1126A51E2D2B6C00F9B03B /* RNN.h in Headers */,
@@ -173,24 +148,6 @@
173 148
 /* End PBXHeadersBuildPhase section */
174 149
 
175 150
 /* Begin PBXNativeTarget section */
176
-		7B7126151E4A22520066D847 /* ReactNativeNavigationTests */ = {
177
-			isa = PBXNativeTarget;
178
-			buildConfigurationList = 7B7126201E4A22530066D847 /* Build configuration list for PBXNativeTarget "ReactNativeNavigationTests" */;
179
-			buildPhases = (
180
-				7B7126121E4A22520066D847 /* Sources */,
181
-				7B7126131E4A22520066D847 /* Frameworks */,
182
-				7B7126141E4A22520066D847 /* Resources */,
183
-			);
184
-			buildRules = (
185
-			);
186
-			dependencies = (
187
-				7B71261D1E4A22520066D847 /* PBXTargetDependency */,
188
-			);
189
-			name = ReactNativeNavigationTests;
190
-			productName = ReactNativeNavigationTests;
191
-			productReference = 7B7126161E4A22520066D847 /* ReactNativeNavigationTests.xctest */;
192
-			productType = "com.apple.product-type.bundle.unit-test";
193
-		};
194 151
 		D8AFADBC1BEE6F3F00A4592D /* ReactNativeNavigation */ = {
195 152
 			isa = PBXNativeTarget;
196 153
 			buildConfigurationList = D8AFADC61BEE6F3F00A4592D /* Build configuration list for PBXNativeTarget "ReactNativeNavigation" */;
@@ -218,10 +175,6 @@
218 175
 				LastUpgradeCheck = 0820;
219 176
 				ORGANIZATIONNAME = Wix;
220 177
 				TargetAttributes = {
221
-					7B7126151E4A22520066D847 = {
222
-						CreatedOnToolsVersion = 8.2.1;
223
-						ProvisioningStyle = Automatic;
224
-					};
225 178
 					D8AFADBC1BEE6F3F00A4592D = {
226 179
 						CreatedOnToolsVersion = 7.1;
227 180
 					};
@@ -240,30 +193,11 @@
240 193
 			projectRoot = "";
241 194
 			targets = (
242 195
 				D8AFADBC1BEE6F3F00A4592D /* ReactNativeNavigation */,
243
-				7B7126151E4A22520066D847 /* ReactNativeNavigationTests */,
244 196
 			);
245 197
 		};
246 198
 /* End PBXProject section */
247 199
 
248
-/* Begin PBXResourcesBuildPhase section */
249
-		7B7126141E4A22520066D847 /* Resources */ = {
250
-			isa = PBXResourcesBuildPhase;
251
-			buildActionMask = 2147483647;
252
-			files = (
253
-			);
254
-			runOnlyForDeploymentPostprocessing = 0;
255
-		};
256
-/* End PBXResourcesBuildPhase section */
257
-
258 200
 /* Begin PBXSourcesBuildPhase section */
259
-		7B7126121E4A22520066D847 /* Sources */ = {
260
-			isa = PBXSourcesBuildPhase;
261
-			buildActionMask = 2147483647;
262
-			files = (
263
-				7B7126221E4A23040066D847 /* RNNRootViewControllerTest.m in Sources */,
264
-			);
265
-			runOnlyForDeploymentPostprocessing = 0;
266
-		};
267 201
 		D8AFADB91BEE6F3F00A4592D /* Sources */ = {
268 202
 			isa = PBXSourcesBuildPhase;
269 203
 			buildActionMask = 2147483647;
@@ -274,6 +208,7 @@
274 208
 				7BBFE5441E25330E002A6182 /* RNNBridgeModule.m in Sources */,
275 209
 				7BEF0D1D1E43771B003E96B0 /* RNNLayoutNode.m in Sources */,
276 210
 				7BA500781E254908001B9E1B /* RNNSplashScreen.m in Sources */,
211
+				26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */,
277 212
 				7BBFE5611E253F97002A6182 /* RNN.m in Sources */,
278 213
 				7BC9346E1E26886E00EFA125 /* RNNControllerFactory.m in Sources */,
279 214
 			);
@@ -281,41 +216,7 @@
281 216
 		};
282 217
 /* End PBXSourcesBuildPhase section */
283 218
 
284
-/* Begin PBXTargetDependency section */
285
-		7B71261D1E4A22520066D847 /* PBXTargetDependency */ = {
286
-			isa = PBXTargetDependency;
287
-			target = D8AFADBC1BEE6F3F00A4592D /* ReactNativeNavigation */;
288
-			targetProxy = 7B71261C1E4A22520066D847 /* PBXContainerItemProxy */;
289
-		};
290
-/* End PBXTargetDependency section */
291
-
292 219
 /* Begin XCBuildConfiguration section */
293
-		7B71261E1E4A22520066D847 /* Debug */ = {
294
-			isa = XCBuildConfiguration;
295
-			buildSettings = {
296
-				CLANG_ANALYZER_NONNULL = YES;
297
-				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
298
-				INFOPLIST_FILE = ReactNativeNavigationTests/Info.plist;
299
-				IPHONEOS_DEPLOYMENT_TARGET = 10.2;
300
-				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
301
-				PRODUCT_BUNDLE_IDENTIFIER = com.wix.ReactNativeNavigationTests;
302
-				PRODUCT_NAME = "$(TARGET_NAME)";
303
-			};
304
-			name = Debug;
305
-		};
306
-		7B71261F1E4A22520066D847 /* Release */ = {
307
-			isa = XCBuildConfiguration;
308
-			buildSettings = {
309
-				CLANG_ANALYZER_NONNULL = YES;
310
-				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
311
-				INFOPLIST_FILE = ReactNativeNavigationTests/Info.plist;
312
-				IPHONEOS_DEPLOYMENT_TARGET = 10.2;
313
-				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
314
-				PRODUCT_BUNDLE_IDENTIFIER = com.wix.ReactNativeNavigationTests;
315
-				PRODUCT_NAME = "$(TARGET_NAME)";
316
-			};
317
-			name = Release;
318
-		};
319 220
 		D8AFADC41BEE6F3F00A4592D /* Debug */ = {
320 221
 			isa = XCBuildConfiguration;
321 222
 			buildSettings = {
@@ -441,14 +342,6 @@
441 342
 /* End XCBuildConfiguration section */
442 343
 
443 344
 /* Begin XCConfigurationList section */
444
-		7B7126201E4A22530066D847 /* Build configuration list for PBXNativeTarget "ReactNativeNavigationTests" */ = {
445
-			isa = XCConfigurationList;
446
-			buildConfigurations = (
447
-				7B71261E1E4A22520066D847 /* Debug */,
448
-				7B71261F1E4A22520066D847 /* Release */,
449
-			);
450
-			defaultConfigurationIsVisible = 0;
451
-		};
452 345
 		D8AFADB81BEE6F3F00A4592D /* Build configuration list for PBXProject "ReactNativeNavigation" */ = {
453 346
 			isa = XCConfigurationList;
454 347
 			buildConfigurations = (

+ 4
- 4
playground/ios/playground.xcodeproj/project.pbxproj 查看文件

@@ -12,7 +12,6 @@
12 12
 		00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
13 13
 		00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
14 14
 		00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
15
-		00E356F31AD99517003FC87E /* playgroundTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* playgroundTests.m */; };
16 15
 		133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
17 16
 		139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
18 17
 		139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; };
@@ -21,6 +20,7 @@
21 20
 		13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
22 21
 		13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
23 22
 		146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
23
+		26070FD01E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */; };
24 24
 		2647D65F1DB175C200B23722 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
25 25
 		7B9B39861DEB4091004A6281 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B9B39631DEB4076004A6281 /* libRCTAnimation.a */; };
26 26
 		7BD721FF1E2E421E00724059 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
@@ -199,7 +199,6 @@
199 199
 		00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = "<group>"; };
200 200
 		00E356EE1AD99517003FC87E /* playgroundTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = playgroundTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
201 201
 		00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
202
-		00E356F21AD99517003FC87E /* playgroundTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = playgroundTests.m; sourceTree = "<group>"; };
203 202
 		139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
204 203
 		139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = "<group>"; };
205 204
 		13B07F961A680F5B00A75B9A /* playground.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = playground.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -210,6 +209,7 @@
210 209
 		13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
211 210
 		13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
212 211
 		146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
212
+		26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNControllerFactoryTest.m; sourceTree = "<group>"; };
213 213
 		2647D6591DB175B300B23722 /* ReactNativeNavigation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeNavigation.xcodeproj; path = "../node_modules/react-native-navigation/ios/ReactNativeNavigation.xcodeproj"; sourceTree = "<group>"; };
214 214
 		78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
215 215
 		7B9B395C1DEB4076004A6281 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
@@ -292,7 +292,7 @@
292 292
 		00E356EF1AD99517003FC87E /* playgroundTests */ = {
293 293
 			isa = PBXGroup;
294 294
 			children = (
295
-				00E356F21AD99517003FC87E /* playgroundTests.m */,
295
+				26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */,
296 296
 				00E356F01AD99517003FC87E /* Supporting Files */,
297 297
 			);
298 298
 			path = playgroundTests;
@@ -734,7 +734,7 @@
734 734
 			isa = PBXSourcesBuildPhase;
735 735
 			buildActionMask = 2147483647;
736 736
 			files = (
737
-				00E356F31AD99517003FC87E /* playgroundTests.m in Sources */,
737
+				26070FD01E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m in Sources */,
738 738
 			);
739 739
 			runOnlyForDeploymentPostprocessing = 0;
740 740
 		};

+ 8
- 1
playground/ios/playground.xcodeproj/xcshareddata/xcschemes/playground.xcscheme 查看文件

@@ -40,7 +40,7 @@
40 40
       buildConfiguration = "Debug"
41 41
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42 42
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43
-      shouldUseLaunchSchemeArgsEnv = "YES">
43
+      shouldUseLaunchSchemeArgsEnv = "NO">
44 44
       <Testables>
45 45
          <TestableReference
46 46
             skipped = "NO">
@@ -62,6 +62,13 @@
62 62
             ReferencedContainer = "container:playground.xcodeproj">
63 63
          </BuildableReference>
64 64
       </MacroExpansion>
65
+      <EnvironmentVariables>
66
+         <EnvironmentVariable
67
+            key = "TEST_ENABLED"
68
+            value = "YES"
69
+            isEnabled = "YES">
70
+         </EnvironmentVariable>
71
+      </EnvironmentVariables>
65 72
       <AdditionalOptions>
66 73
       </AdditionalOptions>
67 74
    </TestAction>

+ 14
- 3
playground/ios/playground/main.m 查看文件

@@ -11,8 +11,19 @@
11 11
 
12 12
 #import "AppDelegate.h"
13 13
 
14
+static bool isRunningTests()
15
+{
16
+	NSDictionary* environment = [[NSProcessInfo processInfo] environment];
17
+	NSString* testEnabled = environment[@"TEST_ENABLED"];
18
+	return [testEnabled isEqualToString:@"YES"];
19
+}
20
+
14 21
 int main(int argc, char * argv[]) {
15
-  @autoreleasepool {
16
-    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17
-  }
22
+	@autoreleasepool {
23
+		if (isRunningTests()) {
24
+			return UIApplicationMain(argc, argv, nil, nil);
25
+		} else {
26
+			return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
27
+		}
28
+	}
18 29
 }

+ 49
- 0
playground/ios/playgroundTests/RNNControllerFactoryTest.m 查看文件

@@ -0,0 +1,49 @@
1
+//
2
+//  RNNControllerFactoryTest.m
3
+//  playground
4
+//
5
+//  Created by Ran Greenberg on 08/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <XCTest/XCTest.h>
10
+#import "RNNControllerFactory.m"
11
+
12
+@interface RNNControllerFactoryTest : XCTestCase
13
+
14
+@end
15
+
16
+@implementation RNNControllerFactoryTest
17
+
18
+- (void)setUp {
19
+    [super setUp];
20
+    // Put setup code here. This method is called before the invocation of each test method in the class.
21
+}
22
+
23
+- (void)tearDown {
24
+    // Put teardown code here. This method is called after the invocation of each test method in the class.
25
+    [super tearDown];
26
+}
27
+
28
+- (void)testCreateContainer_EmptyLayout {
29
+	RNNControllerFactory *factory = [[RNNControllerFactory alloc] init];
30
+	XCTAssertThrows([factory createLayout:@{}]);
31
+}
32
+
33
+
34
+- (void)testCreateContainer_ContainerLayout {
35
+	
36
+	id <RNNRootViewCreator> creator = nil;
37
+	
38
+	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:creator];
39
+	id ans = [factory createLayout:@{@"id": @"cntId",
40
+									 @"type": @"Container",
41
+									 @"data": @{},
42
+									 @"children": @[]}];
43
+	XCTAssertTrue([ans isKindOfClass:[UIViewController class]]);
44
+}
45
+
46
+
47
+
48
+
49
+@end

+ 0
- 29
playground/ios/playgroundTests/playgroundTests.m 查看文件

@@ -1,29 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- */
9
-
10
-#import <UIKit/UIKit.h>
11
-#import <XCTest/XCTest.h>
12
-
13
-#import "RCTLog.h"
14
-
15
-
16
-
17
-
18
-#define TIMEOUT_SECONDS 240
19
-#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
20
-
21
-@interface playgroundTests : XCTestCase
22
-
23
-@end
24
-
25
-@implementation playgroundTests
26
-
27
-
28
-
29
-@end