react-native-navigation的迁移库

RNNRootViewControllerTest.m 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. #import <XCTest/XCTest.h>
  2. #import "RNNRootViewController.h"
  3. #import "RNNReactRootViewCreator.h"
  4. #import "RNNTestRootViewCreator.h"
  5. #import <React/RCTConvert.h>
  6. #import "RNNNavigationOptions.h"
  7. #import "RNNNavigationController.h"
  8. #import "RNNTabBarController.h"
  9. #import "RNNUIBarButtonItem.h"
  10. @interface RNNRootViewControllerTest : XCTestCase
  11. @property (nonatomic, strong) id<RNNRootViewCreator> creator;
  12. @property (nonatomic, strong) NSString* pageName;
  13. @property (nonatomic, strong) NSString* containerId;
  14. @property (nonatomic, strong) id emitter;
  15. @property (nonatomic, strong) RNNNavigationOptions* options;
  16. @property (nonatomic, strong) RNNRootViewController* uut;
  17. @end
  18. @implementation RNNRootViewControllerTest
  19. - (void)setUp {
  20. [super setUp];
  21. self.creator = [[RNNTestRootViewCreator alloc] init];
  22. self.pageName = @"somename";
  23. self.containerId = @"cntId";
  24. self.emitter = nil;
  25. self.options = [RNNNavigationOptions new];
  26. self.uut = [[RNNRootViewController alloc] initWithName:self.pageName withOptions:self.options withContainerId:self.containerId rootViewCreator:self.creator eventEmitter:self.emitter animator:nil];
  27. }
  28. -(void)testTopBarBackgroundColor_validColor{
  29. NSNumber* inputColor = @(0xFFFF0000);
  30. self.options.topBar.backgroundColor = inputColor;
  31. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  32. [self.uut viewWillAppear:false];
  33. UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
  34. XCTAssertTrue([self.uut.navigationController.navigationBar.barTintColor isEqual:expectedColor]);
  35. }
  36. -(void)testTopBarBackgroundColorWithoutNavigationController{
  37. NSNumber* inputColor = @(0xFFFF0000);
  38. self.options.topBar.backgroundColor = inputColor;
  39. XCTAssertNoThrow([self.uut viewWillAppear:false]);
  40. }
  41. - (void)testStatusBarHidden_default {
  42. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  43. [self.uut viewWillAppear:false];
  44. XCTAssertFalse([self.uut prefersStatusBarHidden]);
  45. }
  46. - (void)testStatusBarHidden_true {
  47. self.options.statusBarHidden = @(1);
  48. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  49. [self.uut viewWillAppear:false];
  50. XCTAssertTrue([self.uut prefersStatusBarHidden]);
  51. }
  52. - (void)testStatusBarHideWithTopBar_false {
  53. self.options.statusBarHideWithTopBar = @(0);
  54. self.options.topBar.hidden = @(1);
  55. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  56. [self.uut viewWillAppear:false];
  57. XCTAssertFalse([self.uut prefersStatusBarHidden]);
  58. }
  59. - (void)testStatusBarHideWithTopBar_true {
  60. self.options.statusBarHideWithTopBar = @(1);
  61. self.options.topBar.hidden = @(1);
  62. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  63. [self.uut viewWillAppear:false];
  64. XCTAssertTrue([self.uut prefersStatusBarHidden]);
  65. }
  66. - (void)testStatusBarHidden_false {
  67. self.options.statusBarHidden = @(0);
  68. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  69. [self.uut viewWillAppear:false];
  70. XCTAssertFalse([self.uut prefersStatusBarHidden]);
  71. }
  72. -(void)testTitle_string{
  73. NSString* title =@"some title";
  74. self.options.topBar.title = title;
  75. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  76. [self.uut viewWillAppear:false];
  77. XCTAssertTrue([self.uut.navigationItem.title isEqual:title]);
  78. }
  79. -(void)testTitle_default{
  80. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  81. [self.uut viewWillAppear:false];
  82. XCTAssertNil(self.uut.navigationItem.title);
  83. }
  84. -(void)testTopBarTextColor_validColor{
  85. NSNumber* inputColor = @(0xFFFF0000);
  86. self.options.topBar.textColor = inputColor;
  87. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  88. [self.uut viewWillAppear:false];
  89. UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
  90. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
  91. }
  92. -(void)testScreenBackgroundColor_validColor{
  93. NSNumber* inputColor = @(0xFFFF0000);
  94. self.options.screenBackgroundColor = inputColor;
  95. [self.uut viewWillAppear:false];
  96. UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
  97. XCTAssertTrue([self.uut.view.backgroundColor isEqual:expectedColor]);
  98. }
  99. -(void)testPopGestureEnabled_true{
  100. NSNumber* popGestureEnabled = @(1);
  101. self.options.popGesture = popGestureEnabled;
  102. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  103. [self.uut viewWillAppear:false];
  104. XCTAssertTrue(self.uut.navigationController.interactivePopGestureRecognizer.enabled);
  105. }
  106. -(void)testPopGestureEnabled_false{
  107. NSNumber* popGestureEnabled = @(0);
  108. self.options.popGesture = popGestureEnabled;
  109. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  110. [self.uut viewWillAppear:false];
  111. XCTAssertFalse(self.uut.navigationController.interactivePopGestureRecognizer.enabled);
  112. }
  113. -(void)testTopBarTextFontFamily_validFont{
  114. NSString* inputFont = @"HelveticaNeue";
  115. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  116. self.options.topBar.textFontFamily = inputFont;
  117. [self.uut viewWillAppear:false];
  118. UIFont* expectedFont = [UIFont fontWithName:inputFont size:20];
  119. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
  120. }
  121. -(void)testTopBarHideOnScroll_true {
  122. NSNumber* hideOnScrollInput = @(1);
  123. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  124. self.options.topBar.hideOnScroll = hideOnScrollInput;
  125. [self.uut viewWillAppear:false];
  126. XCTAssertTrue(self.uut.navigationController.hidesBarsOnSwipe);
  127. }
  128. -(void)testTopBarButtonColor {
  129. NSNumber* inputColor = @(0xFFFF0000);
  130. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  131. self.options.topBar.buttonColor = inputColor;
  132. [self.uut viewWillAppear:false];
  133. UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
  134. XCTAssertTrue([self.uut.navigationController.navigationBar.tintColor isEqual:expectedColor]);
  135. }
  136. -(void)testTopBarTranslucent {
  137. NSNumber* topBarTranslucentInput = @(0);
  138. self.options.topBar.translucent = topBarTranslucentInput;
  139. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  140. [self.uut viewWillAppear:false];
  141. XCTAssertFalse(self.uut.navigationController.navigationBar.translucent);
  142. }
  143. -(void)testTabBadge {
  144. NSString* tabBadgeInput = @"5";
  145. self.options.bottomTabs.tabBadge = tabBadgeInput;
  146. __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
  147. NSMutableArray* controllers = [NSMutableArray new];
  148. UITabBarItem* item = [[UITabBarItem alloc] initWithTitle:@"A Tab" image:nil tag:1];
  149. [self.uut setTabBarItem:item];
  150. [controllers addObject:self.uut];
  151. [vc setViewControllers:controllers];
  152. [self.uut viewWillAppear:false];
  153. XCTAssertTrue([self.uut.tabBarItem.badgeValue isEqualToString:tabBadgeInput]);
  154. }
  155. -(void)testTopBarTransparent_BOOL_True {
  156. NSNumber* topBarTransparentInput = @(1);
  157. self.options.topBar.transparent = topBarTransparentInput;
  158. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  159. [self.uut viewWillAppear:false];
  160. UIView* transparentView = [self.uut.navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG];
  161. XCTAssertTrue(transparentView);
  162. XCTAssertTrue([NSStringFromCGRect(transparentView.frame) isEqual: NSStringFromCGRect(CGRectZero)]);
  163. }
  164. -(void)testTopBarTransparent_BOOL_false {
  165. NSNumber* topBarTransparentInput = @(0);
  166. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  167. self.options.topBar.transparent = topBarTransparentInput;
  168. [self.uut viewWillAppear:false];
  169. UIView* transparentView = [self.uut.navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG];
  170. XCTAssertFalse(transparentView);
  171. }
  172. -(void)testStoreOriginalTopBarImages {
  173. }
  174. -(void)testTopBarTextFontSize_withoutTextFontFamily_withoutTextColor {
  175. NSNumber* topBarTextFontSizeInput = @(15);
  176. self.options.topBar.textFontSize = topBarTextFontSizeInput;
  177. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  178. [self.uut viewWillAppear:false];
  179. UIFont* expectedFont = [UIFont systemFontOfSize:15];
  180. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
  181. }
  182. -(void)testTopBarTextFontSize_withoutTextFontFamily_withTextColor {
  183. NSNumber* topBarTextFontSizeInput = @(15);
  184. NSNumber* inputColor = @(0xFFFF0000);
  185. self.options.topBar.textFontSize = topBarTextFontSizeInput;
  186. self.options.topBar.textColor = inputColor;
  187. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  188. [self.uut viewWillAppear:false];
  189. UIFont* expectedFont = [UIFont systemFontOfSize:15];
  190. UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
  191. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
  192. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
  193. }
  194. -(void)testTopBarTextFontSize_withTextFontFamily_withTextColor {
  195. NSNumber* topBarTextFontSizeInput = @(15);
  196. NSNumber* inputColor = @(0xFFFF0000);
  197. NSString* inputFont = @"HelveticaNeue";
  198. self.options.topBar.textFontSize = topBarTextFontSizeInput;
  199. self.options.topBar.textColor = inputColor;
  200. self.options.topBar.textFontFamily = inputFont;
  201. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  202. [self.uut viewWillAppear:false];
  203. UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
  204. UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
  205. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
  206. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
  207. }
  208. -(void)testTopBarTextFontSize_withTextFontFamily_withoutTextColor {
  209. NSNumber* topBarTextFontSizeInput = @(15);
  210. NSString* inputFont = @"HelveticaNeue";
  211. self.options.topBar.textFontSize = topBarTextFontSizeInput;
  212. self.options.topBar.textFontFamily = inputFont;
  213. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  214. [self.uut viewWillAppear:false];
  215. UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
  216. XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
  217. }
  218. // TODO: Currently not passing
  219. -(void)testTopBarTextFontFamily_invalidFont{
  220. NSString* inputFont = @"HelveticaNeueeeee";
  221. __unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  222. self.options.topBar.textFontFamily = inputFont;
  223. // XCTAssertThrows([self.uut viewWillAppear:false]);
  224. }
  225. -(void)testOrientation_portrait {
  226. NSArray* supportedOrientations = @[@"portrait"];
  227. self.options.orientation = supportedOrientations;
  228. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  229. [self.uut viewWillAppear:false];
  230. UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskPortrait;
  231. XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
  232. }
  233. -(void)testOrientation_portraitString {
  234. NSString* supportedOrientation = @"portrait";
  235. self.options.orientation = supportedOrientation;
  236. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  237. [self.uut viewWillAppear:false];
  238. UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait);
  239. XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
  240. }
  241. -(void)testOrientation_portraitAndLandscape {
  242. NSArray* supportedOrientations = @[@"portrait", @"landscape"];
  243. self.options.orientation = supportedOrientations;
  244. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  245. [self.uut viewWillAppear:false];
  246. UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape);
  247. XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
  248. }
  249. -(void)testOrientation_all {
  250. NSArray* supportedOrientations = @[@"all"];
  251. self.options.orientation = supportedOrientations;
  252. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  253. [self.uut viewWillAppear:false];
  254. UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskAll;
  255. XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
  256. }
  257. -(void)testOrientation_default {
  258. NSString* supportedOrientations = @"default";
  259. self.options.orientation = supportedOrientations;
  260. __unused UINavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
  261. [self.uut viewWillAppear:false];
  262. UIInterfaceOrientationMask expectedOrientation = [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
  263. XCTAssertTrue(self.uut.navigationController.supportedInterfaceOrientations == expectedOrientation);
  264. }
  265. -(void)testOrientationTabsController_portrait {
  266. NSArray* supportedOrientations = @[@"portrait"];
  267. self.options.orientation = supportedOrientations;
  268. __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
  269. NSMutableArray* controllers = [NSMutableArray new];
  270. [controllers addObject:self.uut];
  271. [vc setViewControllers:controllers];
  272. [self.uut viewWillAppear:false];
  273. UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskPortrait;
  274. XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
  275. }
  276. -(void)testOrientationTabsController_portraitAndLandscape {
  277. NSArray* supportedOrientations = @[@"portrait", @"landscape"];
  278. self.options.orientation = supportedOrientations;
  279. __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
  280. NSMutableArray* controllers = [NSMutableArray new];
  281. [controllers addObject:self.uut];
  282. [vc setViewControllers:controllers];
  283. [self.uut viewWillAppear:false];
  284. UIInterfaceOrientationMask expectedOrientation = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape);
  285. XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
  286. }
  287. -(void)testOrientationTabsController_all {
  288. NSArray* supportedOrientations = @[@"all"];
  289. self.options.orientation = supportedOrientations;
  290. __unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
  291. NSMutableArray* controllers = [NSMutableArray new];
  292. [controllers addObject:self.uut];
  293. [vc setViewControllers:controllers];
  294. [self.uut viewWillAppear:false];
  295. UIInterfaceOrientationMask expectedOrientation = UIInterfaceOrientationMaskAll;
  296. XCTAssertTrue(self.uut.tabBarController.supportedInterfaceOrientations == expectedOrientation);
  297. }
  298. -(void)testRightButtonsWithTitle_withoutStyle {
  299. self.options.rightButtons = @[@{@"id": @"testId", @"title": @"test"}];
  300. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  301. [self.uut viewWillAppear:false];
  302. RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.rightBarButtonItems objectAtIndex:0];
  303. NSString* expectedButtonId = @"testId";
  304. NSString* expectedTitle = @"test";
  305. XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
  306. XCTAssertTrue([button.title isEqualToString:expectedTitle]);
  307. XCTAssertTrue(button.enabled);
  308. }
  309. -(void)testRightButtonsWithTitle_withStyle {
  310. NSNumber* inputColor = @(0xFFFF0000);
  311. self.options.rightButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
  312. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  313. [self.uut viewWillAppear:false];
  314. RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.rightBarButtonItems objectAtIndex:0];
  315. NSString* expectedButtonId = @"testId";
  316. NSString* expectedTitle = @"test";
  317. XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
  318. XCTAssertTrue([button.title isEqualToString:expectedTitle]);
  319. XCTAssertFalse(button.enabled);
  320. //TODO: Determine how to tests buttonColor,buttonFontSize and buttonFontWeight?
  321. }
  322. -(void)testLeftButtonsWithTitle_withoutStyle {
  323. self.options.leftButtons = @[@{@"id": @"testId", @"title": @"test"}];
  324. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  325. [self.uut viewWillAppear:false];
  326. RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.leftBarButtonItems objectAtIndex:0];
  327. NSString* expectedButtonId = @"testId";
  328. NSString* expectedTitle = @"test";
  329. XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
  330. XCTAssertTrue([button.title isEqualToString:expectedTitle]);
  331. XCTAssertTrue(button.enabled);
  332. }
  333. -(void)testLeftButtonsWithTitle_withStyle {
  334. NSNumber* inputColor = @(0xFFFF0000);
  335. self.options.leftButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
  336. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  337. [self.uut viewWillAppear:false];
  338. RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.leftBarButtonItems objectAtIndex:0];
  339. NSString* expectedButtonId = @"testId";
  340. NSString* expectedTitle = @"test";
  341. XCTAssertTrue([button.buttonId isEqualToString:expectedButtonId]);
  342. XCTAssertTrue([button.title isEqualToString:expectedTitle]);
  343. XCTAssertFalse(button.enabled);
  344. //TODO: Determine how to tests buttonColor,buttonFontSize and buttonFontWeight?
  345. }
  346. -(void)testTopBarNoBorderOn {
  347. NSNumber* topBarNoBorderInput = @(1);
  348. self.options.topBar.noBorder = topBarNoBorderInput;
  349. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  350. [self.uut viewWillAppear:false];
  351. XCTAssertNotNil(self.uut.navigationController.navigationBar.shadowImage);
  352. }
  353. -(void)testTopBarNoBorderOff {
  354. NSNumber* topBarNoBorderInput = @(0);
  355. self.options.topBar.noBorder = topBarNoBorderInput;
  356. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  357. [self.uut viewWillAppear:false];
  358. XCTAssertNil(self.uut.navigationController.navigationBar.shadowImage);
  359. }
  360. -(void)testStatusBarBlurOn {
  361. NSNumber* statusBarBlurInput = @(1);
  362. self.options.statusBarBlur = statusBarBlurInput;
  363. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  364. [self.uut viewWillAppear:false];
  365. XCTAssertNotNil([self.uut.view viewWithTag:BLUR_STATUS_TAG]);
  366. }
  367. -(void)testStatusBarBlurOff {
  368. NSNumber* statusBarBlurInput = @(0);
  369. self.options.statusBarBlur = statusBarBlurInput;
  370. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  371. [self.uut viewWillAppear:false];
  372. XCTAssertNil([self.uut.view viewWithTag:BLUR_STATUS_TAG]);
  373. }
  374. - (void)testTabBarHidden_default {
  375. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  376. [self.uut viewWillAppear:false];
  377. XCTAssertFalse([self.uut hidesBottomBarWhenPushed]);
  378. }
  379. - (void)testTabBarHidden_true {
  380. self.options.bottomTabs.hidden = @(1);
  381. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  382. [self.uut viewWillAppear:false];
  383. XCTAssertTrue([self.uut hidesBottomBarWhenPushed]);
  384. }
  385. - (void)testTabBarHidden_false {
  386. self.options.bottomTabs.hidden = @(0);
  387. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  388. [self.uut viewWillAppear:false];
  389. XCTAssertFalse([self.uut hidesBottomBarWhenPushed]);
  390. }
  391. -(void)testTopBarBlur_default {
  392. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  393. [self.uut viewWillAppear:false];
  394. XCTAssertNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
  395. }
  396. -(void)testTopBarLargeTitle_default {
  397. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  398. [self.uut viewWillAppear:false];
  399. XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeNever);
  400. }
  401. -(void)testTopBarLargeTitle_true {
  402. self.options.topBar.largeTitle = @(1);
  403. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  404. [self.uut viewWillAppear:false];
  405. XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeAlways);
  406. }
  407. -(void)testTopBarLargeTitle_false {
  408. self.options.topBar.largeTitle = @(0);
  409. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  410. [self.uut viewWillAppear:false];
  411. XCTAssertEqual(self.uut.navigationItem.largeTitleDisplayMode, UINavigationItemLargeTitleDisplayModeNever);
  412. }
  413. -(void)testTopBarBlur_false {
  414. NSNumber* topBarBlurInput = @(0);
  415. self.options.topBar.blur = topBarBlurInput;
  416. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  417. [self.uut viewWillAppear:false];
  418. XCTAssertNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
  419. }
  420. -(void)testTopBarBlur_true {
  421. NSNumber* topBarBlurInput = @(1);
  422. self.options.topBar.blur = topBarBlurInput;
  423. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  424. [self.uut viewWillAppear:false];
  425. XCTAssertNotNil([self.uut.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]);
  426. }
  427. -(void)testBackgroundImage {
  428. UIImage* backgroundImage = [[UIImage alloc] init];
  429. self.options.backgroundImage = backgroundImage;
  430. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  431. [self.uut viewWillAppear:false];
  432. XCTAssertTrue([[(UIImageView*)self.uut.view.subviews[0] image] isEqual:backgroundImage]);
  433. }
  434. -(void)testRootBackgroundImage {
  435. UIImage* rootBackgroundImage = [[UIImage alloc] init];
  436. self.options.rootBackgroundImage = rootBackgroundImage;
  437. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  438. [self.uut viewWillAppear:false];
  439. XCTAssertTrue([[(UIImageView*)self.uut.navigationController.view.subviews[0] image] isEqual:rootBackgroundImage]);
  440. }
  441. -(void)testTopBarDrawUnder_true {
  442. self.options.topBar.drawUnder = @(1);
  443. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  444. [self.uut viewWillAppear:false];
  445. XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeTop);
  446. }
  447. -(void)testTopBarDrawUnder_false {
  448. self.options.topBar.drawUnder = @(0);
  449. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  450. [self.uut viewWillAppear:false];
  451. XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeTop);
  452. }
  453. -(void)testBottomTabsDrawUnder_true {
  454. self.options.bottomTabs.drawUnder = @(1);
  455. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  456. [self.uut viewWillAppear:false];
  457. XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeBottom);
  458. }
  459. -(void)testBottomTabsDrawUnder_false {
  460. self.options.bottomTabs.drawUnder = @(0);
  461. __unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
  462. [self.uut viewWillAppear:false];
  463. XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeBottom);
  464. }
  465. @end