Browse Source

Overlay unit tests

yogevbd 6 years ago
parent
commit
963fb5c42d

+ 2
- 0
lib/ios/RNNOverlayManager.h View File

@@ -8,4 +8,6 @@
8 8
 - (void)showOverlay:(UIViewController*)viewController;
9 9
 - (void)dismissOverlay:(UIViewController*)viewController;
10 10
 
11
+@property (nonatomic, retain) NSMutableArray* overlayWindows;
12
+
11 13
 @end

+ 1
- 3
lib/ios/RNNOverlayManager.m View File

@@ -1,9 +1,7 @@
1 1
 #import "RNNOverlayManager.h"
2 2
 #import "RNNOverlayWindow.h"
3 3
 
4
-@implementation RNNOverlayManager {
5
-	NSMutableArray* _overlayWindows;
6
-}
4
+@implementation RNNOverlayManager
7 5
 
8 6
 - (instancetype)init {
9 7
 	self = [super init];

+ 4
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

@@ -78,6 +78,7 @@
78 78
 		50451D0A2042E20600695F00 /* RNNTransitionsOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50451D082042E20600695F00 /* RNNTransitionsOptions.m */; };
79 79
 		50451D0D2042F70900695F00 /* RNNTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 50451D0B2042F70900695F00 /* RNNTransition.h */; };
80 80
 		50451D0E2042F70900695F00 /* RNNTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 50451D0C2042F70900695F00 /* RNNTransition.m */; };
81
+		504753782109C13C00FFFBE6 /* RNNOverlayManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 504753772109C13C00FFFBE6 /* RNNOverlayManagerTest.m */; };
81 82
 		5048862D20BE976D000908DE /* RNNLayoutOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5048862B20BE976D000908DE /* RNNLayoutOptions.h */; };
82 83
 		5048862E20BE976D000908DE /* RNNLayoutOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5048862C20BE976D000908DE /* RNNLayoutOptions.m */; };
83 84
 		504AFE651FFE53070076E904 /* RNNOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 504AFE631FFE53070076E904 /* RNNOptions.m */; };
@@ -301,6 +302,7 @@
301 302
 		50451D082042E20600695F00 /* RNNTransitionsOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTransitionsOptions.m; sourceTree = "<group>"; };
302 303
 		50451D0B2042F70900695F00 /* RNNTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTransition.h; sourceTree = "<group>"; };
303 304
 		50451D0C2042F70900695F00 /* RNNTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTransition.m; sourceTree = "<group>"; };
305
+		504753772109C13C00FFFBE6 /* RNNOverlayManagerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayManagerTest.m; sourceTree = "<group>"; };
304 306
 		5048862B20BE976D000908DE /* RNNLayoutOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNLayoutOptions.h; sourceTree = "<group>"; };
305 307
 		5048862C20BE976D000908DE /* RNNLayoutOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNLayoutOptions.m; sourceTree = "<group>"; };
306 308
 		504AFE621FFE53070076E904 /* RNNOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNOptions.h; sourceTree = "<group>"; };
@@ -685,6 +687,7 @@
685 687
 				7B49FEC81E95098500DEB3EA /* RNNModalManagerTest.m */,
686 688
 				7B49FEC91E95098500DEB3EA /* RNNCommandsHandlerTest.m */,
687 689
 				7B49FECA1E95098500DEB3EA /* RNNNavigationStackManagerTest.m */,
690
+				504753772109C13C00FFFBE6 /* RNNOverlayManagerTest.m */,
688 691
 				7B49FEBF1E95090800DEB3EA /* Info.plist */,
689 692
 				E83BAD671F2734B500A9F3DD /* RNNNavigationOptionsTest.m */,
690 693
 				E83BAD781F27416B00A9F3DD /* RNNRootViewControllerTest.m */,
@@ -992,6 +995,7 @@
992 995
 			buildActionMask = 2147483647;
993 996
 			files = (
994 997
 				E83BAD7C1F27643000A9F3DD /* RNNTestRootViewCreator.m in Sources */,
998
+				504753782109C13C00FFFBE6 /* RNNOverlayManagerTest.m in Sources */,
995 999
 				7B49FECE1E95098500DEB3EA /* RNNCommandsHandlerTest.m in Sources */,
996 1000
 				E83BAD681F2734B500A9F3DD /* RNNNavigationOptionsTest.m in Sources */,
997 1001
 				7B49FECF1E95098500DEB3EA /* RNNNavigationStackManagerTest.m in Sources */,

+ 54
- 0
lib/ios/ReactNativeNavigationTests/RNNOverlayManagerTest.m View File

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