react-native-navigation的迁移库

RNNViewControllerPresenterTest.m 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "RNNViewControllerPresenter.h"
  4. #import "UIViewController+RNNOptions.h"
  5. @interface RNNViewControllerPresenterTest : XCTestCase
  6. @property (nonatomic, strong) RNNViewControllerPresenter *uut;
  7. @property (nonatomic, strong) RNNNavigationOptions *options;
  8. @property (nonatomic, strong) UIViewController *bindedViewController;
  9. @end
  10. @implementation RNNViewControllerPresenterTest
  11. - (void)setUp {
  12. [super setUp];
  13. self.uut = [[RNNViewControllerPresenter alloc] init];
  14. self.bindedViewController = [OCMockObject partialMockForObject:[UIViewController new]];
  15. [self.uut bindViewController:self.bindedViewController];
  16. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  17. }
  18. - (void)testApplyOptions_backgroundImageDefaultNil {
  19. [self.uut applyOptions:self.options];
  20. XCTAssertNil(((UIImageView *)self.bindedViewController.view.subviews[0]).image);
  21. }
  22. - (void)testApplyOptions_topBarPrefersLargeTitleDefaultFalse {
  23. [self.uut applyOptions:self.options];
  24. XCTAssertTrue(self.bindedViewController.navigationItem.largeTitleDisplayMode == UINavigationItemLargeTitleDisplayModeNever);
  25. }
  26. - (void)testApplyOptions_layoutBackgroundColorDefaultWhiteColor {
  27. [self.uut applyOptions:self.options];
  28. XCTAssertNil(self.bindedViewController.view.backgroundColor);
  29. }
  30. - (void)testApplyOptions_statusBarBlurDefaultFalse {
  31. [self.uut applyOptions:self.options];
  32. XCTAssertNil([self.bindedViewController.view viewWithTag:BLUR_STATUS_TAG]);
  33. }
  34. - (void)testApplyOptions_statusBarStyleDefaultStyle {
  35. [self.uut applyOptions:self.options];
  36. XCTAssertTrue([self.bindedViewController preferredStatusBarStyle] == UIStatusBarStyleDefault);
  37. }
  38. - (void)testApplyOptions_backButtonVisibleDefaultTrue {
  39. [self.uut applyOptions:self.options];
  40. XCTAssertFalse(self.bindedViewController.navigationItem.hidesBackButton);
  41. }
  42. - (void)testApplyOptions_drawBehindTabBarTrueWhenVisibleFalse {
  43. self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
  44. [[(id)self.bindedViewController expect] rnn_setDrawBehindTabBar:YES];
  45. [self.uut applyOptions:self.options];
  46. [(id)self.bindedViewController verify];
  47. }
  48. @end