|
@@ -9,7 +9,7 @@
|
9
|
9
|
|
10
|
10
|
@interface UIViewController_LayoutProtocolTest : XCTestCase
|
11
|
11
|
|
12
|
|
-@property (nonatomic, retain) UIViewController* uut;
|
|
12
|
+@property (nonatomic, retain) UIViewController * uut;
|
13
|
13
|
|
14
|
14
|
@end
|
15
|
15
|
|
|
@@ -18,8 +18,8 @@
|
18
|
18
|
- (void)setUp {
|
19
|
19
|
[super setUp];
|
20
|
20
|
self.uut = [OCMockObject partialMockForObject:[UIViewController new]];
|
21
|
|
- self.uut.layoutInfo = [[RNNLayoutInfo alloc] init];
|
22
|
|
- self.uut.layoutInfo.componentId = @"componentId";
|
|
21
|
+ _uut.layoutInfo = [[RNNLayoutInfo alloc] init];
|
|
22
|
+ _uut.layoutInfo.componentId = @"componentId";
|
23
|
23
|
}
|
24
|
24
|
|
25
|
25
|
- (void)testInitWithLayoutApplyDefaultOptions {
|
|
@@ -53,8 +53,8 @@
|
53
|
53
|
|
54
|
54
|
- (void)testSetBackButtonIcon_withColor_shouldSetTitle {
|
55
|
55
|
UIViewController* uut = [UIViewController new];
|
56
|
|
- UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:uut];
|
57
|
|
- NSString* title = @"Title";
|
|
56
|
+ UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:uut];
|
|
57
|
+ NSString* title = @"Title";
|
58
|
58
|
|
59
|
59
|
[uut rnn_setBackButtonIcon:nil withColor:nil title:title];
|
60
|
60
|
XCTAssertEqual(title, uut.navigationItem.backBarButtonItem.title);
|
|
@@ -62,8 +62,8 @@
|
62
|
62
|
|
63
|
63
|
- (void)testSetBackButtonIcon_withColor_shouldSetIcon {
|
64
|
64
|
UIViewController* uut = [UIViewController new];
|
65
|
|
- UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:uut];
|
66
|
|
- UIImage* icon = [UIImage new];
|
|
65
|
+ UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:uut];
|
|
66
|
+ UIImage* icon = [UIImage new];
|
67
|
67
|
|
68
|
68
|
[uut rnn_setBackButtonIcon:icon withColor:nil title:nil];
|
69
|
69
|
XCTAssertEqual(icon, uut.navigationItem.backBarButtonItem.image);
|
|
@@ -99,4 +99,41 @@
|
99
|
99
|
XCTAssertEqual([[parent resolveOptions].bottomTab.selectedIconColor get], UIColor.redColor);
|
100
|
100
|
}
|
101
|
101
|
|
|
102
|
+- (void)testMergeOptions_invokedOnParentViewController {
|
|
103
|
+ id parent = [OCMockObject partialMockForObject:[RNNNavigationController new]];
|
|
104
|
+ RNNNavigationOptions * toMerge = [[RNNNavigationOptions alloc] initEmptyOptions];
|
|
105
|
+ [(UIViewController *) [parent expect] mergeOptions:toMerge];
|
|
106
|
+
|
|
107
|
+ RNNNavigationController* uut = [[RNNNavigationController alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewControllers:nil];
|
|
108
|
+ [parent addChildViewController:uut];
|
|
109
|
+
|
|
110
|
+ [uut mergeOptions:toMerge];
|
|
111
|
+ [parent verify];
|
|
112
|
+}
|
|
113
|
+
|
|
114
|
+- (void)testMergeOptions_presenterIsInvokedWithResolvedOptions {
|
|
115
|
+ id parent = [OCMockObject partialMockForObject:[RNNNavigationController new]];
|
|
116
|
+ id presenter = [OCMockObject partialMockForObject:[RNNNavigationControllerPresenter new]];
|
|
117
|
+ RNNNavigationOptions * toMerge = [[RNNNavigationOptions alloc] initEmptyOptions];
|
|
118
|
+ toMerge.topBar.title.color = [[Color alloc] initWithValue:[UIColor redColor]];
|
|
119
|
+
|
|
120
|
+ [[presenter expect] mergeOptions:toMerge currentOptions:[OCMArg checkWithBlock:^(id value) {
|
|
121
|
+ RNNNavigationOptions * options = (RNNNavigationOptions *) value;
|
|
122
|
+ XCTAssertEqual([options.topBar.title.text get], @"Initial title");
|
|
123
|
+ XCTAssertEqual([options.bottomTab.text get], @"Child tab text");
|
|
124
|
+ return YES;
|
|
125
|
+ }]];
|
|
126
|
+
|
|
127
|
+ RNNNavigationOptions * childOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
|
|
128
|
+ childOptions.bottomTab.text = [[Text alloc] initWithValue:@"Child tab text"];
|
|
129
|
+ UIViewController* child = [[UIViewController alloc] initWithLayoutInfo:nil creator:nil options:childOptions defaultOptions:nil presenter:presenter eventEmitter:nil childViewControllers:nil];
|
|
130
|
+ RNNNavigationOptions * initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
|
|
131
|
+ initialOptions.topBar.title.text = [[Text alloc] initWithValue:@"Initial title"];
|
|
132
|
+ RNNNavigationController* uut = [[RNNNavigationController alloc] initWithLayoutInfo:nil creator:nil options:initialOptions defaultOptions:nil presenter:presenter eventEmitter:nil childViewControllers:@[child]];
|
|
133
|
+ [parent addChildViewController:uut];
|
|
134
|
+
|
|
135
|
+ [uut mergeOptions:toMerge];
|
|
136
|
+ [presenter verify];
|
|
137
|
+}
|
|
138
|
+
|
102
|
139
|
@end
|