marshroute

Форк
0
/
PeekAndPopUtilityImplTests_invokesPopAction.swift 
255 строк · 7.5 Кб
1
import XCTest
2
@testable import Marshroute
3

4
final class PeekAndPopUtilityImplTests_invokesPopAction: BasePeekAndPopUtilityImplTestCase {    
5
    func testPeekAndPopUtility_invokesPopAction_ifSomeTransitionOccursNotDuringActivePeek() {
6
        // Given
7
        let expectation = self.expectation()
8
        
9
        bindSourceViewControllerToWindow()
10
        
11
        registerSourceViewControllerForPreviewing()
12
        
13
        // When
14
        invokeTransitionToPeekViewController(
15
            popAction: {
16
                expectation.fulfill()    
17
            }
18
        )
19
        
20
        // Then
21
        waitForExpectations(timeout: asyncTimeout)
22
    }
23
    
24
    func testPeekAndPopUtility_invokesPopAction_ifPeekBeginsOnOffscreenRegisteredViewControllerAndSomeTransitionOccurs() {
25
        // Given
26
        let expectation = self.expectation()
27
        
28
        unbindSourceViewControllerFromWindow()
29
        
30
        registerSourceViewControllerForPreviewing()
31
        
32
        // When
33
        beginPeekOnRegisteredViewController()
34
        
35
        invokeTransitionToPeekViewController(
36
            popAction: {
37
                expectation.fulfill()    
38
            }
39
        )
40
        
41
        // Then
42
        waitForExpectations(timeout: asyncTimeout)
43
    }
44
    
45
    func testPeekAndPopUtility_invokesPopAction_ifPeekGetsCommitedOnOnscreenRegisteredViewController() {
46
        // Given
47
        let expectation = self.expectation()
48
        
49
        bindSourceViewControllerToWindow()
50
        
51
        registerSourceViewControllerForPreviewing(
52
            onPeek: { _ in
53
                self.invokeTransitionToPeekViewController(
54
                    popAction: {
55
                        expectation.fulfill()
56
                    }
57
                )
58
            }
59
        )
60
        
61
        // When
62
        beginPeekOnRegisteredViewController()
63
        
64
        commitPickOnRegisteredViewController()
65
        
66
        // Then
67
        waitForExpectations(timeout: asyncTimeout)
68
    }
69
    
70
    func testPeekAndPopUtility_invokesPopAction_ifSamePeekFailedToBeginAndNewPeekGetsCommitedOnOnscreenRegisteredViewController() {
71
        // Given
72
        let expectation = self.expectation()
73
        
74
        bindSourceViewControllerToWindow()
75
        bindSourceViewController2ToWindow()
76
        
77
        registerSourceViewControllerForPreviewing()
78
        
79
        registerSourceViewController2ForPreviewing(
80
            onPeek: { _ in
81
                self.invokeTransitionToPeekViewController(
82
                    popAction: {
83
                        expectation.fulfill()
84
                    }
85
                )
86
            }
87
        )
88
        
89
        // When
90
        beginPeekOnRegisteredViewController()
91
        
92
        beginPeekOnRegisteredViewController2()
93
        
94
        commitPickOnRegisteredViewController2()
95
        
96
        // Then
97
        waitForExpectations(timeout: asyncTimeout)
98
    }
99
    
100
    func testPeekAndPopUtility_invokesNoPopAction_ifPeekBeginsOnOnscreenRegisteredViewController() {
101
        // Given
102
        let invertedExpectation = self.invertedExpectation()
103
        
104
        bindSourceViewControllerToWindow()
105
        
106
        registerSourceViewControllerForPreviewing(
107
            onPeek: { _ in
108
                self.invokeTransitionToPeekViewController(
109
                    popAction: {
110
                        invertedExpectation.fulfill()
111
                    }
112
                )
113
            }
114
        )
115
        
116
        // When
117
        beginPeekOnRegisteredViewController()
118
        
119
        // Then
120
        waitForExpectations(timeout: asyncTimeout)
121
    }
122
    
123
    func testPeekAndPopUtility_invokesNoPopAction_ifPeekBeginsOnOnscreenRegisteredViewControllerWithNotNavigationParentViewController() {
124
        // Given
125
        let invertedExpectation = self.invertedExpectation()
126
        
127
        bindSourceViewControllerToWindow()
128
        
129
        bindPeekViewControllerToAnotherParent()
130
        
131
        registerSourceViewControllerForPreviewing(
132
            onPeek: { _ in
133
                self.invokeTransitionToPeekViewController(
134
                    popAction: {
135
                        invertedExpectation.fulfill()
136
                    }
137
                )
138
            }
139
        )
140
        
141
        // When
142
        beginPeekOnRegisteredViewController()
143
        
144
        // Then
145
        waitForExpectations(timeout: asyncTimeout)
146
    }
147
    
148
    func testPeekAndPopUtility_invokesNoPopAction_ifPeekGetsCommitedOnOnscreenRegisteredViewControllerWithNotPeekViewController() {
149
        // Given
150
        let invertedExpectation = self.invertedExpectation()
151
        
152
        bindSourceViewControllerToWindow()
153
        
154
        registerSourceViewControllerForPreviewing(
155
            onPeek: { _ in
156
                self.invokeTransitionToPeekViewController(
157
                    popAction: {
158
                        invertedExpectation.fulfill()
159
                    }
160
                )
161
            }
162
        )
163
        
164
        // When
165
        beginPeekOnRegisteredViewController()
166
        
167
        commitPickOnRegisteredViewControllerToNotPeekViewController()
168
        
169
        // Then
170
        waitForExpectations(timeout: asyncTimeout)
171
    }
172
    
173
    func testPeekAndPopUtility_invokesNoPopAction_ifPeekGetsInterruptedWithAnotherTransitionOnOnscreenRegisteredViewController() {
174
        // Given
175
        let invertedExpectation = self.invertedExpectation()
176
        
177
        bindSourceViewControllerToWindow()
178
        
179
        registerSourceViewControllerForPreviewing(
180
            onPeek: { _ in
181
                self.invokeTransitionToPeekViewController(
182
                    popAction: {
183
                        invertedExpectation.fulfill()
184
                    }
185
                )
186
            }
187
        )
188
        
189
        // When
190
        beginPeekOnRegisteredViewController()
191
        
192
        interruptPeekWithAnotherTransitionOnRegisteredViewController()
193
        
194
        // Then
195
        waitForExpectations(timeout: asyncTimeout)
196
    }
197
    
198
    func testPeekAndPopUtility_invokesNoPopAction_ifSamePeekIsAlreadyBeganAndNewPeekBeginsOnOnscreenRegisteredViewController() {
199
        // Given
200
        let invertedExpectation = self.invertedExpectation()
201
        
202
        bindSourceViewControllerToWindow()
203
        
204
        bindSourceViewController2ToWindow()
205
        
206
        registerSourceViewControllerForPreviewing(
207
            onPeek: { _ in
208
                self.invokeTransitionToPeekViewController()
209
            }
210
        )
211
        
212
        registerSourceViewController2ForPreviewing(
213
            onPeek: { _ in
214
                invertedExpectation.fulfill()
215
            }
216
        )
217
        
218
        // When
219
        beginPeekOnRegisteredViewController()
220
        
221
        beginPeekOnRegisteredViewController2()
222
        
223
        // Then
224
        waitForExpectations(timeout: asyncTimeout)
225
    }
226
    
227
    func testPeekAndPopUtility_invokesNoPopAction_ifSamePeekFailedToBeginAndNewPeekBeginsOnOnscreenRegisteredViewController() {
228
        // Given
229
        let invertedExpectation = self.invertedExpectation()
230
        
231
        bindSourceViewControllerToWindow()
232
        
233
        bindSourceViewController2ToWindow()
234
        
235
        registerSourceViewControllerForPreviewing()
236
        
237
        registerSourceViewController2ForPreviewing(
238
            onPeek: { _ in
239
                self.invokeTransitionToPeekViewController(
240
                    popAction: {
241
                        invertedExpectation.fulfill()
242
                    }
243
                )
244
            }
245
        )
246
        
247
        // When
248
        beginPeekOnRegisteredViewController()
249
        
250
        beginPeekOnRegisteredViewController2()
251
        
252
        // Then
253
        waitForExpectations(timeout: asyncTimeout)
254
    }
255
}    
256

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.