|
@@ -4,6 +4,8 @@
|
4
|
4
|
#import "RNNTestRootViewCreator.h"
|
5
|
5
|
#import <React/RCTConvert.h>
|
6
|
6
|
#import "RNNNavigationOptions.h"
|
|
7
|
+#import "RNNNavigationController.h"
|
|
8
|
+#import "RNNTabBarController.h"
|
7
|
9
|
#import "RNNUIBarButtonItem.h"
|
8
|
10
|
|
9
|
11
|
@interface RNNRootViewControllerTest : XCTestCase
|
|
@@ -31,7 +33,7 @@
|
31
|
33
|
-(void)testTopBarBackgroundColor_validColor{
|
32
|
34
|
NSNumber* inputColor = @(0xFFFF0000);
|
33
|
35
|
self.options.topBarBackgroundColor = inputColor;
|
34
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
36
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
35
|
37
|
[self.uut viewWillAppear:false];
|
36
|
38
|
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
37
|
39
|
|
|
@@ -46,7 +48,7 @@
|
46
|
48
|
}
|
47
|
49
|
|
48
|
50
|
- (void)testStatusBarHidden_default {
|
49
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
51
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
50
|
52
|
[self.uut viewWillAppear:false];
|
51
|
53
|
|
52
|
54
|
XCTAssertFalse([self.uut prefersStatusBarHidden]);
|
|
@@ -54,7 +56,7 @@
|
54
|
56
|
|
55
|
57
|
- (void)testStatusBarHidden_true {
|
56
|
58
|
self.options.statusBarHidden = @(1);
|
57
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
59
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
58
|
60
|
[self.uut viewWillAppear:false];
|
59
|
61
|
|
60
|
62
|
XCTAssertTrue([self.uut prefersStatusBarHidden]);
|
|
@@ -81,7 +83,7 @@
|
81
|
83
|
|
82
|
84
|
- (void)testStatusBarHidden_false {
|
83
|
85
|
self.options.statusBarHidden = @(0);
|
84
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
86
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
85
|
87
|
[self.uut viewWillAppear:false];
|
86
|
88
|
|
87
|
89
|
XCTAssertFalse([self.uut prefersStatusBarHidden]);
|
|
@@ -90,14 +92,14 @@
|
90
|
92
|
-(void)testTitle_string{
|
91
|
93
|
NSString* title =@"some title";
|
92
|
94
|
self.options.title= title;
|
93
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
95
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
94
|
96
|
|
95
|
97
|
[self.uut viewWillAppear:false];
|
96
|
98
|
XCTAssertTrue([self.uut.navigationItem.title isEqual:title]);
|
97
|
99
|
}
|
98
|
100
|
|
99
|
101
|
-(void)testTitle_default{
|
100
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
102
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
101
|
103
|
|
102
|
104
|
[self.uut viewWillAppear:false];
|
103
|
105
|
XCTAssertNil(self.uut.navigationItem.title);
|
|
@@ -106,7 +108,7 @@
|
106
|
108
|
-(void)testTopBarTextColor_validColor{
|
107
|
109
|
NSNumber* inputColor = @(0xFFFF0000);
|
108
|
110
|
self.options.topBarTextColor = inputColor;
|
109
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
111
|
+ __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
110
|
112
|
[self.uut viewWillAppear:false];
|
111
|
113
|
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
112
|
114
|
XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
|
|
@@ -122,7 +124,7 @@
|
122
|
124
|
|
123
|
125
|
-(void)testTopBarTextFontFamily_validFont{
|
124
|
126
|
NSString* inputFont = @"HelveticaNeue";
|
125
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
127
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
126
|
128
|
self.options.topBarTextFontFamily = inputFont;
|
127
|
129
|
[self.uut viewWillAppear:false];
|
128
|
130
|
UIFont* expectedFont = [UIFont fontWithName:inputFont size:20];
|
|
@@ -131,7 +133,7 @@
|
131
|
133
|
|
132
|
134
|
-(void)testTopBarHideOnScroll_true {
|
133
|
135
|
NSNumber* hideOnScrollInput = @(1);
|
134
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
136
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
135
|
137
|
self.options.topBarHideOnScroll = hideOnScrollInput;
|
136
|
138
|
[self.uut viewWillAppear:false];
|
137
|
139
|
XCTAssertTrue(self.uut.navigationController.hidesBarsOnSwipe);
|
|
@@ -139,7 +141,7 @@
|
139
|
141
|
|
140
|
142
|
-(void)testTopBarButtonColor {
|
141
|
143
|
NSNumber* inputColor = @(0xFFFF0000);
|
142
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
144
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
143
|
145
|
self.options.topBarButtonColor = inputColor;
|
144
|
146
|
[self.uut viewWillAppear:false];
|
145
|
147
|
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
@@ -149,7 +151,7 @@
|
149
|
151
|
-(void)testTopBarTranslucent {
|
150
|
152
|
NSNumber* topBarTranslucentInput = @(0);
|
151
|
153
|
self.options.topBarTranslucent = topBarTranslucentInput;
|
152
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
154
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
153
|
155
|
[self.uut viewWillAppear:false];
|
154
|
156
|
XCTAssertFalse(self.uut.navigationController.navigationBar.translucent);
|
155
|
157
|
}
|
|
@@ -157,7 +159,7 @@
|
157
|
159
|
-(void)testTabBadge {
|
158
|
160
|
NSString* tabBadgeInput = @"5";
|
159
|
161
|
self.options.tabBadge = tabBadgeInput;
|
160
|
|
- __unused UITabBarController* vc = [[UITabBarController alloc] init];
|
|
162
|
+ __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
|
161
|
163
|
NSMutableArray* controllers = [NSMutableArray new];
|
162
|
164
|
UITabBarItem* item = [[UITabBarItem alloc] initWithTitle:@"A Tab" image:nil tag:1];
|
163
|
165
|
[self.uut setTabBarItem:item];
|
|
@@ -172,7 +174,7 @@
|
172
|
174
|
-(void)testTopBarTextFontSize_withoutTextFontFamily_withoutTextColor {
|
173
|
175
|
NSNumber* topBarTextFontSizeInput = @(15);
|
174
|
176
|
self.options.topBarTextFontSize = topBarTextFontSizeInput;
|
175
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
177
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
176
|
178
|
[self.uut viewWillAppear:false];
|
177
|
179
|
UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
178
|
180
|
XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
@@ -183,7 +185,7 @@
|
183
|
185
|
NSNumber* inputColor = @(0xFFFF0000);
|
184
|
186
|
self.options.topBarTextFontSize = topBarTextFontSizeInput;
|
185
|
187
|
self.options.topBarTextColor = inputColor;
|
186
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
188
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
187
|
189
|
[self.uut viewWillAppear:false];
|
188
|
190
|
UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
189
|
191
|
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
@@ -198,7 +200,7 @@
|
198
|
200
|
self.options.topBarTextFontSize = topBarTextFontSizeInput;
|
199
|
201
|
self.options.topBarTextColor = inputColor;
|
200
|
202
|
self.options.topBarTextFontFamily = inputFont;
|
201
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
203
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
202
|
204
|
[self.uut viewWillAppear:false];
|
203
|
205
|
UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
204
|
206
|
UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
|
@@ -211,7 +213,7 @@
|
211
|
213
|
NSString* inputFont = @"HelveticaNeue";
|
212
|
214
|
self.options.topBarTextFontSize = topBarTextFontSizeInput;
|
213
|
215
|
self.options.topBarTextFontFamily = inputFont;
|
214
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
216
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
215
|
217
|
[self.uut viewWillAppear:false];
|
216
|
218
|
UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
217
|
219
|
XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
@@ -220,11 +222,99 @@
|
220
|
222
|
// TODO: Currently not passing
|
221
|
223
|
-(void)testTopBarTextFontFamily_invalidFont{
|
222
|
224
|
NSString* inputFont = @"HelveticaNeueeeee";
|
223
|
|
- __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|
|
225
|
+ __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
224
|
226
|
self.options.topBarTextFontFamily = inputFont;
|
225
|
227
|
// XCTAssertThrows([self.uut viewWillAppear:false]);
|
226
|
228
|
}
|
227
|
229
|
|
|
230
|
+-(void)testOrientation_portrait {
|
|
231
|
+ NSArray* supportedOrientations = @[@"portrait"];
|
|
232
|
+ self.options.orientation = supportedOrientations;
|
|
233
|
+ __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
|
234
|
+ [self.uut viewWillAppear:false];
|
|
235
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskPortrait;
|
|
236
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
237
|
+}
|
|
238
|
+
|
|
239
|
+-(void)testOrientation_portraitString {
|
|
240
|
+ NSString* supportedOrientation = @"portrait";
|
|
241
|
+ self.options.orientation = supportedOrientation;
|
|
242
|
+ __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
|
243
|
+ [self.uut viewWillAppear:false];
|
|
244
|
+ UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait);
|
|
245
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
246
|
+}
|
|
247
|
+
|
|
248
|
+-(void)testOrientation_portraitAndLandscape {
|
|
249
|
+ NSArray* supportedOrientations = @[@"portrait", @"landscape"];
|
|
250
|
+ self.options.orientation = supportedOrientations;
|
|
251
|
+ __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
|
252
|
+ [self.uut viewWillAppear:false];
|
|
253
|
+ UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape);
|
|
254
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
255
|
+}
|
|
256
|
+
|
|
257
|
+-(void)testOrientation_all {
|
|
258
|
+ NSArray* supportedOrientations = @[@"all"];
|
|
259
|
+ self.options.orientation = supportedOrientations;
|
|
260
|
+ __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
|
261
|
+ [self.uut viewWillAppear:false];
|
|
262
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskAll;
|
|
263
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
264
|
+}
|
|
265
|
+
|
|
266
|
+-(void)testOrientation_default {
|
|
267
|
+ NSString* supportedOrientations = @"default";
|
|
268
|
+ self.options.orientation = supportedOrientations;
|
|
269
|
+ __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
|
|
270
|
+ [self.uut viewWillAppear:false];
|
|
271
|
+ UIInterfaceOrientationMask expectedOrientation = [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
|
|
272
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
273
|
+}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+-(void)testOrientationTabsController_portrait {
|
|
277
|
+ NSArray* supportedOrientations = @[@"portrait"];
|
|
278
|
+ self.options.orientation = supportedOrientations;
|
|
279
|
+ __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
|
|
280
|
+ NSMutableArray* controllers = [NSMutableArray new];
|
|
281
|
+
|
|
282
|
+ [controllers addObject:self.uut];
|
|
283
|
+ [vc setViewControllers:controllers];
|
|
284
|
+ [self.uut viewWillAppear:false];
|
|
285
|
+
|
|
286
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskPortrait;
|
|
287
|
+ XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
|
|
288
|
+}
|
|
289
|
+
|
|
290
|
+-(void)testOrientationTabsController_portraitAndLandscape {
|
|
291
|
+ NSArray* supportedOrientations = @[@"portrait", @"landscape"];
|
|
292
|
+ self.options.orientation = supportedOrientations;
|
|
293
|
+ __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
|
|
294
|
+ NSMutableArray* controllers = [NSMutableArray new];
|
|
295
|
+
|
|
296
|
+ [controllers addObject:self.uut];
|
|
297
|
+ [vc setViewControllers:controllers];
|
|
298
|
+ [self.uut viewWillAppear:false];
|
|
299
|
+
|
|
300
|
+ UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape);
|
|
301
|
+ XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
|
|
302
|
+}
|
|
303
|
+
|
|
304
|
+-(void)testOrientationTabsController_all {
|
|
305
|
+ NSArray* supportedOrientations = @[@"all"];
|
|
306
|
+ self.options.orientation = supportedOrientations;
|
|
307
|
+ __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
|
|
308
|
+ NSMutableArray* controllers = [NSMutableArray new];
|
|
309
|
+
|
|
310
|
+ [controllers addObject:self.uut];
|
|
311
|
+ [vc setViewControllers:controllers];
|
|
312
|
+ [self.uut viewWillAppear:false];
|
|
313
|
+
|
|
314
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskAll;
|
|
315
|
+ XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
|
|
316
|
+}
|
|
317
|
+
|
228
|
318
|
-(void)testRightButtonsWithTitle_withoutStyle {
|
229
|
319
|
self.options.rightButtons = @[@{@"id": @"testId", @"title": @"test"}];
|
230
|
320
|
__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
|