~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/tests/event-simulate/tests/event-simulate.html

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<html>
2
 
<head>
3
 
<title>event-simulate tests</title>
4
 
<link type="text/css" rel="stylesheet" href="../../../build/logreader/assets/skins/sam/logreader.css" />
5
 
<script type="text/javascript" src="../../../build/yui/yui.js"></script>
6
 
</head>
7
 
<body class="yui3-skin-sam">
8
 
    <h1>Event-Simulate Tests</h1>
9
 
    <div id="c"></div>
10
 
<script type="text/javascript">  
11
 
    
12
 
YUI({
13
 
    filter: "debug",
14
 
    logInclude: { TestRunner: 1}
15
 
}).use('test', 'event-simulate', 'console', function (Y) {
16
 
 
17
 
    Y.namespace("Tests");
18
 
    
19
 
    Y.Tests.EventSimulate = (function(){
20
 
    
21
 
        var Assert          = Y.Assert,
22
 
            ObjectAssert    = Y.ObjectAssert;
23
 
        
24
 
        
25
 
        //-------------------------------------------------------------------------
26
 
        // Generic Event Test Case
27
 
        //-------------------------------------------------------------------------
28
 
        function GenericEventTestCase(type /*:String*/){
29
 
            GenericEventTestCase.superclass.constructor.call(this);
30
 
            this.eventType = type;
31
 
            this.name = "Event '" + type + "' Tests";
32
 
            this.result = null;
33
 
            this.element = null;
34
 
            this.elementTagName = "div";
35
 
        }
36
 
    
37
 
        Y.extend(GenericEventTestCase, Y.Test.Case, {
38
 
        
39
 
            //---------------------------------------------------------------------
40
 
            // Setup and teardown of test harnesses
41
 
            //---------------------------------------------------------------------
42
 
            
43
 
            /*
44
 
             * Sets up several event handlers used to test UserAction mouse events.
45
 
             */
46
 
            setUp : function() /*:Void*/{
47
 
            
48
 
                //create the element
49
 
                this.element = document.createElement(this.elementTagName);
50
 
                document.body.appendChild(this.element);
51
 
                
52
 
                //reset the result
53
 
                this.result = null;
54
 
                
55
 
                this.element["on" + this.eventType] = Y.bind(function(event){
56
 
                    this.handleEvent(event || window.event);
57
 
                }, this);
58
 
                //assign event handler                
59
 
                //this.handler = Y.on(this.eventType, Y.bind(this.handleEvent,this), this.element);
60
 
            },
61
 
            
62
 
            /*
63
 
             * Removes event handlers that were used during the test.
64
 
             */
65
 
            tearDown : function() /*:Void*/{
66
 
            
67
 
                //remove the element
68
 
                document.body.removeChild(this.element);
69
 
    
70
 
                //remove event handler
71
 
                this.element["on" + this.eventType] = null;              
72
 
            },
73
 
            
74
 
            //---------------------------------------------------------------------
75
 
            // Event handler
76
 
            //---------------------------------------------------------------------
77
 
            
78
 
            /*
79
 
             * Uses to trap and assign the event object for interrogation.
80
 
             * @param {Event} event The event object created from the event.
81
 
             */
82
 
            handleEvent : function(event /*:Event*/) /*:Void*/ {
83
 
                this.result = event;
84
 
            }
85
 
        });
86
 
 
87
 
        //-------------------------------------------------------------------------
88
 
        // UIEvent Test Case
89
 
        //-------------------------------------------------------------------------
90
 
    
91
 
        function UIEventTestCase(type){
92
 
            UIEventTestCase.superclass.constructor.call(this, type);
93
 
            this.elementTagName = "input";
94
 
        }
95
 
    
96
 
        Y.extend(UIEventTestCase, GenericEventTestCase, { 
97
 
            /*
98
 
             * Tests with default options.
99
 
             */
100
 
            testDefault : function () /*:Void*/{        
101
 
                
102
 
                //fire the click event
103
 
                Y.Event.simulate(this.element, this.eventType);
104
 
    
105
 
                //test the data coming back
106
 
                Assert.isObject(this.result, "No event object created.");
107
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
108
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
109
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
110
 
                Assert.isFalse(this.result.cancelable, "Cancelable is incorrect.");
111
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
112
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
113
 
                
114
 
            }
115
 
        });
116
 
        
117
 
        //-------------------------------------------------------------------------
118
 
        // Focus/Blur Event Test Case
119
 
        //-------------------------------------------------------------------------
120
 
    
121
 
        function FocusBlurEventTestCase(type){
122
 
            FocusBlurEventTestCase.superclass.constructor.call(this, type);
123
 
            this.elementTagName = "input";
124
 
        }
125
 
    
126
 
        Y.extend(FocusBlurEventTestCase, GenericEventTestCase, { 
127
 
            /*
128
 
             * Tests with default options.
129
 
             */
130
 
            testDefault : function () /*:Void*/{        
131
 
                
132
 
                //fire the click event
133
 
                Y.Event.simulate(this.element, this.eventType);
134
 
    
135
 
                //test the data coming back
136
 
                Assert.isObject(this.result, "No event object created.");
137
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
138
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
139
 
                Assert.isFalse(this.result.bubbles, "bubbles is incorrect.");
140
 
                Assert.isFalse(this.result.cancelable, "Cancelable is incorrect.");
141
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
142
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
143
 
                
144
 
            }
145
 
        });
146
 
        
147
 
        
148
 
        //-------------------------------------------------------------------------
149
 
        // MouseButtonEvent Test Case
150
 
        //-------------------------------------------------------------------------
151
 
    
152
 
        function MouseButtonEventTestCase(type /*:String*/){
153
 
            MouseButtonEventTestCase.superclass.constructor.call(this, type);
154
 
        }
155
 
    
156
 
        Y.extend(MouseButtonEventTestCase, GenericEventTestCase, {
157
 
                
158
 
            //---------------------------------------------------------------------
159
 
            // Tests
160
 
            //---------------------------------------------------------------------
161
 
                    
162
 
            /*
163
 
             * Tests with default options.
164
 
             */
165
 
            testDefault : function () /*:Void*/{        
166
 
                
167
 
                //fire the click event
168
 
                Y.Event.simulate(this.element, this.eventType);
169
 
    
170
 
                //test the data coming back
171
 
                Assert.isObject(this.result, "No event object created.");
172
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
173
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
174
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
175
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
176
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
177
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
178
 
                //Assert.areEqual(0, this.result.button, "Button is incorrect.");
179
 
                
180
 
            },
181
 
            
182
 
            /*
183
 
             * Tests when using the right mouse button.
184
 
             */
185
 
            testRightBtn : function () /*:Void*/{        
186
 
                
187
 
                //fire the click event
188
 
                Y.Event.simulate(this.element, this.eventType, { button: 2 });
189
 
    
190
 
                //test the data coming back
191
 
                Assert.isObject(this.result, "No event object created.");
192
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
193
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
194
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
195
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
196
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
197
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
198
 
                //Assert.areEqual(2, this.result.button, "Button is incorrect.");
199
 
            },
200
 
            
201
 
            /*
202
 
             * Tests when using coordinates.
203
 
             */
204
 
            testCoords : function () /*:Void*/{        
205
 
                
206
 
                //fire the click event
207
 
                Y.Event.simulate(this.element, this.eventType, { clientX: 100, clientY: 150, screenX: 200, screenY: 250 });
208
 
    
209
 
                //test the data coming back
210
 
                Assert.isObject(this.result, "No event object created.");
211
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
212
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
213
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
214
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
215
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
216
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
217
 
                //Assert.areEqual(0, this.result.button, "Button is incorrect.");
218
 
                Assert.areEqual(100, this.result.clientX, "ClientX is incorrect.");
219
 
                Assert.areEqual(150, this.result.clientY, "ClientX is incorrect.");
220
 
                Assert.areEqual(200, this.result.screenX, "ScreenX is incorrect.");
221
 
                Assert.areEqual(250, this.result.screenY, "ScreenY is incorrect.");
222
 
            },
223
 
            
224
 
            /*
225
 
             * Tests UserAction.click() when using CTRL key.
226
 
             */
227
 
            testCtrlKey : function () /*:Void*/{        
228
 
                
229
 
                //fire the click event
230
 
                Y.Event.simulate(this.element, this.eventType, { ctrlKey: true });
231
 
    
232
 
                //test the data coming back
233
 
                Assert.isObject(this.result, "No event object created.");
234
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
235
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
236
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
237
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
238
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
239
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
240
 
                //Assert.areEqual(0, this.result.button, "Button is incorrect.");
241
 
                Assert.isTrue(this.result.ctrlKey, "CtrlKey is incorrect.");
242
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
243
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
244
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
245
 
            },
246
 
            
247
 
            /*
248
 
             * Tests when using ALT key.
249
 
             */
250
 
            testAltKey : function () /*:Void*/{        
251
 
                
252
 
                //fire the click event
253
 
                Y.Event.simulate(this.element, this.eventType, { altKey: true });
254
 
    
255
 
                //test the data coming back
256
 
                Assert.isObject(this.result, "No event object created.");
257
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
258
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
259
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
260
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
261
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
262
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
263
 
                //Assert.areEqual(0, this.result.button, "Button is incorrect.");
264
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
265
 
                Assert.isTrue(this.result.altKey, "AltKey is incorrect.");
266
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
267
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
268
 
            },
269
 
            
270
 
            /*
271
 
             * Tests when using Shift key.
272
 
             */
273
 
            testShiftKey : function () /*:Void*/{        
274
 
                
275
 
                //fire the click event
276
 
                Y.Event.simulate(this.element, this.eventType, { shiftKey: true });
277
 
    
278
 
                //test the data coming back
279
 
                Assert.isObject(this.result, "No event object created.");
280
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
281
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
282
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
283
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
284
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
285
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
286
 
                //Assert.areEqual(0, this.result.button, "Button is incorrect.");
287
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
288
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
289
 
                Assert.isTrue(this.result.shiftKey, "ShiftKey is incorrect.");
290
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
291
 
            },
292
 
            
293
 
            /*
294
 
             * Tests when using Meta key.
295
 
             */
296
 
            testMetaKey : function () /*:Void*/{        
297
 
                
298
 
                //fire the click event
299
 
                Y.Event.simulate(this.element, this.eventType, { metaKey: true });
300
 
    
301
 
                //test the data coming back
302
 
                Assert.isObject(this.result, "No event object created.");
303
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
304
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
305
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
306
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
307
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
308
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
309
 
                //Assert.areEqual(0, this.result.button, "Button is incorrect.");
310
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
311
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
312
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
313
 
                Assert.isTrue(this.result.metaKey, "MetaKey is incorrect.");
314
 
            }    
315
 
        
316
 
        });
317
 
        
318
 
        //-------------------------------------------------------------------------
319
 
        // MouseMovementEvent Test Case
320
 
        //-------------------------------------------------------------------------
321
 
        
322
 
        function MouseMovementEventTestCase(type /*:String*/) {
323
 
            MouseMovementEventTestCase.superclass.constructor.call(this,type);    
324
 
        }
325
 
        
326
 
        Y.extend(MouseMovementEventTestCase, MouseButtonEventTestCase, {
327
 
        
328
 
            /*
329
 
             * Tests that the relatedTarget property is correct.
330
 
             */
331
 
            testRelatedTarget : function () /*:Void*/{
332
 
            
333
 
                //fire the click event
334
 
                Y.Event.simulate(this.element, this.eventType, { relatedTarget: document.body });
335
 
    
336
 
                //test the data coming back
337
 
                Assert.isObject(this.result, "No event object created.");
338
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
339
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
340
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
341
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
342
 
                Assert.areSame(window, this.result.view, "View is incorrect.");
343
 
                Assert.areEqual(1, this.result.detail, "Details is incorrect.");
344
 
                //Assert.areEqual(0, this.result.button, "Button is incorrect.");
345
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
346
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
347
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
348
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");        
349
 
                Assert.areSame(document.body, this.result.relatedTarget || this.result.fromElement || this.result.toElement, "RelatedTarget is incorrect.");        
350
 
            }
351
 
        
352
 
        
353
 
        });
354
 
        
355
 
    
356
 
        //-------------------------------------------------------------------------
357
 
        // KeyEvent Test Case
358
 
        //-------------------------------------------------------------------------
359
 
        
360
 
        function KeyEventTestCase(type /*:String*/) {
361
 
            KeyEventTestCase.superclass.constructor.call(this,type);
362
 
        }
363
 
        
364
 
        Y.extend(KeyEventTestCase, GenericEventTestCase, {
365
 
        
366
 
            /*
367
 
             * Tests that the default properties are correct.
368
 
             */
369
 
            testDefault : function () /*:Void*/{
370
 
            
371
 
                //fire the click event
372
 
                Y.Event.simulate(this.element, this.eventType);
373
 
    
374
 
                //test the data coming back
375
 
                Assert.isObject(this.result, "No event object created.");
376
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
377
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
378
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
379
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
380
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
381
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
382
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
383
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");        
384
 
          
385
 
            },
386
 
            
387
 
            /*
388
 
             * Tests UserAction.click() when using CTRL key.
389
 
             */
390
 
            testCtrlKey : function () /*:Void*/{        
391
 
                
392
 
                //fire the click event
393
 
                Y.Event.simulate(this.element, this.eventType, { ctrlKey: true });
394
 
    
395
 
                //test the data coming back
396
 
                Assert.isObject(this.result, "No event object created.");
397
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
398
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
399
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
400
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
401
 
                Assert.isTrue(this.result.ctrlKey, "CtrlKey is incorrect.");
402
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
403
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
404
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
405
 
            },
406
 
            
407
 
            /*
408
 
             * Tests when using ALT key.
409
 
             */
410
 
            testAltKey : function () /*:Void*/{        
411
 
                
412
 
                //fire the click event
413
 
                Y.Event.simulate(this.element, this.eventType, { altKey: true });
414
 
    
415
 
                //test the data coming back
416
 
                Assert.isObject(this.result, "No event object created.");
417
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
418
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
419
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
420
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
421
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
422
 
                Assert.isTrue(this.result.altKey, "AltKey is incorrect.");
423
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
424
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
425
 
            },
426
 
            
427
 
            /*
428
 
             * Tests when using Shift key.
429
 
             */
430
 
            testShiftKey : function () /*:Void*/{        
431
 
                
432
 
                //fire the click event
433
 
                Y.Event.simulate(this.element, this.eventType, { shiftKey: true });
434
 
    
435
 
                //test the data coming back
436
 
                Assert.isObject(this.result, "No event object created.");
437
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
438
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
439
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
440
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
441
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
442
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
443
 
                Assert.isTrue(this.result.shiftKey, "ShiftKey is incorrect.");
444
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
445
 
            },
446
 
            
447
 
            /*
448
 
             * Tests when using Meta key.
449
 
             */
450
 
            testMetaKey : function () /*:Void*/{        
451
 
                
452
 
                //fire the click event
453
 
                Y.Event.simulate(this.element, this.eventType, { metaKey: true });
454
 
    
455
 
                //test the data coming back
456
 
                Assert.isObject(this.result, "No event object created.");
457
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
458
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
459
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
460
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
461
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
462
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
463
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
464
 
                Assert.isTrue(this.result.metaKey, "MetaKey is incorrect.");
465
 
            }            
466
 
        
467
 
        
468
 
        });    
469
 
        
470
 
        //-------------------------------------------------------------------------
471
 
        // KeyDirection Test Case
472
 
        //-------------------------------------------------------------------------    
473
 
        
474
 
        function KeyDirectionEventTestCase(type /*:String*/){
475
 
            KeyDirectionEventTestCase.superclass.constructor.call(this, type);
476
 
        }
477
 
        
478
 
        Y.extend(KeyDirectionEventTestCase, KeyEventTestCase, {
479
 
        
480
 
            /*
481
 
             * Tests that the default properties are correct.
482
 
             */
483
 
            testKeyCode : function () /*:Void*/{
484
 
            
485
 
                //fire the click event
486
 
                Y.Event.simulate(this.element, this.eventType, { keyCode: 97 });
487
 
    
488
 
                //test the data coming back
489
 
                Assert.isObject(this.result, "No event object created.");
490
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
491
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
492
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
493
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
494
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
495
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
496
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
497
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");        
498
 
                Assert.areEqual(97, this.result.keyCode, "KeyCode is incorrect.");
499
 
            }
500
 
        
501
 
        });
502
 
        
503
 
        //-------------------------------------------------------------------------
504
 
        // TextEvent Test Case
505
 
        //-------------------------------------------------------------------------
506
 
        
507
 
        function TextEventTestCase(type /*:String*/){
508
 
            TextEventTestCase.superclass.constructor.call(this, type);
509
 
        }
510
 
        
511
 
        Y.extend(TextEventTestCase, KeyEventTestCase, {
512
 
        
513
 
            /*
514
 
             * Tests that the default properties are correct.
515
 
             */
516
 
            testCharCode : function () /*:Void*/{
517
 
            
518
 
                //fire the click event
519
 
                Y.Event.simulate(this.element, this.eventType, { charCode: 97 });
520
 
    
521
 
                //test the data coming back
522
 
                Assert.isObject(this.result, "No event object created.");
523
 
                Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
524
 
                Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
525
 
                Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
526
 
                Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
527
 
                Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
528
 
                Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
529
 
                Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
530
 
                Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");        
531
 
                Assert.areEqual(97, this.result.charCode || this.result.keyCode, "CharCode is incorrect.");
532
 
            }
533
 
        
534
 
        });        
535
 
        
536
 
        //-------------------------------------------------------------------------
537
 
        // UserAction Tests
538
 
        //-------------------------------------------------------------------------
539
 
    
540
 
        //the user action suite
541
 
        var suite /*:Y.Test.Suite*/ 
542
 
            = new Y.Test.Suite("Event Simulate Tests");
543
 
        
544
 
        var mouseEventsSuite /*:Y.Test.Suite*/ 
545
 
            = new Y.Test.Suite("MouseEvent Tests");
546
 
        suite.add(mouseEventsSuite);
547
 
        
548
 
        var keyEventsSuite /*:Y.Test.Suite*/ 
549
 
            = new Y.Test.Suite("KeyEvent Tests");
550
 
        suite.add(keyEventsSuite);
551
 
    
552
 
        var uiEventsSuite /*:Y.Test.Suite*/ 
553
 
            = new Y.Test.Suite("UIEvents Tests");
554
 
        suite.add(uiEventsSuite);
555
 
    
556
 
        //-------------------------------------------------------------------------
557
 
        // Mouse Tests
558
 
        //-------------------------------------------------------------------------
559
 
        mouseEventsSuite.add(new MouseButtonEventTestCase("click"));
560
 
        mouseEventsSuite.add(new MouseButtonEventTestCase("dblclick"));
561
 
        mouseEventsSuite.add(new MouseButtonEventTestCase("mousedown"));
562
 
        mouseEventsSuite.add(new MouseButtonEventTestCase("mouseup"));        
563
 
        mouseEventsSuite.add(new MouseMovementEventTestCase("mouseover"));
564
 
        mouseEventsSuite.add(new MouseMovementEventTestCase("mouseout"));
565
 
        
566
 
        //-------------------------------------------------------------------------
567
 
        // Key Tests
568
 
        //-------------------------------------------------------------------------
569
 
        keyEventsSuite.add(new KeyDirectionEventTestCase("keyup"));
570
 
        keyEventsSuite.add(new KeyDirectionEventTestCase("keydown"));
571
 
        keyEventsSuite.add(new TextEventTestCase("keypress"));        
572
 
    
573
 
        //-------------------------------------------------------------------------
574
 
        // UI Tests
575
 
        //-------------------------------------------------------------------------
576
 
        uiEventsSuite.add(new UIEventTestCase("change"));
577
 
        uiEventsSuite.add(new UIEventTestCase("select"));
578
 
        uiEventsSuite.add(new FocusBlurEventTestCase("blur"));
579
 
        uiEventsSuite.add(new FocusBlurEventTestCase("focus"));
580
 
        
581
 
        //return it
582
 
        return suite;
583
 
    
584
 
    })();
585
 
 
586
 
    
587
 
    var r = new Y.Console({
588
 
        verbose : true,
589
 
        //consoleLimit : 10,
590
 
        newestOnTop : false
591
 
    });
592
 
    
593
 
    r.render('#c');
594
 
    
595
 
    
596
 
    //add to the testrunner and run
597
 
    Y.Test.Runner.add(Y.Tests.EventSimulate);
598
 
    Y.Test.Runner.run();
599
 
 
600
 
    /*if (parent && parent != window) {
601
 
        YAHOO.tool.TestManager.load();
602
 
    } else {
603
 
        YAHOO.tool.TestRunner.run();
604
 
    }*/
605
 
 
606
 
});
607
 
 
608
 
 
609
 
</script>
610
 
</body>
611
 
</html>