|
14 | 14 | setup: function(){
|
15 | 15 |
|
16 | 16 | // ensure bindings are removed
|
17 |
| - $.each(events, function(i, name){ |
18 |
| - $.each([$("#qunit-fixture"), |
19 |
| - $($.event.special.scrollstart), |
20 |
| - $($.event.special.tap), |
21 |
| - $($.event.special.tap), |
22 |
| - $($.event.special.swipe)], function(j, obj){ |
23 |
| - obj.unbind(name); |
24 |
| - }); |
| 17 | + $.each(events + "vmouseup vmousedown".split(" "), function(i, name){ |
| 18 | + $("#qunit-fixture").unbind(); |
25 | 19 | });
|
26 | 20 |
|
27 | 21 | //NOTE unmock
|
28 | 22 | Math.abs = absFn;
|
29 | 23 | $.Event.prototype.originalEvent = originalEventFn;
|
30 | 24 | $.Event.prototype.preventDefault = preventDefaultFn;
|
| 25 | + $.Event.prototype.touches = [{pageX: 1, pageY: 1 }]; |
31 | 26 |
|
32 | 27 | $($.mobile.pageContainer).unbind( "throttledresize" );
|
33 | 28 | }
|
|
43 | 38 | $.testHelper.reloadLib(libName);
|
44 | 39 |
|
45 | 40 | $.each(events, function( i, name ) {
|
46 |
| - ok($.fn[name] !== undefined, name + "is not undefined"); |
| 41 | + ok($.fn[name] !== undefined, name + " is not undefined"); |
47 | 42 | });
|
48 | 43 | });
|
49 | 44 | });
|
|
88 | 83 | expect( 1 );
|
89 | 84 | $.event.special.scrollstart.enabled = false;
|
90 | 85 |
|
91 |
| - $($.event.special.scrollstart).bind("scrollstart", function(){ |
| 86 | + $( "#qunit-fixture" ).bind("scrollstart", function(){ |
92 | 87 | ok(false, "scrollstart fired");
|
93 | 88 | });
|
94 | 89 |
|
95 |
| - $($.event.special.scrollstart).bind("touchmove", function(){ |
| 90 | + $( "#qunit-fixture" ).bind("touchmove", function(){ |
96 | 91 | ok(true, "touchmove fired");
|
97 | 92 | start();
|
98 | 93 | });
|
99 | 94 |
|
100 |
| - $($.event.special.scrollstart).trigger("touchmove"); |
| 95 | + $( "#qunit-fixture" ).trigger("touchmove"); |
101 | 96 | });
|
102 | 97 |
|
103 | 98 | asyncTest( "scrollstart setup binds a function that triggers scroll start when enabled", function(){
|
104 | 99 | $.event.special.scrollstart.enabled = true;
|
105 | 100 |
|
106 |
| - $($.event.special.scrollstart).bind("scrollstart", function(){ |
| 101 | + $( "#qunit-fixture" ).bind("scrollstart", function(){ |
107 | 102 | ok(true, "scrollstart fired");
|
108 | 103 | start();
|
109 | 104 | });
|
110 | 105 |
|
111 |
| - $($.event.special.scrollstart).trigger("touchmove"); |
| 106 | + $( "#qunit-fixture" ).trigger("touchmove"); |
112 | 107 | });
|
113 | 108 |
|
114 | 109 | asyncTest( "scrollstart setup binds a function that triggers scroll stop after 50 ms", function(){
|
115 | 110 | var triggered = false;
|
116 | 111 | $.event.special.scrollstart.enabled = true;
|
117 | 112 |
|
118 |
| - $($.event.special.scrollstart).bind("scrollstop", function(){ |
| 113 | + $( "#qunit-fixture" ).bind("scrollstop", function(){ |
119 | 114 | triggered = true;
|
120 | 115 | });
|
121 | 116 |
|
122 | 117 | ok(!triggered, "not triggered");
|
123 | 118 |
|
124 |
| - $($.event.special.scrollstart).trigger("touchmove"); |
| 119 | + $( "#qunit-fixture" ).trigger("touchmove"); |
125 | 120 |
|
126 | 121 | setTimeout(function(){
|
127 | 122 | ok(triggered, "triggered");
|
|
144 | 139 |
|
145 | 140 | forceTouchSupport();
|
146 | 141 |
|
147 |
| - $($.event.special.tap).bind("taphold", function(){ |
| 142 | + $( "#qunit-fixture" ).bind("taphold", function(){ |
148 | 143 | taphold = true;
|
149 | 144 | });
|
150 | 145 |
|
151 |
| - $($.event.special.tap).trigger("vmousedown"); |
| 146 | + $( "#qunit-fixture" ).trigger("vmousedown"); |
152 | 147 |
|
153 | 148 | setTimeout(function(){
|
154 | 149 | ok(taphold);
|
|
172 | 167 | mockAbs(100);
|
173 | 168 |
|
174 | 169 | //NOTE record taphold event
|
175 |
| - $($.event.special.tap).bind("taphold", function(){ |
| 170 | + $( "#qunit-fixture" ).bind("taphold", function(){ |
176 | 171 | ok(false, "taphold fired");
|
177 | 172 | taphold = true;
|
178 | 173 | });
|
179 | 174 |
|
180 | 175 | //NOTE start the touch events
|
181 |
| - $($.event.special.tap).trigger("vmousedown"); |
| 176 | + $( "#qunit-fixture" ).trigger("vmousedown"); |
182 | 177 |
|
183 | 178 | //NOTE fire touchmove to push back taphold
|
184 | 179 | setTimeout(function(){
|
185 |
| - $($.event.special.tap).trigger("vmousecancel"); |
| 180 | + $( "#qunit-fixture" ).trigger("vmousecancel"); |
186 | 181 | }, 100);
|
187 | 182 |
|
188 | 183 | //NOTE verify that the taphold hasn't been fired
|
|
203 | 198 | forceTouchSupport();
|
204 | 199 |
|
205 | 200 | //NOTE record the tap event
|
206 |
| - $($.event.special.tap).bind("tap", checkTap); |
| 201 | + $( "#qunit-fixture" ).bind("tap", checkTap); |
207 | 202 |
|
208 |
| - $($.event.special.tap).trigger("vmousedown"); |
209 |
| - $($.event.special.tap).trigger("vmouseup"); |
210 |
| - $($.event.special.tap).trigger("vclick"); |
| 203 | + $( "#qunit-fixture" ).trigger("vmousedown"); |
| 204 | + $( "#qunit-fixture" ).trigger("vmouseup"); |
| 205 | + $( "#qunit-fixture" ).trigger("vclick"); |
211 | 206 |
|
212 | 207 | setTimeout(function(){
|
213 | 208 | start();
|
|
220 | 215 | forceTouchSupport();
|
221 | 216 |
|
222 | 217 | //NOTE record tap event
|
223 |
| - $($.event.special.tap).bind("tap", function(){ |
| 218 | + $( "#qunit-fixture" ).bind("tap", function(){ |
224 | 219 | ok(false, "tap fired");
|
225 | 220 | tap = true;
|
226 | 221 | });
|
|
229 | 224 | mockAbs(100);
|
230 | 225 |
|
231 | 226 | //NOTE start and move right away
|
232 |
| - $($.event.special.tap).trigger("touchstart"); |
233 |
| - $($.event.special.tap).trigger("touchmove"); |
| 227 | + $( "#qunit-fixture" ).trigger("touchstart"); |
| 228 | + $( "#qunit-fixture" ).trigger("touchmove"); |
234 | 229 |
|
235 | 230 | //NOTE end touch sequence after 20 ms
|
236 | 231 | setTimeout(function(){
|
237 |
| - $($.event.special.tap).trigger("touchend"); |
| 232 | + $( "#qunit-fixture" ).trigger("touchend"); |
238 | 233 | }, 20);
|
239 | 234 |
|
240 | 235 | setTimeout(function(){
|
|
248 | 243 |
|
249 | 244 | forceTouchSupport();
|
250 | 245 |
|
251 |
| - $($.event.special.swipe).bind('swipe', function(){ |
| 246 | + $( "#qunit-fixture" ).bind('swipe', function(){ |
252 | 247 | swipe = true;
|
253 | 248 | });
|
254 | 249 |
|
|
257 | 252 | touches: false
|
258 | 253 | };
|
259 | 254 |
|
260 |
| - $($.event.special.swipe).trigger("touchstart"); |
| 255 | + $( "#qunit-fixture" ).trigger("touchstart"); |
261 | 256 |
|
262 | 257 | //NOTE make sure the coordinates are calculated within range
|
263 | 258 | // to be registered as a swipe
|
264 | 259 | mockAbs(opts.coordChange);
|
265 | 260 |
|
266 | 261 | setTimeout(function(){
|
267 |
| - $($.event.special.swipe).trigger("touchmove"); |
268 |
| - $($.event.special.swipe).trigger("touchend"); |
| 262 | + $( "#qunit-fixture" ).trigger("touchmove"); |
| 263 | + $( "#qunit-fixture" ).trigger("touchend"); |
269 | 264 | }, opts.timeout + 100);
|
270 | 265 |
|
271 | 266 | setTimeout(function(){
|
|
298 | 293 | forceTouchSupport();
|
299 | 294 |
|
300 | 295 | // ensure the swipe custome event is setup
|
301 |
| - $($.event.special.swipe).bind('swipe', function(){}); |
| 296 | + $( "#qunit-fixture" ).bind('swipe', function(){}); |
302 | 297 |
|
303 | 298 | //NOTE bypass the trigger source check
|
304 | 299 | $.Event.prototype.originalEvent = {
|
|
312 | 307 |
|
313 | 308 | mockAbs(11);
|
314 | 309 |
|
315 |
| - $($.event.special.swipe).trigger("touchstart"); |
316 |
| - $($.event.special.swipe).trigger("touchmove"); |
| 310 | + $( "#qunit-fixture" ).trigger("touchstart"); |
| 311 | + $( "#qunit-fixture" ).trigger("touchmove"); |
317 | 312 | });
|
318 | 313 |
|
319 | 314 | asyncTest( "move handler returns when touchstart has been fired since touchstop", function(){
|
|
327 | 322 | forceTouchSupport();
|
328 | 323 |
|
329 | 324 | // ensure the swipe custome event is setup
|
330 |
| - $($.event.special.swipe).bind('swipe', function(){}); |
| 325 | + $( "#qunit-fixture" ).bind('swipe', function(){}); |
331 | 326 |
|
332 |
| - $($.event.special.swipe).trigger("touchstart"); |
333 |
| - $($.event.special.swipe).trigger("touchend"); |
| 327 | + $( "#qunit-fixture" ).trigger("touchstart"); |
| 328 | + $( "#qunit-fixture" ).trigger("touchend"); |
334 | 329 |
|
335 |
| - $($.event.special.swipe).bind("touchmove", function(){ |
| 330 | + $( "#qunit-fixture" ).bind("touchmove", function(){ |
336 | 331 | ok(true, "touchmove bound functions are fired");
|
337 | 332 | start();
|
338 | 333 | });
|
|
341 | 336 | ok(false, "shouldn't compare coordinates");
|
342 | 337 | };
|
343 | 338 |
|
344 |
| - $($.event.special.swipe).trigger("touchmove"); |
| 339 | + $( "#qunit-fixture" ).trigger("touchmove"); |
345 | 340 | });
|
346 | 341 |
|
347 | 342 | var nativeSupportTest = function(opts){
|
|
0 commit comments