|
@@ -32,6 +32,7 @@
|
32
|
32
|
@property (nonatomic, strong) RNNRootViewController* vc2;
|
33
|
33
|
@property (nonatomic, strong) RNNRootViewController* vc3;
|
34
|
34
|
@property (nonatomic, strong) MockUINavigationController* nvc;
|
|
35
|
+@property (nonatomic, strong) id mainWindow;
|
35
|
36
|
@property (nonatomic, strong) id controllerFactory;
|
36
|
37
|
@property (nonatomic, strong) id overlayManager;
|
37
|
38
|
@property (nonatomic, strong) id eventEmmiter;
|
|
@@ -42,11 +43,12 @@
|
42
|
43
|
|
43
|
44
|
- (void)setUp {
|
44
|
45
|
[super setUp];
|
|
46
|
+ self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
|
45
|
47
|
self.store = [OCMockObject partialMockForObject:[[RNNStore alloc] init]];
|
46
|
48
|
self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
|
47
|
49
|
self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
|
48
|
50
|
self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter andBridge:nil]];
|
49
|
|
- self.uut = [[RNNCommandsHandler alloc] initWithStore:self.store controllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager];
|
|
51
|
+ self.uut = [[RNNCommandsHandler alloc] initWithStore:self.store controllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager mainWindow:self.mainWindow];
|
50
|
52
|
self.vc1 = [RNNRootViewController new];
|
51
|
53
|
self.vc2 = [RNNRootViewController new];
|
52
|
54
|
self.vc3 = [RNNRootViewController new];
|
|
@@ -72,30 +74,30 @@
|
72
|
74
|
|
73
|
75
|
-(NSArray*) getPublicMethodNamesForObject:(NSObject*)obj{
|
74
|
76
|
NSMutableArray* skipMethods = [NSMutableArray new];
|
75
|
|
-
|
76
|
|
- [skipMethods addObject:@"initWithStore:controllerFactory:eventEmitter:stackManager:modalManager:overlayManager:"];
|
|
77
|
+
|
|
78
|
+ [skipMethods addObject:@"initWithStore:controllerFactory:eventEmitter:stackManager:modalManager:overlayManager:mainWindow:"];
|
77
|
79
|
[skipMethods addObject:@"assertReady"];
|
78
|
80
|
[skipMethods addObject:@"removePopedViewControllers:"];
|
79
|
81
|
[skipMethods addObject:@".cxx_destruct"];
|
80
|
82
|
[skipMethods addObject:@"dismissedModal:"];
|
81
|
83
|
[skipMethods addObject:@"dismissedMultipleModals:"];
|
82
|
|
-
|
|
84
|
+
|
83
|
85
|
NSMutableArray* result = [NSMutableArray new];
|
84
|
|
-
|
|
86
|
+
|
85
|
87
|
// count and names:
|
86
|
88
|
int i=0;
|
87
|
89
|
unsigned int mc = 0;
|
88
|
90
|
Method * mlist = class_copyMethodList(object_getClass(obj), &mc);
|
89
|
|
-
|
|
91
|
+
|
90
|
92
|
for(i=0; i<mc; i++) {
|
91
|
93
|
NSString *methodName = [NSString stringWithUTF8String:sel_getName(method_getName(mlist[i]))];
|
92
|
|
-
|
|
94
|
+
|
93
|
95
|
// filter skippedMethods
|
94
|
96
|
if (methodName && ![skipMethods containsObject:methodName]) {
|
95
|
97
|
[result addObject:methodName];
|
96
|
98
|
}
|
97
|
99
|
}
|
98
|
|
-
|
|
100
|
+
|
99
|
101
|
return result;
|
100
|
102
|
}
|
101
|
103
|
|
|
@@ -112,13 +114,13 @@
|
112
|
114
|
|
113
|
115
|
[vc viewWillAppear:false];
|
114
|
116
|
XCTAssertTrue([vc.navigationItem.title isEqual:@"the title"]);
|
115
|
|
-
|
|
117
|
+
|
116
|
118
|
[self.store setReadyToReceiveCommands:true];
|
117
|
119
|
[self.store setComponent:vc componentId:@"componentId"];
|
118
|
120
|
|
119
|
121
|
NSDictionary* dictFromJs = @{@"topBar": @{@"background" : @{@"color" : @(0xFFFF0000)}}};
|
120
|
122
|
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
121
|
|
-
|
|
123
|
+
|
122
|
124
|
[self.uut mergeOptions:@"componentId" options:dictFromJs completion:^{
|
123
|
125
|
XCTAssertTrue([vc.navigationItem.title isEqual:@"the title"]);
|
124
|
126
|
XCTAssertTrue([nav.navigationBar.barTintColor isEqual:expectedColor]);
|
|
@@ -149,7 +151,7 @@
|
149
|
151
|
- (void)testPop_removeTopVCFromStore {
|
150
|
152
|
[self.store setReadyToReceiveCommands:true];
|
151
|
153
|
XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
|
152
|
|
-
|
|
154
|
+
|
153
|
155
|
[self.uut pop:@"vc3" mergeOptions:nil completion:^{
|
154
|
156
|
XCTAssertNil([self.store findComponentForId:@"vc3"]);
|
155
|
157
|
XCTAssertNotNil([self.store findComponentForId:@"vc2"]);
|
|
@@ -224,7 +226,7 @@
|
224
|
226
|
[self.store setReadyToReceiveCommands:true];
|
225
|
227
|
OCMStub([self.overlayManager showOverlayWindow:[OCMArg any]]);
|
226
|
228
|
OCMStub([self.controllerFactory createLayout:[OCMArg any] saveToStore:[OCMArg any]]);
|
227
|
|
-
|
|
229
|
+
|
228
|
230
|
NSDictionary* layout = @{};
|
229
|
231
|
|
230
|
232
|
[[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"showOverlay" params:[OCMArg any]];
|
|
@@ -254,11 +256,11 @@
|
254
|
256
|
- (void)testDismissOverlay_handleErrorIfNoOverlayExists {
|
255
|
257
|
[self.store setReadyToReceiveCommands:true];
|
256
|
258
|
NSString* componentId = @"componentId";
|
257
|
|
- id errorHandlerMockClass = [OCMockObject mockForClass:[RNNErrorHandler class]];
|
|
259
|
+ id errorHandlerMockClass = [OCMockObject mockForClass:[RNNErrorHandler class]];
|
258
|
260
|
|
259
|
|
- [[errorHandlerMockClass expect] reject:[OCMArg any] withErrorCode:1010 errorDescription:[OCMArg any]];
|
260
|
|
- [self.uut dismissOverlay:componentId completion:[OCMArg any] rejection:[OCMArg any]];
|
261
|
|
- [errorHandlerMockClass verify];
|
|
261
|
+ [[errorHandlerMockClass expect] reject:[OCMArg any] withErrorCode:1010 errorDescription:[OCMArg any]];
|
|
262
|
+ [self.uut dismissOverlay:componentId completion:[OCMArg any] rejection:[OCMArg any]];
|
|
263
|
+ [errorHandlerMockClass verify];
|
262
|
264
|
}
|
263
|
265
|
|
264
|
266
|
- (void)testDismissOverlay_invokeNavigationCommandEvent {
|
|
@@ -270,8 +272,26 @@
|
270
|
272
|
[self.uut dismissOverlay:componentId completion:^{
|
271
|
273
|
|
272
|
274
|
} rejection:^(NSString *code, NSString *message, NSError *error) {}];
|
273
|
|
-
|
|
275
|
+
|
274
|
276
|
[self.eventEmmiter verify];
|
275
|
277
|
}
|
276
|
278
|
|
|
279
|
+- (void)testSetRoot_setRootViewControllerOnMainWindow {
|
|
280
|
+ [self.store setReadyToReceiveCommands:true];
|
|
281
|
+ OCMStub([self.controllerFactory createLayout:[OCMArg any] saveToStore:self.store]).andReturn(self.vc1);
|
|
282
|
+
|
|
283
|
+ [[self.mainWindow expect] setRootViewController:self.vc1];
|
|
284
|
+ [self.uut setRoot:@{} completion:^{}];
|
|
285
|
+ [self.mainWindow verify];
|
|
286
|
+}
|
|
287
|
+
|
|
288
|
+- (void)testSetRoot_removeAllComponentsFromMainWindow {
|
|
289
|
+ [self.store setReadyToReceiveCommands:true];
|
|
290
|
+ OCMStub([self.controllerFactory createLayout:[OCMArg any] saveToStore:self.store]).andReturn(self.vc1);
|
|
291
|
+
|
|
292
|
+ [[self.store expect] removeAllComponentsFromWindow:self.mainWindow];
|
|
293
|
+ [self.uut setRoot:@{} completion:^{}];
|
|
294
|
+ [self.store verify];
|
|
295
|
+}
|
|
296
|
+
|
277
|
297
|
@end
|