@@ -11,18 +11,17 @@ class QuickSeekMediaControlPluginTests: QuickSpec {
11
11
var core : CoreStub !
12
12
var mediaControl : MediaControl !
13
13
var playButton : PlayButton !
14
+ var overlayPlugin : OverlayPlugin !
14
15
15
16
beforeEach {
16
17
Loader . shared. resetPlugins ( )
17
18
core = CoreStub ( )
18
19
core. playbackMock? . videoDuration = 60.0
19
20
quickSeekPlugin = QuickSeekMediaControlPlugin ( context: core)
20
21
mediaControl = MediaControl ( context: core)
21
- playButton = PlayButton ( context: core)
22
22
23
23
core. addPlugin ( mediaControl)
24
24
core. addPlugin ( quickSeekPlugin)
25
- core. addPlugin ( playButton)
26
25
27
26
core. view. frame = CGRect ( x: 0 , y: 0 , width: 320 , height: 200 )
28
27
@@ -68,14 +67,64 @@ class QuickSeekMediaControlPluginTests: QuickSpec {
68
67
}
69
68
}
70
69
71
- context ( " and it colides with another UICorePlugin " ) {
72
- it ( " does not seek " ) {
70
+ describe ( " and there is another UICorePlugin " ) {
71
+ beforeEach {
72
+ playButton = PlayButton ( context: core)
73
+
74
+ core. addPlugin ( playButton)
75
+ core. render ( )
76
+
77
+ mediaControl. render ( )
73
78
playButton. view. layoutIfNeeded ( )
74
79
mediaControl. view. layoutIfNeeded ( )
75
80
76
- let shouldSeek = quickSeekPlugin. shouldSeek ( point: CGPoint ( x: 100 , y: 100 ) )
81
+ }
82
+
83
+ context ( " and it collides with that plugin " ) {
84
+ it ( " does not seek " ) {
85
+ let playButtonCenterInMediaControlCoordinate = playButton. view. convert ( playButton. view. center, to: mediaControl. mediaControlView)
86
+
87
+ let shouldSeek = quickSeekPlugin. shouldSeek ( point: playButtonCenterInMediaControlCoordinate)
88
+
89
+ expect ( shouldSeek) . to ( beFalse ( ) )
90
+ }
91
+ }
92
+
93
+ context ( " and it does not collide with that plugin " ) {
94
+ it ( " does seek " ) {
95
+ let pointOutsidePlayButton = CGPoint ( x: playButton. view. frame. width + 1 , y: playButton. view. frame. height + 1 )
96
+ let outsidePointInMediaControlCoordinate = playButton. view. convert ( pointOutsidePlayButton, to: mediaControl. mediaControlView)
97
+
98
+ let shouldSeek = quickSeekPlugin. shouldSeek ( point: outsidePointInMediaControlCoordinate)
99
+
100
+ expect ( shouldSeek) . to ( beTrue ( ) )
101
+ }
102
+ }
103
+
104
+ context ( " and that plugin is not visible " ) {
105
+ it ( " does seek " ) {
106
+ let playButtonCenterInMediaControlCoordinate = playButton. view. convert ( playButton. view. center, to: mediaControl. mediaControlView)
107
+ playButton. view. alpha = 0.0
108
+
109
+ let shouldSeek = quickSeekPlugin. shouldSeek ( point: playButtonCenterInMediaControlCoordinate)
110
+
111
+ expect ( shouldSeek) . to ( beTrue ( ) )
112
+ }
113
+ }
114
+ }
115
+
116
+ context ( " and there are not visible overlay plugins " ) {
117
+ it ( " ignores them and seeks " ) {
118
+ overlayPlugin = OverlayPluginStub ( context: core)
119
+ core. addPlugin ( overlayPlugin)
120
+ core. render ( )
121
+ overlayPlugin. render ( )
122
+ overlayPlugin. view. layoutIfNeeded ( )
123
+ let overlayPluginCenterInMediaControlCoordinate = overlayPlugin. view. convert ( overlayPlugin. view. center, to: mediaControl. mediaControlView)
124
+
125
+ let shouldSeek = quickSeekPlugin. shouldSeek ( point: overlayPluginCenterInMediaControlCoordinate)
77
126
78
- expect ( shouldSeek) . to ( beFalse ( ) )
127
+ expect ( shouldSeek) . to ( beTrue ( ) )
79
128
}
80
129
}
81
130
@@ -138,3 +187,19 @@ class QuickSeekMediaControlPluginTests: QuickSpec {
138
187
}
139
188
}
140
189
}
190
+
191
+ class OverlayPluginStub : OverlayPlugin {
192
+ override var isModal : Bool {
193
+ true
194
+ }
195
+
196
+ override class var name : String {
197
+ " OverlayPluginStub "
198
+ }
199
+
200
+ override func bindEvents( ) { }
201
+
202
+ override func render( ) {
203
+ view. backgroundColor = . red
204
+ }
205
+ }
0 commit comments