|
@@ -1,5 +1,4 @@
|
1
|
1
|
#import <XCTest/XCTest.h>
|
2
|
|
-//#import <objc/runtime.h>
|
3
|
2
|
#import "RNNStore.h"
|
4
|
3
|
#import "RNNNavigationStackManager.h"
|
5
|
4
|
|
|
@@ -13,91 +12,75 @@
|
13
|
12
|
return self.willReturnVCs;
|
14
|
13
|
}
|
15
|
14
|
|
|
15
|
+-(NSArray<UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated {
|
|
16
|
+ return self.willReturnVCs;
|
|
17
|
+}
|
|
18
|
+
|
16
|
19
|
@end
|
17
|
20
|
|
18
|
21
|
|
19
|
22
|
@interface RNNNavigationStackManagerTest : XCTestCase
|
20
|
23
|
|
|
24
|
+@property (nonatomic, strong) RNNStore *store;
|
|
25
|
+@property (nonatomic, strong) RNNNavigationStackManager *uut;
|
|
26
|
+@property (nonatomic, strong) MockUINavigationController *nvc;
|
|
27
|
+@property (nonatomic, strong) UIViewController *vc1;
|
|
28
|
+@property (nonatomic, strong) UIViewController *vc2;
|
|
29
|
+@property (nonatomic, strong) UIViewController *vc3;
|
|
30
|
+
|
21
|
31
|
@end
|
22
|
32
|
|
23
|
33
|
@implementation RNNNavigationStackManagerTest
|
24
|
34
|
|
25
|
35
|
- (void)setUp {
|
26
|
36
|
[super setUp];
|
|
37
|
+ self.store = [RNNStore new];
|
|
38
|
+ self.uut = [[RNNNavigationStackManager alloc] initWithStore:self.store];
|
|
39
|
+
|
|
40
|
+ self.nvc = [[MockUINavigationController alloc] init];
|
|
41
|
+ self.vc1 = [UIViewController new];
|
|
42
|
+ self.vc2 = [UIViewController new];
|
|
43
|
+ self.vc3 = [UIViewController new];
|
|
44
|
+ NSArray *vcArray = @[self.vc1, self.vc2, self.vc3];
|
|
45
|
+ [self.nvc setViewControllers:vcArray];
|
|
46
|
+
|
|
47
|
+ [self.store setContainer:self.vc1 containerId:@"vc1"];
|
|
48
|
+ [self.store setContainer:self.vc2 containerId:@"vc2"];
|
|
49
|
+ [self.store setContainer:self.vc3 containerId:@"vc3"];
|
|
50
|
+
|
27
|
51
|
|
28
|
52
|
}
|
29
|
53
|
|
30
|
54
|
|
31
|
|
-- (void)testPop {
|
32
|
|
- RNNStore *store = [RNNStore new];
|
33
|
|
- RNNNavigationStackManager *uut = [[RNNNavigationStackManager alloc] initWithStore:store];
|
|
55
|
+- (void)testPop_removeTopVCFromStore {
|
|
56
|
+ [self.uut pop:@"vc3"];
|
34
|
57
|
|
35
|
|
- UINavigationController *nvc = [[UINavigationController alloc] init];
|
36
|
|
-
|
37
|
|
- UIViewController *vc1 = [UIViewController new];
|
38
|
|
- UIViewController *vc2 = [UIViewController new];
|
|
58
|
+ XCTAssertNil([self.store findContainerForId:@"vc3"]);
|
|
59
|
+ XCTAssertNotNil([self.store findContainerForId:@"vc2"]);
|
|
60
|
+ XCTAssertNotNil([self.store findContainerForId:@"vc1"]);
|
|
61
|
+}
|
39
|
62
|
|
|
63
|
+- (void)testPopToSpecificVC_removeAllPopedVCFromStore {
|
|
64
|
+ self.nvc.willReturnVCs = @[self.vc2, self.vc3];
|
|
65
|
+ [self.uut popTo:@"vc1" fromContainerId:@"vc3"];
|
40
|
66
|
|
41
|
|
- NSArray *vcArray = @[vc1, vc2];
|
42
|
|
- [nvc setViewControllers:vcArray];
|
43
|
|
- [store setContainer:vc1 containerId:@"vc1"];
|
44
|
|
- [store setContainer:vc2 containerId:@"vc2"];
|
45
|
|
- [uut pop:@"vc2"];
|
46
|
|
-
|
47
|
|
- XCTAssertNil([store findContainerForId:@"vc2"]);
|
48
|
|
- XCTAssertNotNil([store findContainerForId:@"vc1"]);
|
|
67
|
+ XCTAssertNil([self.store findContainerForId:@"vc2"]);
|
|
68
|
+ XCTAssertNil([self.store findContainerForId:@"vc3"]);
|
|
69
|
+ XCTAssertNotNil([self.store findContainerForId:@"vc1"]);
|
49
|
70
|
|
50
|
71
|
}
|
51
|
72
|
|
52
|
|
-- (void)testPopTo_singleVc {
|
53
|
|
- RNNStore *store = [RNNStore new];
|
54
|
|
- RNNNavigationStackManager *uut = [[RNNNavigationStackManager alloc] initWithStore:store];
|
55
|
|
-
|
56
|
|
- UIViewController *vc1 = [UIViewController new];
|
57
|
|
- UIViewController *vc2 = [UIViewController new];
|
58
|
|
- UIViewController *vc3 = [UIViewController new];
|
59
|
|
- MockUINavigationController *nvc = [[MockUINavigationController alloc] initWithRootViewController:vc1];
|
60
|
|
- [nvc pushViewController:vc2 animated:NO];
|
61
|
|
- [nvc pushViewController:vc3 animated:NO];
|
62
|
|
- nvc.willReturnVCs = @[vc2, vc3];
|
63
|
|
-
|
64
|
|
- [store setContainer:vc1 containerId:@"vc1"];
|
65
|
|
- [store setContainer:vc2 containerId:@"vc2"];
|
66
|
|
- [store setContainer:vc3 containerId:@"vc3"];
|
67
|
|
- [uut popTo:@"vc1" fromContainerId:@"vc3"];
|
68
|
|
-
|
69
|
|
- XCTAssertNil([store findContainerForId:@"vc2"]);
|
70
|
|
- XCTAssertNotNil([store findContainerForId:@"vc1"]);
|
|
73
|
+- (void)testPopToRoot_removeAllTopVCsFromStore {
|
|
74
|
+ self.nvc.willReturnVCs = @[self.vc2, self.vc3];
|
|
75
|
+ [self.uut popToRoot:@"vc3"];
|
71
|
76
|
|
|
77
|
+ XCTAssertNil([self.store findContainerForId:@"vc2"]);
|
|
78
|
+ XCTAssertNil([self.store findContainerForId:@"vc3"]);
|
|
79
|
+ XCTAssertNotNil([self.store findContainerForId:@"vc1"]);
|
|
80
|
+
|
72
|
81
|
}
|
73
|
82
|
|
74
|
83
|
|
75
|
|
-//- (void)testPopTo {
|
76
|
|
-// RNNStore *store = [RNNStore new];
|
77
|
|
-// RNNNavigationStackManager *uut = [[RNNNavigationStackManager alloc] initWithStore:store];
|
78
|
|
-//
|
79
|
|
-// UINavigationController *nvc = [[UINavigationController alloc] init];
|
80
|
|
-//
|
81
|
|
-// UIViewController *vc1 = [UIViewController new];
|
82
|
|
-// UIViewController *vc2 = [UIViewController new];
|
83
|
|
-// UIViewController *vc3 = [UIViewController new];
|
84
|
|
-// UIViewController *vc4 = [UIViewController new];
|
85
|
|
-//
|
86
|
|
-// NSArray *vcArray = @[vc1, vc2, vc3, vc4];
|
87
|
|
-// [nvc setViewControllers:vcArray];
|
88
|
|
-// [store setContainer:vc1 containerId:@"vc1"];
|
89
|
|
-// [store setContainer:vc2 containerId:@"vc2"];
|
90
|
|
-// [store setContainer:vc3 containerId:@"vc3"];
|
91
|
|
-// [store setContainer:vc4 containerId:@"vc4"];
|
92
|
|
-// [store setContainer:nvc containerId:@"nvc"];
|
93
|
|
-//
|
94
|
|
-// [uut popTo:@"vc1" fromContainerId:@"vc4"];
|
95
|
|
-//
|
96
|
|
-// XCTAssertNil([store findContainerForId:@"vc4"]);
|
97
|
|
-// XCTAssertNil([store findContainerForId:@"vc3"]);
|
98
|
|
-// XCTAssertNil([store findContainerForId:@"vc2"]);
|
99
|
|
-//
|
100
|
|
-//}
|
101
|
84
|
|
102
|
85
|
|
103
|
86
|
@end
|