1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #import <XCTest/XCTest.h>
- #import "RNNOverlayManager.h"
-
- @interface RNNOverlayManagerTest : XCTestCase
-
- @property (nonatomic, retain) RNNOverlayManager* overlayManager;
- @property (nonatomic, retain) UIViewController* overlayVC;
-
- @end
-
- @implementation RNNOverlayManagerTest
-
- - (void)setUp {
- [super setUp];
- _overlayManager = [RNNOverlayManager new];
- _overlayVC = [UIViewController new];
- }
-
-
- - (void)testShowOverlayShouldAddWindowWithVCAsRoot {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- XCTAssertTrue([window.rootViewController isEqual:_overlayVC]);
- }
-
- - (void)testShowOverlayShouldAddVisibleWindow {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- XCTAssertTrue(window.windowLevel == UIWindowLevelNormal);
- XCTAssertFalse(window.hidden);
- }
-
- - (void)testShowOverlayShouldCreateTransparentView {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- XCTAssertTrue(window.rootViewController.view.backgroundColor == [UIColor clearColor]);
- }
-
- - (void)testShowOverlayShouldNotBeKeyWindow {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- XCTAssertFalse(window.keyWindow);
- }
-
- - (void)testDismissOverlayShouldCleanWindowRootVC {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- [_overlayManager dismissOverlay:_overlayVC];
- XCTAssertNil(window.rootViewController);
- }
-
- - (void)testDismissOverlayShouldHideWindow {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- [_overlayManager dismissOverlay:_overlayVC];
- XCTAssertTrue(window.hidden);
- }
-
- - (void)testDismissOverlayShouldRemoveOverlayWindow {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- [_overlayManager dismissOverlay:_overlayVC];
- XCTAssertFalse([_overlayManager.overlayWindows containsObject:window]);
- }
-
- - (void)testDismissOverlayShouldNotRemoveWrongVC {
- [_overlayManager showOverlay:_overlayVC];
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
- [_overlayManager dismissOverlay:[UIViewController new]];
- XCTAssertTrue([_overlayManager.overlayWindows containsObject:window]);
- }
-
- @end
|