react-native-navigation的迁移库

RNNNavigationControllerTest.m 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #import <XCTest/XCTest.h>
  2. #import "RNNNavigationController.h"
  3. @interface RNNNavigationControllerTest : XCTestCase
  4. @property (nonatomic, strong) RNNNavigationController *uut;
  5. @end
  6. @implementation RNNNavigationControllerTest {
  7. RNNRootViewController* _vc1;
  8. RNNRootViewController* _vc2;
  9. UIViewController* _vc3;
  10. }
  11. - (void)setUp {
  12. [super setUp];
  13. self.uut = [[RNNNavigationController alloc] initWithLayoutInfo:[self createLayoutInfo]];
  14. _vc1 = [[RNNRootViewController alloc] init];
  15. _vc1.layoutInfo = [self createLayoutInfo];
  16. _vc2 = [[RNNRootViewController alloc] init];
  17. _vc2.layoutInfo = [self createLayoutInfo];
  18. _vc3 = [UIViewController new];
  19. }
  20. - (void)testSetViewControllers_shouldPropogateOptionsToViewController {
  21. self.uut.layoutInfo.options.topBar.visible = @(1);
  22. [self.uut setViewControllers:@[_vc1]];
  23. XCTAssertTrue(_vc1.layoutInfo.options.topBar.visible.boolValue == self.uut.layoutInfo.options.topBar.visible.boolValue);
  24. }
  25. - (void)testSetViewControllers_externalViewControllerShouldNotCrash {
  26. NSArray* viewControllers = @[_vc1, _vc3];
  27. XCTAssertNoThrow([self.uut setViewControllers:viewControllers]);
  28. }
  29. - (void)testPushViewController_shouldPropogateOptionsToViewController {
  30. self.uut.layoutInfo.options.topBar.visible = @(1);
  31. [self.uut pushViewController:_vc2 animated:NO];
  32. XCTAssertTrue(_vc2.layoutInfo.options.topBar.visible.boolValue == self.uut.layoutInfo.options.topBar.visible.boolValue);
  33. }
  34. - (void)testPushViewController_externalViewControllerShouldNotCrash {
  35. XCTAssertNoThrow([self.uut pushViewController:_vc3 animated:NO]);
  36. }
  37. - (void)testChildViewControllerForStatusBarStyle_shouldReturnTopViewController {
  38. XCTAssertTrue(self.uut.childViewControllerForStatusBarStyle == self.uut.topViewController);
  39. }
  40. - (void)testGetLeafViewController_shouldReturnTopViewController {
  41. XCTAssertTrue(self.uut.getLeafViewController == self.uut.topViewController);
  42. }
  43. - (void)testPreferredStatusBarStyle_shouldReturnLeafPreferredStatusBarStyle {
  44. [self.uut setViewControllers:@[_vc1]];
  45. self.uut.getLeafViewController.layoutInfo.options.statusBar.style = @"dark";
  46. XCTAssertTrue(self.uut.preferredStatusBarStyle == self.uut.getLeafViewController.preferredStatusBarStyle);
  47. }
  48. - (RNNLayoutInfo *)createLayoutInfo {
  49. RNNLayoutInfo *layoutInfo = [RNNLayoutInfo new];
  50. layoutInfo.options = [[RNNNavigationOptions alloc] initWithDict:@{}];
  51. return layoutInfo;
  52. }
  53. @end