event-simulate.html revision 9f07526b4143bd56d662c42b82c38343f5217ff7
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas<html>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas<head>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas<title>event-simulate tests</title>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas<link type="text/css" rel="stylesheet" href="/build/logreader/assets/skins/sam/logreader.css" />
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas<script type="text/javascript" src="/build/yui/yui.js"></script>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas</head>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas<body class="yui-skin-sam">
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas <h1>Event-Simulate Tests</h1>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas <div id="c"></div>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas<script type="text/javascript">
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. ZakasYUI({
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas base: '/build/',
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas filter: "debug",
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas logInclude: { TestRunner: 1}
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas}).use('test', 'event-simulate', 'console', function (Y) {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.namespace("Tests");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Tests.EventSimulate = (function(){
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas var Assert = Y.Assert,
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas ObjectAssert = Y.ObjectAssert;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // Generic Event Test Case
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas function GenericEventTestCase(type /*:String*/){
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas GenericEventTestCase.superclass.constructor.call(this);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.eventType = type;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.name = "Event '" + type + "' Tests";
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.result = null;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.element = null;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.elementTagName = "div";
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.extend(GenericEventTestCase, Y.Test.Case, {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //---------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // Setup and teardown of test harnesses
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //---------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Sets up several event handlers used to test UserAction mouse events.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas setUp : function() /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //create the element
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.element = document.createElement(this.elementTagName);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas document.body.appendChild(this.element);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //reset the result
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.result = null;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.element["on" + this.eventType] = Y.bind(function(event){
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.handleEvent(event || window.event);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }, this);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //assign event handler
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //this.handler = Y.on(this.eventType, Y.bind(this.handleEvent,this), this.element);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Removes event handlers that were used during the test.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas tearDown : function() /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //remove the element
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas document.body.removeChild(this.element);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //remove event handler
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.element["on" + this.eventType] = null;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //---------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // Event handler
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //---------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Uses to trap and assign the event object for interrogation.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * @param {Event} event The event object created from the event.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas handleEvent : function(event /*:Event*/) /*:Void*/ {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas this.result = event;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // MouseButtonEvent Test Case
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas function MouseButtonEventTestCase(type /*:String*/){
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas MouseButtonEventTestCase.superclass.constructor.call(this, type);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.extend(MouseButtonEventTestCase, GenericEventTestCase, {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //---------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // Tests
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //---------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests with default options.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testDefault : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(0, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using the right mouse button.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testRightBtn : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { button: 2 });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(2, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using coordinates.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testCoords : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { clientX: 100, clientY: 150, screenX: 200, screenY: 250 });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(0, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(100, this.result.clientX, "ClientX is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(150, this.result.clientY, "ClientX is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(200, this.result.screenX, "ScreenX is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(250, this.result.screenY, "ScreenY is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests UserAction.click() when using CTRL key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testCtrlKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { ctrlKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(0, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using ALT key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testAltKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { altKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(0, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using Shift key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testShiftKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { shiftKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(0, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using Meta key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testMetaKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { metaKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(0, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // MouseMovementEvent Test Case
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas function MouseMovementEventTestCase(type /*:String*/) {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas MouseMovementEventTestCase.superclass.constructor.call(this,type);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.extend(MouseMovementEventTestCase, MouseButtonEventTestCase, {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests that the relatedTarget property is correct.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testRelatedTarget : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { relatedTarget: document.body });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(window, this.result.view, "View is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(1, this.result.detail, "Details is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //Assert.areEqual(0, this.result.button, "Button is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(document.body, this.result.relatedTarget || this.result.fromElement || this.result.toElement, "RelatedTarget is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // KeyEvent Test Case
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas function KeyEventTestCase(type /*:String*/) {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas KeyEventTestCase.superclass.constructor.call(this,type);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.extend(KeyEventTestCase, GenericEventTestCase, {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests that the default properties are correct.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testDefault : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests UserAction.click() when using CTRL key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testCtrlKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { ctrlKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using ALT key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testAltKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { altKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using Shift key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testShiftKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { shiftKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas },
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests when using Meta key.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testMetaKey : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { metaKey: true });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // KeyDirection Test Case
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas function KeyDirectionEventTestCase(type /*:String*/){
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas KeyDirectionEventTestCase.superclass.constructor.call(this, type);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.extend(KeyDirectionEventTestCase, KeyEventTestCase, {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests that the default properties are correct.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testKeyCode : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { keyCode: 97 });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(97, this.result.keyCode, "KeyCode is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // TextEvent Test Case
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas function TextEventTestCase(type /*:String*/){
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas TextEventTestCase.superclass.constructor.call(this, type);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.extend(TextEventTestCase, KeyEventTestCase, {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas * Tests that the default properties are correct.
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas */
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas testCharCode : function () /*:Void*/{
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //fire the click event
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Event.simulate(this.element, this.eventType, { charCode: 97 });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //test the data coming back
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isObject(this.result, "No event object created.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areSame(this.element, this.result.target || this.result.srcElement, "Target is not correct.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(this.eventType, this.result.type, "Event type is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.bubbles, "bubbles is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isTrue(this.result.cancelable, "Cancelable is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.ctrlKey, "CtrlKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.altKey, "AltKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.shiftKey, "ShiftKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.isFalse(this.result.metaKey, "MetaKey is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Assert.areEqual(97, this.result.charCode || this.result.keyCode, "CharCode is incorrect.");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // UserAction Tests
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //the user action suite
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas var suite /*:Y.Test.Suite*/
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas = new Y.Test.Suite("Event Simulate Tests");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas var mouseEventsSuite /*:Y.Test.Suite*/
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas = new Y.Test.Suite("MouseEvent Tests");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas suite.add(mouseEventsSuite);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas var keyEventsSuite /*:Y.Test.Suite*/
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas = new Y.Test.Suite("KeyEvent Tests");
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas suite.add(keyEventsSuite);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // Mouse Tests
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas mouseEventsSuite.add(new MouseButtonEventTestCase("click"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas mouseEventsSuite.add(new MouseButtonEventTestCase("dblclick"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas mouseEventsSuite.add(new MouseButtonEventTestCase("mousedown"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas mouseEventsSuite.add(new MouseButtonEventTestCase("mouseup"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas mouseEventsSuite.add(new MouseMovementEventTestCase("mouseover"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas mouseEventsSuite.add(new MouseMovementEventTestCase("mouseout"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas // Key Tests
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //-------------------------------------------------------------------------
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas keyEventsSuite.add(new KeyDirectionEventTestCase("keyup"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas keyEventsSuite.add(new KeyDirectionEventTestCase("keydown"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas keyEventsSuite.add(new TextEventTestCase("keypress"));
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //return it
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas return suite;
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas })();
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas var r = new Y.Console({
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas verbose : true,
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //consoleLimit : 10,
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas newestOnTop : false
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas });
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas r.render('#c');
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas //add to the testrunner and run
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Test.Runner.add(Y.Tests.EventSimulate);
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas Y.Test.Runner.run();
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas /*if (parent && parent != window) {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas YAHOO.tool.TestManager.load();
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas } else {
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas YAHOO.tool.TestRunner.run();
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas }*/
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas});
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas</script>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas</body>
9f07526b4143bd56d662c42b82c38343f5217ff7Nicholas C. Zakas</html>