|
@@ -1,10 +1,12 @@
|
1
|
1
|
#import <XCTest/XCTest.h>
|
|
2
|
+#import <OCMock/OCMock.h>
|
2
|
3
|
#import "RNNOverlayManager.h"
|
3
|
4
|
|
4
|
5
|
@interface RNNOverlayManagerTest : XCTestCase
|
5
|
6
|
|
6
|
7
|
@property (nonatomic, retain) RNNOverlayManager* overlayManager;
|
7
|
8
|
@property (nonatomic, retain) UIViewController* overlayVC;
|
|
9
|
+@property (nonatomic, retain) RNNOverlayWindow* overlayWindow;
|
8
|
10
|
|
9
|
11
|
@end
|
10
|
12
|
|
|
@@ -14,57 +16,54 @@
|
14
|
16
|
[super setUp];
|
15
|
17
|
_overlayManager = [RNNOverlayManager new];
|
16
|
18
|
_overlayVC = [UIViewController new];
|
|
19
|
+ _overlayWindow = [OCMockObject partialMockForObject:[RNNOverlayWindow new]];
|
|
20
|
+ OCMStub([_overlayWindow makeKeyAndVisible]);
|
|
21
|
+ _overlayWindow.rootViewController = _overlayVC;
|
17
|
22
|
}
|
18
|
23
|
|
19
|
24
|
|
20
|
25
|
- (void)testShowOverlayShouldAddWindowWithVCAsRoot {
|
21
|
|
- [_overlayManager showOverlay:_overlayVC];
|
|
26
|
+ [_overlayManager showOverlayWindow:_overlayWindow];
|
22
|
27
|
UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
23
|
28
|
XCTAssertTrue([window.rootViewController isEqual:_overlayVC]);
|
24
|
29
|
}
|
25
|
30
|
|
26
|
|
-- (void)testShowOverlayShouldAddVisibleWindow {
|
27
|
|
- [_overlayManager showOverlay:_overlayVC];
|
28
|
|
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
29
|
|
- XCTAssertTrue(window.windowLevel == UIWindowLevelNormal);
|
30
|
|
- XCTAssertFalse(window.hidden);
|
|
31
|
+- (void)testShowOverlayShouldSetKeyAndVisibleWindow {
|
|
32
|
+ id window = _overlayManager.overlayWindows.lastObject;
|
|
33
|
+ [[window expect] makeKeyAndVisible];
|
|
34
|
+ [_overlayManager showOverlayWindow:_overlayWindow];
|
|
35
|
+ [window verify];
|
31
|
36
|
}
|
32
|
37
|
|
33
|
38
|
- (void)testShowOverlayShouldCreateTransparentView {
|
34
|
|
- [_overlayManager showOverlay:_overlayVC];
|
|
39
|
+ [_overlayManager showOverlayWindow:_overlayWindow];
|
35
|
40
|
UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
36
|
41
|
XCTAssertTrue(window.rootViewController.view.backgroundColor == [UIColor clearColor]);
|
37
|
42
|
}
|
38
|
43
|
|
39
|
|
-- (void)testShowOverlayShouldNotBeKeyWindow {
|
40
|
|
- [_overlayManager showOverlay:_overlayVC];
|
41
|
|
- UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
42
|
|
- XCTAssertFalse(window.keyWindow);
|
43
|
|
-}
|
44
|
|
-
|
45
|
44
|
- (void)testDismissOverlayShouldCleanWindowRootVC {
|
46
|
|
- [_overlayManager showOverlay:_overlayVC];
|
|
45
|
+ [_overlayManager showOverlayWindow:_overlayWindow];
|
47
|
46
|
UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
48
|
47
|
[_overlayManager dismissOverlay:_overlayVC];
|
49
|
48
|
XCTAssertNil(window.rootViewController);
|
50
|
49
|
}
|
51
|
50
|
|
52
|
51
|
- (void)testDismissOverlayShouldHideWindow {
|
53
|
|
- [_overlayManager showOverlay:_overlayVC];
|
|
52
|
+ [_overlayManager showOverlayWindow:_overlayWindow];
|
54
|
53
|
UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
55
|
54
|
[_overlayManager dismissOverlay:_overlayVC];
|
56
|
55
|
XCTAssertTrue(window.hidden);
|
57
|
56
|
}
|
58
|
57
|
|
59
|
58
|
- (void)testDismissOverlayShouldRemoveOverlayWindow {
|
60
|
|
- [_overlayManager showOverlay:_overlayVC];
|
|
59
|
+ [_overlayManager showOverlayWindow:_overlayWindow];
|
61
|
60
|
UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
62
|
61
|
[_overlayManager dismissOverlay:_overlayVC];
|
63
|
62
|
XCTAssertFalse([_overlayManager.overlayWindows containsObject:window]);
|
64
|
63
|
}
|
65
|
64
|
|
66
|
65
|
- (void)testDismissOverlayShouldNotRemoveWrongVC {
|
67
|
|
- [_overlayManager showOverlay:_overlayVC];
|
|
66
|
+ [_overlayManager showOverlayWindow:_overlayWindow];
|
68
|
67
|
UIWindow* window = _overlayManager.overlayWindows.lastObject;
|
69
|
68
|
[_overlayManager dismissOverlay:[UIViewController new]];
|
70
|
69
|
XCTAssertTrue([_overlayManager.overlayWindows containsObject:window]);
|