react-native-navigation的迁移库

RNNOverlayManagerTest.m 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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)testShowOverlayShouldCreateTransparentView {
  25. [_overlayManager showOverlay:_overlayVC];
  26. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  27. XCTAssertTrue(window.rootViewController.view.backgroundColor == [UIColor clearColor]);
  28. }
  29. - (void)testShowOverlayShouldNotBeKeyWindow {
  30. [_overlayManager showOverlay:_overlayVC];
  31. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  32. XCTAssertFalse(window.keyWindow);
  33. }
  34. - (void)testDismissOverlayShouldCleanWindowRootVC {
  35. [_overlayManager showOverlay:_overlayVC];
  36. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  37. [_overlayManager dismissOverlay:_overlayVC];
  38. XCTAssertNil(window.rootViewController);
  39. }
  40. - (void)testDismissOverlayShouldHideWindow {
  41. [_overlayManager showOverlay:_overlayVC];
  42. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  43. [_overlayManager dismissOverlay:_overlayVC];
  44. XCTAssertTrue(window.hidden);
  45. }
  46. - (void)testDismissOverlayShouldRemoveOverlayWindow {
  47. [_overlayManager showOverlay:_overlayVC];
  48. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  49. [_overlayManager dismissOverlay:_overlayVC];
  50. XCTAssertFalse([_overlayManager.overlayWindows containsObject:window]);
  51. }
  52. - (void)testDismissOverlayShouldNotRemoveWrongVC {
  53. [_overlayManager showOverlay:_overlayVC];
  54. UIWindow* window = _overlayManager.overlayWindows.lastObject;
  55. [_overlayManager dismissOverlay:[UIViewController new]];
  56. XCTAssertTrue([_overlayManager.overlayWindows containsObject:window]);
  57. }
  58. @end