|
@@ -0,0 +1,566 @@
|
|
1
|
+#import <XCTest/XCTest.h>
|
|
2
|
+#import <OCMock/OCMock.h>
|
|
3
|
+#import <ReactNativeNavigation/RNNComponentViewController.h>
|
|
4
|
+#import "RNNReactRootViewCreator.h"
|
|
5
|
+#import "RNNTestRootViewCreator.h"
|
|
6
|
+#import <React/RCTConvert.h>
|
|
7
|
+#import "RNNNavigationOptions.h"
|
|
8
|
+#import "RNNStackController.h"
|
|
9
|
+#import "RNNBottomTabsController.h"
|
|
10
|
+#import "RNNUIBarButtonItem.h"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+@interface RNNComponentViewController (EmbedInTabBar)
|
|
14
|
+- (void)embedInTabBarController;
|
|
15
|
+@end
|
|
16
|
+
|
|
17
|
+@implementation RNNComponentViewController (EmbedInTabBar)
|
|
18
|
+
|
|
19
|
+- (void)embedInTabBarController {
|
|
20
|
+ RNNBottomTabsController* tabVC = [[RNNBottomTabsController alloc] init];
|
|
21
|
+ tabVC.viewControllers = @[self];
|
|
22
|
+ [self viewWillAppear:false];
|
|
23
|
+}
|
|
24
|
+
|
|
25
|
+@end
|
|
26
|
+
|
|
27
|
+@interface RNNRootViewControllerTest : XCTestCase
|
|
28
|
+
|
|
29
|
+@property (nonatomic, strong) id<RNNComponentViewCreator> creator;
|
|
30
|
+@property (nonatomic, strong) NSString* pageName;
|
|
31
|
+@property (nonatomic, strong) NSString* componentId;
|
|
32
|
+@property (nonatomic, strong) id emitter;
|
|
33
|
+@property (nonatomic, strong) RNNNavigationOptions* options;
|
|
34
|
+@property (nonatomic, strong) RNNLayoutInfo* layoutInfo;
|
|
35
|
+@property (nonatomic, strong) RNNComponentViewController* uut;
|
|
36
|
+@end
|
|
37
|
+
|
|
38
|
+@implementation RNNRootViewControllerTest
|
|
39
|
+
|
|
40
|
+- (void)setUp {
|
|
41
|
+ [super setUp];
|
|
42
|
+ self.creator = [[RNNTestRootViewCreator alloc] init];
|
|
43
|
+ self.pageName = @"somename";
|
|
44
|
+ self.componentId = @"cntId";
|
|
45
|
+ self.emitter = nil;
|
|
46
|
+ self.options = [[RNNNavigationOptions alloc] initWithDict:@{}];
|
|
47
|
+
|
|
48
|
+ RNNLayoutInfo* layoutInfo = [RNNLayoutInfo new];
|
|
49
|
+ layoutInfo.componentId = self.componentId;
|
|
50
|
+ layoutInfo.name = self.pageName;
|
|
51
|
+
|
|
52
|
+ id presenter = [OCMockObject partialMockForObject:[[RNNComponentPresenter alloc] init]];
|
|
53
|
+ self.uut = [[RNNComponentViewController alloc] initWithLayoutInfo:layoutInfo rootViewCreator:self.creator eventEmitter:self.emitter presenter:presenter options:self.options defaultOptions:nil];
|
|
54
|
+}
|
|
55
|
+
|
|
56
|
+-(void)testTopBarBackgroundColor_validColor{
|
|
57
|
+ NSNumber* inputColor = @(0xFFFF0000);
|
|
58
|
+ self.options.topBar.background.color = [[Color alloc] initWithValue:[RCTConvert UIColor:inputColor]];
|
|
59
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
60
|
+ [self.uut viewWillAppear:false];
|
|
61
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
62
|
+
|
|
63
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.barTintColor isEqual:expectedColor]);
|
|
64
|
+}
|
|
65
|
+
|
|
66
|
+-(void)testTopBarBackgroundColorWithoutNavigationController{
|
|
67
|
+ NSNumber* inputColor = @(0xFFFF0000);
|
|
68
|
+ self.options.topBar.background.color = [[Color alloc] initWithValue:[RCTConvert UIColor:inputColor]];
|
|
69
|
+
|
|
70
|
+ XCTAssertNoThrow([self.uut viewWillAppear:false]);
|
|
71
|
+}
|
|
72
|
+
|
|
73
|
+- (void)testStatusBarHidden_default {
|
|
74
|
+ [self.uut viewWillAppear:false];
|
|
75
|
+
|
|
76
|
+ XCTAssertFalse([self.uut prefersStatusBarHidden]);
|
|
77
|
+}
|
|
78
|
+
|
|
79
|
+- (void)testStatusBarVisible_false {
|
|
80
|
+ self.options.statusBar.visible = [[Bool alloc] initWithValue:@(0)];
|
|
81
|
+ [self.uut viewWillAppear:false];
|
|
82
|
+
|
|
83
|
+ XCTAssertTrue([self.uut prefersStatusBarHidden]);
|
|
84
|
+}
|
|
85
|
+
|
|
86
|
+- (void)testStatusBarVisible_true {
|
|
87
|
+ self.options.statusBar.visible = [[Bool alloc] initWithValue:@(1)];
|
|
88
|
+ [self.uut viewWillAppear:false];
|
|
89
|
+
|
|
90
|
+ XCTAssertFalse([self.uut prefersStatusBarHidden]);
|
|
91
|
+}
|
|
92
|
+
|
|
93
|
+- (void)testStatusBarHideWithTopBar_false {
|
|
94
|
+ self.options.statusBar.hideWithTopBar = [[Bool alloc] initWithValue:@(0)];
|
|
95
|
+ self.options.topBar.visible = [[Bool alloc] initWithValue:@(0)];
|
|
96
|
+ [self.uut viewWillAppear:false];
|
|
97
|
+
|
|
98
|
+ XCTAssertFalse([self.uut prefersStatusBarHidden]);
|
|
99
|
+}
|
|
100
|
+
|
|
101
|
+- (void)testStatusBarHideWithTopBar_true {
|
|
102
|
+ self.options.statusBar.hideWithTopBar = [[Bool alloc] initWithValue:@(1)];
|
|
103
|
+ self.options.topBar.visible = [[Bool alloc] initWithValue:@(0)];
|
|
104
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
105
|
+
|
|
106
|
+ [self.uut viewWillAppear:false];
|
|
107
|
+
|
|
108
|
+ XCTAssertTrue([self.uut prefersStatusBarHidden]);
|
|
109
|
+}
|
|
110
|
+
|
|
111
|
+-(void)testTitle_string{
|
|
112
|
+ NSString* title =@"some title";
|
|
113
|
+ self.options.topBar.title.text = [[Text alloc] initWithValue:title];
|
|
114
|
+
|
|
115
|
+ [self.uut viewWillAppear:false];
|
|
116
|
+ XCTAssertTrue([self.uut.navigationItem.title isEqual:title]);
|
|
117
|
+}
|
|
118
|
+
|
|
119
|
+-(void)testTitle_default{
|
|
120
|
+ [self.uut viewWillAppear:false];
|
|
121
|
+ XCTAssertNil(self.uut.navigationItem.title);
|
|
122
|
+}
|
|
123
|
+
|
|
124
|
+-(void)testTopBarTextColor_validColor{
|
|
125
|
+ UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
|
|
126
|
+ self.options.topBar.title.color = [[Color alloc] initWithValue:inputColor];
|
|
127
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
128
|
+ [self.uut viewWillAppear:false];
|
|
129
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
130
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
|
|
131
|
+}
|
|
132
|
+
|
|
133
|
+-(void)testbackgroundColor_validColor{
|
|
134
|
+ UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
|
|
135
|
+ self.options.layout.backgroundColor = [[Color alloc] initWithValue:inputColor];
|
|
136
|
+ [self.uut viewWillAppear:false];
|
|
137
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
138
|
+ XCTAssertTrue([self.uut.view.backgroundColor isEqual:expectedColor]);
|
|
139
|
+}
|
|
140
|
+
|
|
141
|
+-(void)testTopBarTextFontFamily_validFont{
|
|
142
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
143
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
144
|
+ self.options.topBar.title.fontFamily = [[Text alloc] initWithValue:inputFont];
|
|
145
|
+ [self.uut viewWillAppear:false];
|
|
146
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:17];
|
|
147
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
148
|
+}
|
|
149
|
+
|
|
150
|
+-(void)testTopBarHideOnScroll_true {
|
|
151
|
+ NSNumber* hideOnScrollInput = @(1);
|
|
152
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
153
|
+ self.options.topBar.hideOnScroll = [[Bool alloc] initWithValue:hideOnScrollInput];;
|
|
154
|
+ [self.uut viewWillAppear:false];
|
|
155
|
+ XCTAssertTrue(self.uut.navigationController.hidesBarsOnSwipe);
|
|
156
|
+}
|
|
157
|
+
|
|
158
|
+-(void)testTopBarTranslucent {
|
|
159
|
+ NSNumber* topBarTranslucentInput = @(0);
|
|
160
|
+ self.options.topBar.background.translucent = [[Bool alloc] initWithValue:topBarTranslucentInput];
|
|
161
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
162
|
+ [self.uut viewWillAppear:false];
|
|
163
|
+ XCTAssertFalse(self.uut.navigationController.navigationBar.translucent);
|
|
164
|
+}
|
|
165
|
+
|
|
166
|
+-(void)testTabBadge {
|
|
167
|
+ NSString* tabBadgeInput = @"5";
|
|
168
|
+ self.options.bottomTab.badge = [[Text alloc] initWithValue:tabBadgeInput];
|
|
169
|
+ __unused RNNBottomTabsController* vc = [[RNNBottomTabsController alloc] init];
|
|
170
|
+ NSMutableArray* controllers = [NSMutableArray new];
|
|
171
|
+ UITabBarItem* item = [[UITabBarItem alloc] initWithTitle:@"A Tab" image:nil tag:1];
|
|
172
|
+ [self.uut setTabBarItem:item];
|
|
173
|
+ [controllers addObject:self.uut];
|
|
174
|
+ [vc setViewControllers:controllers];
|
|
175
|
+ [self.uut viewWillAppear:false];
|
|
176
|
+ XCTAssertTrue([self.uut.tabBarItem.badgeValue isEqualToString:tabBadgeInput]);
|
|
177
|
+
|
|
178
|
+}
|
|
179
|
+
|
|
180
|
+-(void)testTopBarTransparent_BOOL_True {
|
|
181
|
+ UIColor* transparentColor = [RCTConvert UIColor:@(0x00000000)];
|
|
182
|
+ self.options.topBar.background.color = [[Color alloc] initWithValue:transparentColor];
|
|
183
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
184
|
+ [self.uut viewWillAppear:false];
|
|
185
|
+
|
|
186
|
+ nav.navigationBar.barTintColor = UIColor.clearColor;
|
|
187
|
+ XCTAssertTrue([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
|
|
188
|
+}
|
|
189
|
+
|
|
190
|
+-(void)testTopBarTransparent_BOOL_false {
|
|
191
|
+ UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
|
|
192
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
193
|
+ self.options.topBar.background.color = [[Color alloc] initWithValue:inputColor];
|
|
194
|
+ [self.uut viewWillAppear:false];
|
|
195
|
+
|
|
196
|
+ XCTAssertFalse([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
|
|
197
|
+}
|
|
198
|
+
|
|
199
|
+-(void)testTopBarLargeTitle_default {
|
|
200
|
+ [self.uut viewWillAppear:false];
|
|
201
|
+
|
|
202
|
+ XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeNever);
|
|
203
|
+}
|
|
204
|
+
|
|
205
|
+-(void)testTopBarLargeTitle_true {
|
|
206
|
+ self.options.topBar.largeTitle.visible = [[Bool alloc] initWithValue:@(1)];
|
|
207
|
+ [self.uut viewWillAppear:false];
|
|
208
|
+
|
|
209
|
+ XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeAlways);
|
|
210
|
+}
|
|
211
|
+
|
|
212
|
+-(void)testTopBarLargeTitle_false {
|
|
213
|
+ self.options.topBar.largeTitle.visible = [[Bool alloc] initWithValue:@(0)];
|
|
214
|
+ [self.uut viewWillAppear:false];
|
|
215
|
+
|
|
216
|
+ XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeNever);
|
|
217
|
+}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+-(void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withoutTextColor {
|
|
221
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
222
|
+ self.options.topBar.largeTitle.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
223
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
224
|
+ [self.uut viewWillAppear:false];
|
|
225
|
+ UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
|
226
|
+
|
|
227
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
228
|
+}
|
|
229
|
+
|
|
230
|
+-(void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withTextColor {
|
|
231
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
232
|
+ UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
|
|
233
|
+ self.options.topBar.largeTitle.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
234
|
+ self.options.topBar.largeTitle.color = [[Color alloc] initWithValue:inputColor];
|
|
235
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
236
|
+ [self.uut viewWillAppear:false];
|
|
237
|
+ UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
|
238
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
239
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
240
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
|
|
241
|
+}
|
|
242
|
+
|
|
243
|
+-(void)testTopBarLargeTitleFontSize_withTextFontFamily_withTextColor {
|
|
244
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
245
|
+ UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
|
|
246
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
247
|
+ self.options.topBar.largeTitle.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
248
|
+ self.options.topBar.largeTitle.color = [[Color alloc] initWithValue:inputColor];
|
|
249
|
+ self.options.topBar.largeTitle.fontFamily = [[Text alloc] initWithValue:inputFont];
|
|
250
|
+
|
|
251
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
252
|
+ [self.uut viewWillAppear:false];
|
|
253
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
254
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
|
255
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
256
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
|
|
257
|
+}
|
|
258
|
+
|
|
259
|
+-(void)testTopBarLargeTitleFontSize_withTextFontFamily_withoutTextColor {
|
|
260
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
261
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
262
|
+ self.options.topBar.largeTitle.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
263
|
+ self.options.topBar.largeTitle.fontFamily = [[Text alloc] initWithValue:inputFont];
|
|
264
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
265
|
+ [self.uut viewWillAppear:false];
|
|
266
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
|
267
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
268
|
+}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+-(void)testTopBarTextFontSize_withoutTextFontFamily_withoutTextColor {
|
|
272
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
273
|
+ self.options.topBar.title.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
274
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
275
|
+ [self.uut viewWillAppear:false];
|
|
276
|
+ UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
|
277
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
278
|
+}
|
|
279
|
+
|
|
280
|
+-(void)testTopBarTextFontSize_withoutTextFontFamily_withTextColor {
|
|
281
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
282
|
+ UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
|
|
283
|
+ self.options.topBar.title.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
284
|
+ self.options.topBar.title.color = [[Color alloc] initWithValue:inputColor];
|
|
285
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
286
|
+ [self.uut viewWillAppear:false];
|
|
287
|
+ UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
|
288
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
289
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
290
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
|
|
291
|
+}
|
|
292
|
+
|
|
293
|
+-(void)testTopBarTextFontSize_withTextFontFamily_withTextColor {
|
|
294
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
295
|
+ UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
|
|
296
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
297
|
+ self.options.topBar.title.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
298
|
+ self.options.topBar.title.color = [[Color alloc] initWithValue:inputColor];
|
|
299
|
+ self.options.topBar.title.fontFamily = [[Text alloc] initWithValue:inputFont];
|
|
300
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
301
|
+ [self.uut viewWillAppear:false];
|
|
302
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
303
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
|
304
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
305
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
|
|
306
|
+}
|
|
307
|
+
|
|
308
|
+-(void)testTopBarTextFontSize_withTextFontFamily_withoutTextColor {
|
|
309
|
+ NSNumber* topBarTextFontSizeInput = @(15);
|
|
310
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
311
|
+ self.options.topBar.title.fontSize = [[Number alloc] initWithValue:topBarTextFontSizeInput];
|
|
312
|
+ self.options.topBar.title.fontFamily = [[Text alloc] initWithValue:inputFont];
|
|
313
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
314
|
+ [self.uut viewWillAppear:false];
|
|
315
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
|
316
|
+ XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
|
|
317
|
+}
|
|
318
|
+
|
|
319
|
+// TODO: Currently not passing
|
|
320
|
+-(void)testTopBarTextFontFamily_invalidFont{
|
|
321
|
+ NSString* inputFont = @"HelveticaNeueeeee";
|
|
322
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
323
|
+ self.options.topBar.title.fontFamily = [[Text alloc] initWithValue:inputFont];
|
|
324
|
+ // XCTAssertThrows([self.uut viewWillAppear:false]);
|
|
325
|
+}
|
|
326
|
+
|
|
327
|
+-(void)testOrientation_portrait {
|
|
328
|
+ NSArray* supportedOrientations = @[@"portrait"];
|
|
329
|
+ self.options.layout.orientation = supportedOrientations;
|
|
330
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
331
|
+ [self.uut viewWillAppear:false];
|
|
332
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskPortrait;
|
|
333
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
334
|
+}
|
|
335
|
+
|
|
336
|
+-(void)testOrientation_portraitString {
|
|
337
|
+ NSString* supportedOrientation = @"portrait";
|
|
338
|
+ self.options.layout.orientation = supportedOrientation;
|
|
339
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
340
|
+ [self.uut viewWillAppear:false];
|
|
341
|
+ UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait);
|
|
342
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
343
|
+}
|
|
344
|
+
|
|
345
|
+-(void)testOrientation_portraitAndLandscape {
|
|
346
|
+ NSArray* supportedOrientations = @[@"portrait", @"landscape"];
|
|
347
|
+ self.options.layout.orientation = supportedOrientations;
|
|
348
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
349
|
+ [self.uut viewWillAppear:false];
|
|
350
|
+ UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape);
|
|
351
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
352
|
+}
|
|
353
|
+
|
|
354
|
+-(void)testOrientation_all {
|
|
355
|
+ NSArray* supportedOrientations = @[@"all"];
|
|
356
|
+ self.options.layout.orientation = supportedOrientations;
|
|
357
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
358
|
+ [self.uut viewWillAppear:false];
|
|
359
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskAll;
|
|
360
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
361
|
+}
|
|
362
|
+
|
|
363
|
+-(void)testOrientation_default {
|
|
364
|
+ NSString* supportedOrientations = @"default";
|
|
365
|
+ self.options.layout.orientation = supportedOrientations;
|
|
366
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
367
|
+ [self.uut viewWillAppear:false];
|
|
368
|
+ UIInterfaceOrientationMask expectedOrientation = [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
|
|
369
|
+ XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
|
|
370
|
+}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+-(void)testOrientationTabsController_portrait {
|
|
374
|
+ NSArray* supportedOrientations = @[@"portrait"];
|
|
375
|
+ self.options.layout.orientation = supportedOrientations;
|
|
376
|
+ NSMutableArray* controllers = [[NSMutableArray alloc] initWithArray:@[self.uut]];
|
|
377
|
+ __unused RNNBottomTabsController* vc = [[RNNBottomTabsController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:[RNNComponentPresenter new] eventEmitter:nil childViewControllers:controllers];
|
|
378
|
+
|
|
379
|
+ [self.uut viewWillAppear:false];
|
|
380
|
+
|
|
381
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskPortrait;
|
|
382
|
+ XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
|
|
383
|
+}
|
|
384
|
+
|
|
385
|
+-(void)testOrientationTabsController_portraitAndLandscape {
|
|
386
|
+ NSArray* supportedOrientations = @[@"portrait", @"landscape"];
|
|
387
|
+ self.options.layout.orientation = supportedOrientations;
|
|
388
|
+ NSMutableArray* controllers = [[NSMutableArray alloc] initWithArray:@[self.uut]];
|
|
389
|
+ __unused RNNBottomTabsController* vc = [[RNNBottomTabsController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:[RNNComponentPresenter new] eventEmitter:nil childViewControllers:controllers];
|
|
390
|
+
|
|
391
|
+ [self.uut viewWillAppear:false];
|
|
392
|
+
|
|
393
|
+ UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape);
|
|
394
|
+ XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
|
|
395
|
+}
|
|
396
|
+
|
|
397
|
+-(void)testOrientationTabsController_all {
|
|
398
|
+ NSArray* supportedOrientations = @[@"all"];
|
|
399
|
+ self.options.layout.orientation = supportedOrientations;
|
|
400
|
+ NSMutableArray* controllers = [[NSMutableArray alloc] initWithArray:@[self.uut]];
|
|
401
|
+ __unused RNNBottomTabsController* vc = [[RNNBottomTabsController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:[RNNComponentPresenter new] eventEmitter:nil childViewControllers:controllers];
|
|
402
|
+
|
|
403
|
+ [self.uut viewWillAppear:false];
|
|
404
|
+
|
|
405
|
+ UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskAll;
|
|
406
|
+ XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
|
|
407
|
+}
|
|
408
|
+
|
|
409
|
+-(void)testRightButtonsWithTitle_withoutStyle {
|
|
410
|
+ self.options.topBar.rightButtons = @[@{@"id": @"testId", @"text": @"test"}];
|
|
411
|
+ self.uut = [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNComponentPresenter new] options:self.options defaultOptions:nil];
|
|
412
|
+ RNNStackController* nav = [[RNNStackController alloc] initWithLayoutInfo:nil creator:_creator options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewControllers:@[self.uut]];
|
|
413
|
+
|
|
414
|
+ RNNUIBarButtonItem* button = (RNNUIBarButtonItem*) nav.topViewController.navigationItem.rightBarButtonItems[0];
|
|
415
|
+ NSString* expectedButtonId = @"testId";
|
|
416
|
+ NSString* expectedTitle = @"test";
|
|
417
|
+ XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
|
|
418
|
+ XCTAssertTrue([button.title isEqualToString:expectedTitle]);
|
|
419
|
+ XCTAssertTrue(button.enabled);
|
|
420
|
+}
|
|
421
|
+
|
|
422
|
+-(void)testRightButtonsWithTitle_withStyle {
|
|
423
|
+ NSNumber* inputColor = @(0xFFFF0000);
|
|
424
|
+
|
|
425
|
+ self.options.topBar.rightButtons = @[@{@"id": @"testId", @"text": @"test", @"enabled": @false, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
|
|
426
|
+ self.uut = [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNComponentPresenter new] options:self.options defaultOptions:nil];
|
|
427
|
+ RNNStackController* nav = [[RNNStackController alloc] initWithLayoutInfo:nil creator:_creator options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewControllers:@[self.uut]];
|
|
428
|
+
|
|
429
|
+ RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.rightBarButtonItems objectAtIndex:0];
|
|
430
|
+ NSString* expectedButtonId = @"testId";
|
|
431
|
+ NSString* expectedTitle = @"test";
|
|
432
|
+ XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
|
|
433
|
+ XCTAssertTrue([button.title isEqualToString:expectedTitle]);
|
|
434
|
+ XCTAssertFalse(button.enabled);
|
|
435
|
+
|
|
436
|
+ //TODO: Determine how to tests buttonColor,buttonFontSize and buttonFontWeight?
|
|
437
|
+}
|
|
438
|
+
|
|
439
|
+-(void)testLeftButtonsWithTitle_withoutStyle {
|
|
440
|
+ self.options.topBar.leftButtons = @[@{@"id": @"testId", @"text": @"test"}];
|
|
441
|
+ self.uut = [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNComponentPresenter new] options:self.options defaultOptions:nil];
|
|
442
|
+ RNNStackController* nav = [[RNNStackController alloc] initWithLayoutInfo:nil creator:_creator options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewControllers:@[self.uut]];
|
|
443
|
+
|
|
444
|
+ RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.leftBarButtonItems objectAtIndex:0];
|
|
445
|
+ NSString* expectedButtonId = @"testId";
|
|
446
|
+ NSString* expectedTitle = @"test";
|
|
447
|
+ XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
|
|
448
|
+ XCTAssertTrue([button.title isEqualToString:expectedTitle]);
|
|
449
|
+ XCTAssertTrue(button.enabled);
|
|
450
|
+}
|
|
451
|
+
|
|
452
|
+-(void)testLeftButtonsWithTitle_withStyle {
|
|
453
|
+ NSNumber* inputColor = @(0xFFFF0000);
|
|
454
|
+
|
|
455
|
+ self.options.topBar.leftButtons = @[@{@"id": @"testId", @"text": @"test", @"enabled": @false, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
|
|
456
|
+ self.uut = [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNComponentPresenter new] options:self.options defaultOptions:nil];
|
|
457
|
+ RNNStackController* nav = [[RNNStackController alloc] initWithLayoutInfo:nil creator:_creator options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewControllers:@[self.uut]];
|
|
458
|
+
|
|
459
|
+ RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.leftBarButtonItems objectAtIndex:0];
|
|
460
|
+ NSString* expectedButtonId = @"testId";
|
|
461
|
+ NSString* expectedTitle = @"test";
|
|
462
|
+ XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
|
|
463
|
+ XCTAssertTrue([button.title isEqualToString:expectedTitle]);
|
|
464
|
+ XCTAssertFalse(button.enabled);
|
|
465
|
+
|
|
466
|
+ //TODO: Determine how to tests buttonColor,buttonFontSize and buttonFontWeight?
|
|
467
|
+}
|
|
468
|
+
|
|
469
|
+-(void)testTopBarNoBorderOn {
|
|
470
|
+ NSNumber* topBarNoBorderInput = @(1);
|
|
471
|
+ self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
|
|
472
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
473
|
+ [self.uut viewWillAppear:false];
|
|
474
|
+ XCTAssertNotNil(self.uut.navigationController.navigationBar.shadowImage);
|
|
475
|
+}
|
|
476
|
+
|
|
477
|
+-(void)testTopBarNoBorderOff {
|
|
478
|
+ NSNumber* topBarNoBorderInput = @(0);
|
|
479
|
+ self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
|
|
480
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
481
|
+ [self.uut viewWillAppear:false];
|
|
482
|
+ XCTAssertNil(self.uut.navigationController.navigationBar.shadowImage);
|
|
483
|
+}
|
|
484
|
+
|
|
485
|
+-(void)testStatusBarBlurOn {
|
|
486
|
+ NSNumber* statusBarBlurInput = @(1);
|
|
487
|
+ self.options.statusBar.blur = [[Bool alloc] initWithValue:statusBarBlurInput];
|
|
488
|
+ [self.uut viewWillAppear:false];
|
|
489
|
+ XCTAssertNotNil([self.uut.view viewWithTag:BLUR_STATUS_TAG]);
|
|
490
|
+}
|
|
491
|
+
|
|
492
|
+-(void)testStatusBarBlurOff {
|
|
493
|
+ NSNumber* statusBarBlurInput = @(0);
|
|
494
|
+ self.options.statusBar.blur = [[Bool alloc] initWithValue:statusBarBlurInput];
|
|
495
|
+ [self.uut viewWillAppear:false];
|
|
496
|
+ XCTAssertNil([self.uut.view viewWithTag:BLUR_STATUS_TAG]);
|
|
497
|
+}
|
|
498
|
+
|
|
499
|
+- (void)testTabBarHidden_default {
|
|
500
|
+ [self.uut viewWillAppear:false];
|
|
501
|
+
|
|
502
|
+ XCTAssertFalse([self.uut hidesBottomBarWhenPushed]);
|
|
503
|
+}
|
|
504
|
+
|
|
505
|
+- (void)testTabBarHidden_false {
|
|
506
|
+ self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(1)];
|
|
507
|
+ [self.uut viewWillAppear:false];
|
|
508
|
+
|
|
509
|
+ XCTAssertFalse([self.uut hidesBottomBarWhenPushed]);
|
|
510
|
+}
|
|
511
|
+
|
|
512
|
+-(void)testTopBarBlur_default {
|
|
513
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
514
|
+ [self.uut viewWillAppear:false];
|
|
515
|
+ XCTAssertNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
|
|
516
|
+}
|
|
517
|
+
|
|
518
|
+-(void)testTopBarBlur_false {
|
|
519
|
+ NSNumber* topBarBlurInput = @(0);
|
|
520
|
+ self.options.topBar.background.blur = [[Bool alloc] initWithValue:topBarBlurInput];
|
|
521
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
522
|
+ [self.uut viewWillAppear:false];
|
|
523
|
+ XCTAssertNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
|
|
524
|
+}
|
|
525
|
+
|
|
526
|
+-(void)testTopBarBlur_true {
|
|
527
|
+ NSNumber* topBarBlurInput = @(1);
|
|
528
|
+ self.options.topBar.background.blur = [[Bool alloc] initWithValue:topBarBlurInput];
|
|
529
|
+ __unused RNNStackController* nav = [self createNavigationController];
|
|
530
|
+ [self.uut viewWillAppear:false];
|
|
531
|
+ XCTAssertNotNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
|
|
532
|
+}
|
|
533
|
+
|
|
534
|
+-(void)testBackgroundImage {
|
|
535
|
+ Image* backgroundImage = [[Image alloc] initWithValue:[[UIImage alloc] init]];
|
|
536
|
+ self.options.backgroundImage = backgroundImage;
|
|
537
|
+ [self.uut viewWillAppear:false];
|
|
538
|
+
|
|
539
|
+ XCTAssertTrue([[(UIImageView*)self.uut.view.subviews[0] image] isEqual:backgroundImage.get]);
|
|
540
|
+}
|
|
541
|
+
|
|
542
|
+- (void)testMergeOptionsShouldCallPresenterMergeOptions {
|
|
543
|
+ RNNNavigationOptions* newOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
|
|
544
|
+ [[(id) self.uut.presenter expect] mergeOptions:newOptions resolvedOptions:self.uut.options];
|
|
545
|
+ [self.uut mergeOptions:newOptions];
|
|
546
|
+ [(id)self.uut.presenter verify];
|
|
547
|
+}
|
|
548
|
+
|
|
549
|
+- (void)testOverrideOptions {
|
|
550
|
+ RNNNavigationOptions* newOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
|
|
551
|
+ newOptions.topBar.background.color = [[Color alloc] initWithValue:[UIColor redColor]];
|
|
552
|
+
|
|
553
|
+ [self.uut overrideOptions:newOptions];
|
|
554
|
+ XCTAssertEqual([UIColor redColor], self.uut.options.topBar.background.color.get);
|
|
555
|
+}
|
|
556
|
+
|
|
557
|
+#pragma mark BottomTabs
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+- (RNNStackController *)createNavigationController {
|
|
561
|
+ RNNStackController* nav = [[RNNStackController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:[[RNNStackPresenter alloc] init] eventEmitter:nil childViewControllers:@[self.uut]];
|
|
562
|
+
|
|
563
|
+ return nav;
|
|
564
|
+}
|
|
565
|
+
|
|
566
|
+@end
|