react-native-navigation的迁移库

RNNOverlayManagerTest.m 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #import <XCTest/XCTest.h>
  2. #import "RNNOverlayManager.h"
  3. @interface RNNOverlayManagerTest : XCTestCase
  4. @property (nonatomic, retain) RNNOverlayManager* overlayManager;
  5. @property (nonatomic, retain) UIViewController* overlayVC;
  6. @end
  7. @implementation RNNOverlayManagerTest
  8. - (void)setUp {
  9. [super setUp];
  10. _overlayManager = [RNNOverlayManager new];
  11. _overlayVC = [UIViewController new];
  12. }
  13. - (void)testShowOverlayShouldAddWindowWithVCAsRoot {
  14. [_overlayManager showOverlay:_overlayVC];
  15. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  16. XCTAssertTrue([window.rootViewController isEqual:_overlayVC]);
  17. }
  18. - (void)testShowOverlayShouldAddVisibleWindow {
  19. [_overlayManager showOverlay:_overlayVC];
  20. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  21. XCTAssertTrue(window.windowLevel == UIWindowLevelNormal);
  22. XCTAssertFalse(window.hidden);
  23. }
  24. - (void)testDismissOverlayShouldCleanWindowRootVC {
  25. [_overlayManager showOverlay:_overlayVC];
  26. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  27. [_overlayManager dismissOverlay:_overlayVC];
  28. XCTAssertNil(window.rootViewController);
  29. }
  30. - (void)testDismissOverlayShouldHideWindow {
  31. [_overlayManager showOverlay:_overlayVC];
  32. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  33. [_overlayManager dismissOverlay:_overlayVC];
  34. XCTAssertTrue(window.hidden);
  35. }
  36. - (void)testDismissOverlayShouldRemoveOverlayWindow {
  37. [_overlayManager showOverlay:_overlayVC];
  38. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  39. [_overlayManager dismissOverlay:_overlayVC];
  40. XCTAssertFalse([_overlayManager.overlayWindows containsObject:window]);
  41. }
  42. - (void)testDismissOverlayShouldNotRemoveWrongVC {
  43. [_overlayManager showOverlay:_overlayVC];
  44. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  45. [_overlayManager dismissOverlay:[UIViewController new]];
  46. XCTAssertTrue([_overlayManager.overlayWindows containsObject:window]);
  47. }
  48. @end