Documentation

include MVC MVC.Animate MVC.Class MVC.Controller MVC.Controller.Action MVC.Controller.Action.Drag MVC.Controller.Action.Drop MVC.Controller.Action.EnterLeave MVC.Controller.Action.Event MVC.Controller.Action.Hover MVC.Controller.Action.Lasso MVC.Controller.Action.Selectable MVC.Controller.Action.Subscribe MVC.Controller.Comet MVC.Controller.Params MVC.Controller.Params.Drag MVC.Controller.Params.Drop MVC.Controller.Stateful MVC.Delegator MVC.Doc MVC.Element MVC.Event MVC.File MVC.History MVC.IO MVC.IO.Ajax MVC.IO.Comet MVC.IO.JsonP MVC.IO.WindowName MVC.IO.XDoc MVC.Model MVC.Model.Ajax MVC.Model.Cookie MVC.Model.JsonP MVC.Model.JsonRest MVC.Model.WindowName MVC.Model.XmlRest MVC.Native MVC.Native.Array MVC.Native.Date MVC.Native.Function MVC.Native.Number MVC.Native.Object MVC.Native.String MVC.Options MVC.Store MVC.SyntheticEvent MVC.Test MVC.Test.Assertions MVC.Test.Controller MVC.Test.Functional MVC.Test.Runner MVC.Test.Unit MVC.Timer MVC.Timer.Easings MVC.Vector MVC.View MVC.View.Helpers OpenAjax

MVC.Test.Functional

Inherits: MVC.Test
Functional tests are used to mimic user events.

Prototype Methods

Action

