testing.events

Classes

goog.testing.events.Event
goog.events.BrowserEvent expects an Event so we provide one for JSCompiler. This clones a lot of the functionality of goog.events.Event. This used to use a mixin, but the mixin results in confusing the two types when compiled.
goog.testing.events.EventMatcher
A matcher that verifies that an argument is a goog.events.Event of a particular type.
goog.testing.events.EventObserver
Event observer. Implements a handleEvent interface so it may be used as a listener in listening functions and methods.
goog.testing.events.OnlineHandler
NetworkStatusMonitor test double.

Public Protected Private

Global Functions

goog.testing.events.assertEventTarget_(target) !EventTarget
Asserts an event target exists. This will fail if target is not defined. TODO(nnaze): Gradually add this to the methods in this file, and eventually update the method signatures to not take nullables. See http://b/8961907
Arguments:
target : EventTarget
A target to assert.
Returns: !EventTarget  The target, guaranteed to exist.
code »
goog.testing.events.fireBlurEvent(target) boolean
Simulate a blur event on the given target.
Arguments:
target : EventTarget
The target for the event.
Returns: boolean  The value returned by firing the blur browser event, which returns false iff 'preventDefault' was invoked.
code »
goog.testing.events.fireBrowserEvent(event) boolean
Simulates an event's capturing and bubbling phases.
Arguments:
event : Event
A simulated native event. It will be wrapped in a normalized BrowserEvent and dispatched to Closure listeners on all ancestors of its target (inclusive).
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireClickEvent(targetopt_buttonopt_coordsopt_eventProperties) boolean
Simulates a click event on the given target. IE only supports click with the left mouse button.
Arguments:
target : EventTarget
The target for the event.
opt_button : goog.events.BrowserEvent.MouseButton=
Mouse button; defaults to goog.events.BrowserEvent.MouseButton.LEFT.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireClickSequence(targetopt_buttonopt_coordsopt_eventProperties) boolean
Simulates a mousedown, mouseup, and then click on the given event target, with the left mouse button.
Arguments:
target : EventTarget
The target for the event.
opt_button : goog.events.BrowserEvent.MouseButton=
Mouse button; defaults to goog.events.BrowserEvent.MouseButton.LEFT.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.
code »
goog.testing.events.fireContextMenuEvent(targetopt_coords) boolean
Simulates a contextmenu event on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireContextMenuSequence(targetopt_coords) boolean
Simulates a mousedown, contextmenu, and the mouseup on the given event target, with the right mouse button.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
Returns: boolean  The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.
code »
goog.testing.events.fireDoubleClickEvent(targetopt_coordsopt_eventProperties) boolean
Simulates a double-click event on the given target. Always double-clicks with the left mouse button since no browser supports double-clicking with any other buttons.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireDoubleClickSequence(targetopt_coordsopt_eventProperties) boolean
Simulates the sequence of events fired by the browser when the user double- clicks the given target.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.
code »
goog.testing.events.fireFocusEvent(target) boolean
Simulate a focus event on the given target.
Arguments:
target : EventTarget
The target for the event.
Returns: boolean  The value returned by firing the focus browser event, which returns false iff 'preventDefault' was invoked.
code »
goog.testing.events.fireKeySequence(targetkeyCodeopt_eventProperties) boolean
Simulates a complete keystroke (keydown, keypress, and keyup). Note that if preventDefault is called on the keydown, the keypress will not fire.
Arguments:
target : EventTarget
The target for the event.
keyCode : number
The keycode of the key pressed.
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.
code »
goog.testing.events.fireMouseButtonEvent_(typetargetopt_buttonopt_coordsopt_eventProperties) boolean
Helper function to fire a mouse event. with the left mouse button since no browser supports double-clicking with any other buttons.
Arguments:
type : string
The event type.
target : EventTarget
The target for the event.
opt_button : number=
Mouse button; defaults to goog.events.BrowserEvent.MouseButton.LEFT.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireMouseDownEvent(targetopt_buttonopt_coordsopt_eventProperties) boolean
Simulates a mousedown event on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_button : goog.events.BrowserEvent.MouseButton=
Mouse button; defaults to goog.events.BrowserEvent.MouseButton.LEFT.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireMouseMoveEvent(targetopt_coords) boolean
Simulates a mousemove event on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireMouseOutEvent(targetrelatedTargetopt_coords) boolean
Simulates a mouseout event on the given target.
Arguments:
target : EventTarget
The target for the event.
relatedTarget : EventTarget
The related target for the event (e.g., the node that the mouse is being moved into).
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireMouseOverEvent(targetrelatedTargetopt_coords) boolean
Simulates a mouseover event on the given target.
Arguments:
target : EventTarget
The target for the event.
relatedTarget : EventTarget
The related target for the event (e.g., the node that the mouse is being moved out of).
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireMouseUpEvent(targetopt_buttonopt_coordsopt_eventProperties) boolean
Simulates a mouseup event on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_button : goog.events.BrowserEvent.MouseButton=
Mouse button; defaults to goog.events.BrowserEvent.MouseButton.LEFT.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireNonAsciiKeySequence(targetkeyCodekeyPressKeyCodeopt_eventProperties) boolean
Simulates a complete keystroke (keydown, keypress, and keyup) when typing a non-ASCII character. Same as fireKeySequence, the keypress will not fire if preventDefault is called on the keydown.
Arguments:
target : EventTarget
The target for the event.
keyCode : number
The keycode of the keydown and keyup events.
keyPressKeyCode : number
The keycode of the keypress event.
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.
code »
goog.testing.events.firePopStateEvent(targetstate) boolean
Simulates a popstate event on the given target.
Arguments:
target : EventTarget
The target for the event.
state : Object
History state object.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireTouchEndEvent(targetopt_coordsopt_eventProperties) boolean
Simulates a touchend event on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Touch position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireTouchMoveEvent(targetopt_coordsopt_eventProperties) boolean
Simulates a touchmove event on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Touch position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.fireTouchSequence(targetopt_coordsopt_eventProperties) boolean
Simulates a simple touch sequence on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Touch position. Defaults to event target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.
code »
goog.testing.events.fireTouchStartEvent(targetopt_coordsopt_eventProperties) boolean
Simulates a touchstart event on the given target.
Arguments:
target : EventTarget
The target for the event.
opt_coords : goog.math.Coordinate=
Touch position. Defaults to event's target's position (if available), otherwise (0, 0).
opt_eventProperties : Object=
Event properties to be mixed into the BrowserEvent.
Returns: boolean  The returnValue of the event: false if preventDefault() was called on it, true otherwise.
code »
goog.testing.events.isBrokenGeckoMacActionKey_(e) boolean
No description.
Arguments:
e : goog.testing.events.Event
The event.
Returns: boolean  Whether this is the Gecko/Mac's Meta-C/V/X, which is broken and requires special handling.
code »
goog.testing.events.mixinListenable(obj)
Mixins a listenable into the given object. This turns the object into a goog.events.Listenable. This is useful, for example, when you need to mock a implementation of listenable and still want it to work with goog.events.
Arguments:
obj : !Object
The object to mixin into.
code »
goog.testing.events.setEventClientXY_(eventopt_coords)
A static helper function that sets the mouse position to the event.
Arguments:
event : Event
A simulated native event.
opt_coords : goog.math.Coordinate=
Mouse position. Defaults to event's target's position (if available), otherwise (0, 0).
code »

Global Properties

goog.testing.events.EventMatcherTest :
No description.
Code »
goog.testing.events.EventObserverTest :
No description.
Code »
goog.testing.events.OnlineHandlerTest :
No description.
Code »

Package testing

Package Reference