react-native-navigation的迁移库

RNNNavigationControllerTest.m 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #import <XCTest/XCTest.h>
  2. #import "RNNNavigationController.h"
  3. #import "RNNRootViewController.h"
  4. @interface RNNNavigationControllerTest : XCTestCase
  5. @property (nonatomic, strong) RNNNavigationController *uut;
  6. @end
  7. @implementation RNNNavigationControllerTest {
  8. RNNRootViewController* _vc1;
  9. RNNRootViewController* _vc2;
  10. UIViewController* _vc3;
  11. }
  12. - (void)setUp {
  13. [super setUp];
  14. _vc1 = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[[RNNViewControllerPresenter alloc] init] options:nil];
  15. _vc2 = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[[RNNViewControllerPresenter alloc] init] options:nil];
  16. _vc3 = [UIViewController new];
  17. self.uut = [[RNNNavigationController alloc] initWithRootViewController:_vc1];
  18. self.uut.options = [[RNNNavigationOptions alloc] initWithDict:@{}];
  19. self.uut.presenter = [[RNNNavigationControllerPresenter alloc] init];;
  20. }
  21. - (void)testChildViewControllerForStatusBarStyle_shouldReturnTopViewController {
  22. XCTAssertTrue(self.uut.childViewControllerForStatusBarStyle == self.uut.topViewController);
  23. }
  24. - (void)testGetLeafViewController_shouldReturnTopViewController {
  25. XCTAssertTrue(self.uut.getLeafViewController == self.uut.topViewController);
  26. }
  27. - (void)testPreferredStatusBarStyle_shouldReturnLeafPreferredStatusBarStyle {
  28. self.uut.getLeafViewController.options.statusBar.style = @"light";
  29. XCTAssertTrue(self.uut.preferredStatusBarStyle == self.uut.getLeafViewController.preferredStatusBarStyle);
  30. }
  31. - (void)testPopGestureEnabled_false {
  32. NSNumber* popGestureEnabled = @(0);
  33. self.uut.options.popGesture = popGestureEnabled;
  34. [self.uut viewDidLoad];
  35. XCTAssertFalse(self.uut.interactivePopGestureRecognizer.enabled);
  36. }
  37. - (void)testPopGestureEnabled_true {
  38. NSNumber* popGestureEnabled = @(1);
  39. self.uut.options.popGesture = popGestureEnabled;
  40. [self.uut viewDidLoad];
  41. XCTAssertTrue(self.uut.interactivePopGestureRecognizer.enabled);
  42. }
  43. - (void)testRootBackgroundImage {
  44. UIImage* rootBackgroundImage = [[UIImage alloc] init];
  45. self.uut.options.rootBackgroundImage = rootBackgroundImage;
  46. [self.uut viewDidLoad];
  47. XCTAssertTrue([[(UIImageView*)self.uut.view.subviews[0] image] isEqual:rootBackgroundImage]);
  48. }
  49. - (void)testTopBarBackgroundClipToBounds_true {
  50. self.uut.options.topBar.background.clipToBounds = @(1);
  51. [self.uut viewDidLoad];
  52. XCTAssertTrue(self.uut.navigationBar.clipsToBounds);
  53. }
  54. - (void)testTopBarBackgroundClipToBounds_false {
  55. self.uut.options.topBar.background.clipToBounds = @(0);
  56. [self.uut viewDidLoad];
  57. XCTAssertFalse(self.uut.navigationController.navigationBar.clipsToBounds);
  58. }
  59. @end