react-native-navigation的迁移库

UIViewController+LayoutProtocolTest.m 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "UIViewController+LayoutProtocol.h"
  4. #import "RNNViewControllerPresenter.h"
  5. #import "RCTConvert+Modal.h"
  6. @interface UIViewController_LayoutProtocolTest : XCTestCase
  7. @property (nonatomic, retain) UIViewController* uut;
  8. @end
  9. @implementation UIViewController_LayoutProtocolTest
  10. - (void)setUp {
  11. [super setUp];
  12. self.uut = [OCMockObject partialMockForObject:[UIViewController new]];
  13. self.uut.layoutInfo = [[RNNLayoutInfo alloc] init];
  14. self.uut.layoutInfo.componentId = @"componentId";
  15. }
  16. - (void)testInitWithLayoutApplyDefaultOptions {
  17. RNNViewControllerPresenter* presenter = [[RNNViewControllerPresenter alloc] init];
  18. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
  19. RNNNavigationOptions* defaultOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  20. defaultOptions.modalPresentationStyle = [[Text alloc] initWithValue:@"fullScreen"];
  21. UIViewController* uut = [[UIViewController alloc] initWithLayoutInfo:nil creator:nil options:options defaultOptions:defaultOptions presenter:presenter eventEmitter:nil childViewControllers:nil];
  22. XCTAssertEqual(uut.modalPresentationStyle, [RCTConvert UIModalPresentationStyle:@"fullScreen"]);
  23. }
  24. - (void)testInitWithLayoutInfoShouldSetChildViewControllers {
  25. UIViewController* child1 = [UIViewController new];
  26. UIViewController* child2 = [UIViewController new];
  27. NSArray* childViewControllers = @[child1, child2];
  28. UINavigationController* uut = [[UINavigationController alloc] initWithLayoutInfo:nil creator:nil options:nil defaultOptions:nil presenter:nil eventEmitter:nil childViewControllers:childViewControllers];
  29. XCTAssertEqual(uut.viewControllers[0], child1);
  30. XCTAssertEqual(uut.viewControllers[1], child2);
  31. }
  32. @end