|
@@ -7,14 +7,8 @@
|
7
|
7
|
|
8
|
8
|
@interface RNNCommandsHandlerTest : XCTestCase
|
9
|
9
|
|
10
|
|
-@property (nonatomic, strong) id<RNNRootViewCreator> creator;
|
11
|
|
-@property (nonatomic, strong) NSString* pageName;
|
12
|
|
-@property (nonatomic, strong) NSString* containerId;
|
13
|
|
-@property (nonatomic, strong) id emitter;
|
14
|
10
|
@property (nonatomic, strong) RNNStore* store;
|
15
|
|
-@property (nonatomic, strong) RNNNavigationOptions* options;
|
16
|
|
-@property (nonatomic, strong) RNNRootViewController* viewController;
|
17
|
|
-@property (nonatomic, strong) RNNCommandsHandler* cmdHandler;
|
|
11
|
+@property (nonatomic, strong) RNNCommandsHandler* uut;
|
18
|
12
|
|
19
|
13
|
@end
|
20
|
14
|
|
|
@@ -22,31 +16,21 @@
|
22
|
16
|
|
23
|
17
|
- (void)setUp {
|
24
|
18
|
[super setUp];
|
25
|
|
- self.creator = [[RNNTestRootViewCreator alloc] init];
|
26
|
|
- self.pageName = @"somename";
|
27
|
|
- self.containerId = @"cntId";
|
28
|
|
- self.emitter = nil;
|
29
|
|
- self.options = [[RNNNavigationOptions alloc] initWithDict:@{@"title" : @"static title"}];
|
30
|
|
- self.store = [RNNStore new];
|
31
|
|
- self.viewController = [[RNNRootViewController alloc] initWithName:self.pageName withOptions:self.options withContainerId:self.containerId rootViewCreator:self.creator eventEmitter:self.emitter];
|
32
|
|
- [self.store setReadyToReceiveCommands:true];
|
33
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.viewController];
|
34
|
|
- [self.store setContainer:self.viewController containerId:self.containerId];
|
35
|
|
- self.cmdHandler = [[RNNCommandsHandler alloc] initWithStore:self.store controllerFactory:nil];
|
|
19
|
+ self.store = [[RNNStore alloc] init];
|
|
20
|
+ self.uut = [[RNNCommandsHandler alloc] initWithStore:self.store controllerFactory:nil];
|
36
|
21
|
}
|
37
|
22
|
|
38
|
23
|
|
39
|
24
|
- (void)testAssertReadyForEachMethodThrowsExceptoins {
|
40
|
|
- RNNStore *store = [RNNStore new];
|
41
|
|
- [store setReadyToReceiveCommands:NO];
|
42
|
|
- RNNCommandsHandler *uut = [[RNNCommandsHandler alloc] initWithStore:store controllerFactory:nil];
|
43
|
|
-
|
44
|
|
- NSArray* methods = [self getPublicMethodNamesForObject:uut];
|
|
25
|
+ NSArray* methods = [self getPublicMethodNamesForObject:self.uut];
|
45
|
26
|
|
46
|
27
|
for (NSString* methodName in methods) {
|
|
28
|
+
|
|
29
|
+ __strong id uut = self.uut;
|
47
|
30
|
SEL s = NSSelectorFromString(methodName);
|
48
|
31
|
IMP imp = [uut methodForSelector:s];
|
49
|
32
|
void (*func)(id, SEL) = (void *)imp;
|
|
33
|
+
|
50
|
34
|
XCTAssertThrowsSpecificNamed(func(uut,s), NSException, @"BridgeNotLoadedError");
|
51
|
35
|
}
|
52
|
36
|
}
|
|
@@ -68,7 +52,7 @@
|
68
|
52
|
NSString *methodName = [NSString stringWithUTF8String:sel_getName(method_getName(mlist[i]))];
|
69
|
53
|
|
70
|
54
|
// filter skippedMethods
|
71
|
|
- if (![skipMethods containsObject:methodName]) {
|
|
55
|
+ if (methodName && ![skipMethods containsObject:methodName]) {
|
72
|
56
|
[result addObject:methodName];
|
73
|
57
|
}
|
74
|
58
|
}
|
|
@@ -76,22 +60,28 @@
|
76
|
60
|
return result;
|
77
|
61
|
}
|
78
|
62
|
|
79
|
|
--(void)testDynamicTopBarBackgroundColor_validColor {
|
80
|
|
- NSDictionary* dictFromJs = @{@"topBarBackgroundColor" :@(0xFFFF0000)};
|
81
|
|
- UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
82
|
|
- [self.cmdHandler setOptions:self.containerId options:dictFromJs];
|
83
|
|
- XCTAssertTrue([self.viewController.navigationController.navigationBar.barTintColor isEqual:expectedColor]);
|
84
|
|
-}
|
85
|
|
-
|
86
|
63
|
-(void)testDynamicStylesMergeWithStaticStyles {
|
|
64
|
+ RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] init];
|
|
65
|
+ [initialOptions setTitle:@"the title"];
|
|
66
|
+ RNNRootViewController* vc = [[RNNRootViewController alloc] initWithName:@"name"
|
|
67
|
+ withOptions:initialOptions
|
|
68
|
+ withContainerId:@"containerId"
|
|
69
|
+ rootViewCreator:[[RNNTestRootViewCreator alloc] init]
|
|
70
|
+ eventEmitter:nil];
|
|
71
|
+ UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:vc];
|
|
72
|
+ [vc viewWillAppear:false];
|
|
73
|
+ XCTAssertTrue([vc.navigationItem.title isEqual:@"the title"]);
|
|
74
|
+
|
|
75
|
+ [self.store setReadyToReceiveCommands:true];
|
|
76
|
+ [self.store setContainer:vc containerId:@"containerId"];
|
|
77
|
+
|
87
|
78
|
NSDictionary* dictFromJs = @{@"topBarBackgroundColor" :@(0xFFFF0000)};
|
88
|
79
|
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
89
|
|
- [self.cmdHandler setOptions:self.containerId options:dictFromJs];
|
90
|
|
- XCTAssertTrue([self.viewController.navigationController.navigationBar.barTintColor isEqual:expectedColor]);
|
91
|
|
- XCTAssertTrue([self.viewController.navigationItem.title isEqual:@"static title"]);
|
|
80
|
+
|
|
81
|
+ [self.uut setOptions:@"containerId" options:dictFromJs];
|
|
82
|
+
|
|
83
|
+ XCTAssertTrue([vc.navigationItem.title isEqual:@"the title"]);
|
|
84
|
+ XCTAssertTrue([nav.navigationBar.barTintColor isEqual:expectedColor]);
|
92
|
85
|
}
|
93
|
86
|
|
94
|
|
-
|
95
|
|
-
|
96
|
|
-
|
97
|
87
|
@end
|