|
@@ -8,6 +8,21 @@
|
8
|
8
|
#import "RNNTabBarController.h"
|
9
|
9
|
#import "RNNUIBarButtonItem.h"
|
10
|
10
|
|
|
11
|
+
|
|
12
|
+@interface RNNRootViewController (EmbedInTabBar)
|
|
13
|
+- (void)embedInTabBarController;
|
|
14
|
+@end
|
|
15
|
+
|
|
16
|
+@implementation RNNRootViewController (EmbedInTabBar)
|
|
17
|
+
|
|
18
|
+- (void)embedInTabBarController {
|
|
19
|
+ RNNTabBarController* tabVC = [[RNNTabBarController alloc] init];
|
|
20
|
+ tabVC.viewControllers = @[self];
|
|
21
|
+ [self viewWillAppear:false];
|
|
22
|
+}
|
|
23
|
+
|
|
24
|
+@end
|
|
25
|
+
|
11
|
26
|
@interface RNNRootViewControllerTest : XCTestCase
|
12
|
27
|
|
13
|
28
|
@property (nonatomic, strong) id<RNNRootViewCreator> creator;
|
|
@@ -561,4 +576,107 @@
|
561
|
576
|
XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeBottom);
|
562
|
577
|
}
|
563
|
578
|
|
|
579
|
+#pragma mark BottomTabs
|
|
580
|
+
|
|
581
|
+- (void)testTabBarTranslucent_default {
|
|
582
|
+ [self.uut embedInTabBarController];
|
|
583
|
+ XCTAssertFalse(self.uut.tabBarController.tabBar.translucent);
|
|
584
|
+}
|
|
585
|
+
|
|
586
|
+- (void)testTabBarTranslucent_true {
|
|
587
|
+ self.options.bottomTabs.translucent = @(1);
|
|
588
|
+ [self.uut embedInTabBarController];
|
|
589
|
+ XCTAssertTrue(self.uut.tabBarController.tabBar.translucent);
|
|
590
|
+}
|
|
591
|
+
|
|
592
|
+- (void)testTabBarTranslucent_false {
|
|
593
|
+ self.options.bottomTabs.translucent = @(0);
|
|
594
|
+ [self.uut embedInTabBarController];
|
|
595
|
+ XCTAssertFalse(self.uut.tabBarController.tabBar.translucent);
|
|
596
|
+}
|
|
597
|
+
|
|
598
|
+- (void)testTabBarHideShadow_default {
|
|
599
|
+ [self.uut embedInTabBarController];
|
|
600
|
+ XCTAssertFalse(self.uut.tabBarController.tabBar.clipsToBounds);
|
|
601
|
+}
|
|
602
|
+
|
|
603
|
+- (void)testTabBarHideShadow_true {
|
|
604
|
+ self.options.bottomTabs.hideShadow = @(1);
|
|
605
|
+ [self.uut embedInTabBarController];
|
|
606
|
+ XCTAssertTrue(self.uut.tabBarController.tabBar.clipsToBounds);
|
|
607
|
+}
|
|
608
|
+
|
|
609
|
+- (void)testTabBarHideShadow_false {
|
|
610
|
+ self.options.bottomTabs.hideShadow = @(0);
|
|
611
|
+ [self.uut embedInTabBarController];
|
|
612
|
+ XCTAssertFalse(self.uut.tabBarController.tabBar.clipsToBounds);
|
|
613
|
+}
|
|
614
|
+
|
|
615
|
+- (void)testTabBarBackgroundColor {
|
|
616
|
+ self.options.bottomTabs.backgroundColor = @(0xFFFF0000);
|
|
617
|
+ [self.uut embedInTabBarController];
|
|
618
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
619
|
+ XCTAssertTrue([self.uut.tabBarController.tabBar.barTintColor isEqual:expectedColor]);
|
|
620
|
+}
|
|
621
|
+
|
|
622
|
+-(void)testTabBarTextColor_validColor{
|
|
623
|
+ NSNumber* inputColor = @(0xFFFF0000);
|
|
624
|
+ self.options.bottomTabs.textColor = inputColor;
|
|
625
|
+ [self.uut embedInTabBarController];
|
|
626
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
627
|
+ NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
|
|
628
|
+ XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
|
|
629
|
+}
|
|
630
|
+
|
|
631
|
+-(void)testTabBarTextFontFamily_validFont{
|
|
632
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
633
|
+ self.options.bottomTabs.textFontFamily = inputFont;
|
|
634
|
+ [self.uut embedInTabBarController];
|
|
635
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:10];
|
|
636
|
+ NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
|
|
637
|
+ XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
|
|
638
|
+}
|
|
639
|
+
|
|
640
|
+-(void)testTabBarTextFontSize_withoutTextFontFamily_withoutTextColor {
|
|
641
|
+ self.options.bottomTabs.textFontSize = @(15);
|
|
642
|
+ [self.uut embedInTabBarController];
|
|
643
|
+ UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
|
644
|
+ NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
|
|
645
|
+ XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
|
|
646
|
+}
|
|
647
|
+
|
|
648
|
+-(void)testTabBarTextFontSize_withoutTextFontFamily_withTextColor {
|
|
649
|
+ self.options.bottomTabs.textFontSize = @(15);
|
|
650
|
+ self.options.bottomTabs.textColor = @(0xFFFF0000);
|
|
651
|
+ [self.uut embedInTabBarController];
|
|
652
|
+ UIFont* expectedFont = [UIFont systemFontOfSize:15];
|
|
653
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
654
|
+ NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
|
|
655
|
+ XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
|
|
656
|
+ XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
|
|
657
|
+}
|
|
658
|
+
|
|
659
|
+-(void)testTabBarTextFontSize_withTextFontFamily_withTextColor {
|
|
660
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
661
|
+ self.options.bottomTabs.textFontSize = @(15);
|
|
662
|
+ self.options.bottomTabs.textColor = @(0xFFFF0000);
|
|
663
|
+ self.options.bottomTabs.textFontFamily = inputFont;
|
|
664
|
+ [self.uut embedInTabBarController];
|
|
665
|
+ UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
|
|
666
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
|
667
|
+ NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
|
|
668
|
+ XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
|
|
669
|
+ XCTAssertTrue([attributes[@"NSColor"] isEqual:expectedColor]);
|
|
670
|
+}
|
|
671
|
+
|
|
672
|
+-(void)testTabBarTextFontSize_withTextFontFamily_withoutTextColor {
|
|
673
|
+ NSString* inputFont = @"HelveticaNeue";
|
|
674
|
+ self.options.bottomTabs.textFontSize = @(15);
|
|
675
|
+ self.options.bottomTabs.textFontFamily = inputFont;
|
|
676
|
+ [self.uut embedInTabBarController];
|
|
677
|
+ UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
|
|
678
|
+ NSDictionary* attributes = [self.uut.tabBarController.tabBar.items.firstObject titleTextAttributesForState:UIControlStateNormal];
|
|
679
|
+ XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
|
|
680
|
+}
|
|
681
|
+
|
564
|
682
|
@end
|