Action(event_type, selector, options) -> undefined
Creates a syntetic event on a HTMLElement.
 this.Action('click','.todo',3) //calls a click on the third element with class '.todo'
{String} - A lowercase event type. One of ['change', 'click', 'contextmenu', 'dblclick', 'keyup', 'keydown', 'keypress','mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'submit', 'focus', 'blur','drag', 'write'].
{String/HTMLElement} - An HTMLElement or a CSS selector.
{Number/Object} - If a number is provided, it uses it to select that number from the array of elements returned by doing a CSSQuery with selector. If an object is provided, it passes those options to the SyntheticEvent for creation. If nothing is provided, the number defaults to 0.

Blur

Blur(selector_or_element, options_or_number) -> undefined
Calls Action using 'blur' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Change

Change() -> undefined
Calls Action using 'change' as the first parameter.

Click

Click(selector_or_element, options_or_number) -> undefined
Calls Action using 'click' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Contextmenu

Contextmenu(selector_or_element, options_or_number) -> undefined
Calls Action using 'contextmenu' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Dblclick

Dblclick(selector_or_element, options_or_number) -> undefined
Calls Action using 'dblclick' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Dblclick

Dblclick(selector_or_element, options_or_number) -> undefined
Calls Action using 'dblclick' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Drag

Drag(selector_or_element, options) -> undefined
Creates events that simulate a drag motion across the browser. The drag events are comprised of a mousedown from the from location, equal spaced mousemoves to the to location, and a mouseup at the to location. Drag is by default syncronous, but can be made asyncronous by providing a duration option.
test_drag_to_trash : function(){
  this.Drag('#/drag_handle', 
    {
      from: '/drag_handle',
      to: '/trash', 
      duration: 2, 
      callback: this.next_callback()
    })
},
make_sure_drag_worked : function(){
  this.assertNull(document.getElementById('/drag_handle'));
}
{String/HTMLElement} -
{Object} - A hash with the following properties:
OptionDefaultDescription
callback null A callback that gets called when the drag motion has completed. This is only necessary with asyncronous drags. Typically, the callback can be provided by next_callback();
duration null The length of time in seconds the drag takes place. By setting this option, the events are dispatched in intervals, letting the browser update the screen. Typically, you want to provide a callback to test the results of the drag after completion.
from null The starting coordinates of the drag. This can be specified in three ways: first, as an object like {x: 123, y: 321}; second, as a HTMLElement; third, as the string ID of a HTMLElement. Providing an element or the id of an element, Drag will use the center of the element as is starting position.
steps 100 The number of mousemoves called to represent the drag. This parameter is void if duration is provided.
to null The ending coordinates of the drag. Use the to option the same way as the from option.

Focus

Focus(selector_or_element, options_or_number) -> undefined
Calls Action using 'focus' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

init

init(name, tests) -> undefined
Creates a new functional test case. A test case is a collection of test functions and helpers.
new MVC.Test.Functional('TestCaseName',{
  test_some_clicks : function(){
    this.Click('#button')
  }
})
{String} - The unique name of the test. Make sure no two tests have the same name.
{Object} - An object with test functions. Functions that begin with test_ will be run as tests. Functions that don't begin with test are converted to helper functions. Do not name helper functions the same name as the test provided helpers and assertions such as assert or assertEqual as your functions will override these functions.

Keydown

Keydown(selector_or_element, options_or_number) -> undefined
Calls Action using 'keydown' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Keypress

Keypress(selector_or_element, The, options) -> undefined
Calls Action using 'keypress' as the first parameter. In browsers other that Firefox, keypress support built into the browser doesn't actually write text into the input element. To make up for this shortcoming, this method manually inserts text into the input element's value attribute.
{String/HTMLElement} -
{String} - character to be written to the passed element, '\b' causes a character to be deleted, '\n' simulates pressing enter
{Object} - a hash with the following properties:
OptionDefaultDescription
character false True to simulate pressing the alt key.
ctrlKey false True to simulate pressing the control key.
altKey false True to simulate pressing the alt key.
shiftKey false True to simulate pressing the shift key.
metaKey false True to simulate pressing the meta key.
keyCode 0 Used to simulate pressing other keys, this reference shows a list of keyCodes you can use.

Keyup

Keyup(selector_or_element, options_or_number) -> undefined
Calls Action using 'keyup' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Load

Load(selector_or_element, options_or_number) -> undefined
Calls Action using 'load' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Mousedown

Mousedown(selector_or_element, options_or_number) -> undefined
Calls Action using 'mousedown' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Mousemove

Mousemove(selector_or_element, options_or_number) -> undefined
Calls Action using 'mousemove' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Mouseout

Mouseout(selector_or_element, options_or_number) -> undefined
Calls Action using 'mouseout' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Mouseover

Mouseover(selector_or_element, options_or_number) -> undefined
Calls Action using 'mouseover' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Mouseup

Mouseup(selector_or_element, options_or_number) -> undefined
Calls Action using 'mouseup' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Reset

Reset(selector_or_element, options_or_number) -> undefined
Calls Action using 'reset' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Resize

Resize(selector_or_element, options_or_number) -> undefined
Calls Action using 'resize' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Scroll

Scroll(selector_or_element, options_or_number) -> undefined
Calls Action using 'scroll' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Select

Select(selector_or_element, options_or_number) -> undefined
Calls Action using 'select' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Submit

Submit(selector_or_element, options_or_number) -> undefined
Calls Action using 'submit' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Unload

Unload(selector_or_element, options_or_number) -> undefined
Calls Action using 'unload' as the first parameter.
{String/HTMLElement} -
{Object/Number} -

Write

Write(selector_or_element, options_or_string) -> undefined
Creates events that simulate writing into an input element. If a callback option is used in the second parameter, the event is asynchronous. Otherwise, it is synchronous.
// syntax 1: synchronous version
this.Write(input_params.element, 'Brian');
// syntax 2: asynchronous version
this.Write(input_params.element, {text: 'Brian', callback: this.next_callback()});
{String/HTMLElement} -
{Object/String} - If a string is passed, it is the text written in the passed input element. If a hash is passed it, it expects the following parameters:
OptionDefaultDescription
callback null A callback that gets called when the write has completed. This is only necessary with asyncronous writes. Typically, the callback can be provided by next_callback();
duration null The length of time in seconds the write takes place. By setting this option, the events are dispatched in intervals, letting the browser update the screen. Typically, you want to provide a callback to test the results of the drag after completion.
text null The text to be written into the given input element.
'\b' - the backspace character is used to delete one character of text
'\n' - the newline character is used to simulate pressing enter