TestAssertions

From Web Events Wiki
Jump to: navigation, search

NOTE: the Web Events Working Group closed in November 2013 because it completed its technical work with the publication of the 10 October 2013 Touch Events Recommendation. As such, this document is NO longer maintained.


Test Assertions for Touch Events v1

This page documents the test assertions for the Touch Events v1 specification [1].

This is work-in-progress. Feedback or direct modifications of this page is welcomed.

Test Assertions for Touch Interface

Assertion Applies to Single-touch Applies to Multi-touch
1.1.1 Touch object must be immutable

(Question: Is this testable?)

Y Y
1.1.2 For any Touch object, each of the attributes must exist Y Y
1.1.3 For any Touch object, each of the attributes must be of the specified data type Y Y

Test Assertions for TouchList Interface

Assertion Applies to Single-touch Applies to Multi-touch
1.2.1 For any TouchList object, each of the attributes must exist Y Y
1.2.2 For any TouchList object, each of the attributes must be of the specified data type Y Y
1.2.3 For any TouchList object, 0 ≤ length ≤ 1 Y
1.2.4 For any TouchList object, length ≥ 0 Y
1.2.5 For any TouchList object, for each i where 0 ≤ i ≤ length-1, item(i) must return a Touch object Y Y
1.2.6 For any TouchList object, for each i where 0 ≤ i ≤ length-1, item(i) must return the same Touch object as identifiedTouch(item(i).identifier) Y Y

Test Assertions for touchstart event

Assertion Applies to Single-touch Applies to Multi-touch
Event attributes 1.3.1.1 For any touchstart event object, each of the attributes must exist Y Y
1.3.1.2 For any touchstart event object, each of the attributes must be of the specified data type Y Y
changedTouches 1.3.2.1 For any touchstart event object, changedTouches.length==1 Y
1.3.2.2 For any touchstart event object, 1 ≤ changedTouches.length ≤ touches.length Y
1.3.2.3 For any touchstart event object, changedTouches.item(0).identifier == touches.item(0).identifier Y
1.3.2.4 For any touchstart event object, each item in changedTouches must also appear in touches

In other words, for i where 0 ≤ i ≤ changedTouches.length-1, there exists j where 0 ≤ j ≤ touches.length-1 such that changedTouches.item(i).identifier == touches.item(j).identifier

Y
targetTouches 1.3.3.1 For any touchstart event object, targetTouches.length == 1 Y
1.3.3.2 For any touchstart event object, 1 ≤ targetTouches.length ≤ touches.length Y
1.3.3.3 For any touchstart event object, each item in targetTouches must also appear in touches

In other words, for i where 0 ≤ i ≤ targetTouches.length-1, there exists j where 0 ≤ j ≤ touches.length-1 such that targetTouches.item(i).identifier == touches.item(j).identifier

Y Y
1.3.3.4 For any touchstart event object, targetTouches.item(0).identifier == changedTouches.item(0).identifier Y
1.3.3.5 For the first received touchstart event object, targetTouches.length ≤ changedTouches.length Y
1.3.3.6 For each subsequent touchstart event object, targetTouches.length must be greater than the targetTouches.length value in the last received touch event. Additionally, the difference must be ≤ changedTouches.length

Precondition: the element is listening to ALL touch events

Y
1.3.3.7 For the first received touchstart event object, each item in targetTouches must also appear in changedTouches

In other words, for i where 0 ≤ i ≤ targetTouches.length-1, there exists j where 0 ≤ j ≤ changedTouches.length-1 such that targetTouches.item(i).identifier == changedTouches.item(j).identifier

Y
1.3.3.8 For each subsequent touchstart event object, at least one item in targetTouches must appear in changedTouches.

In other words, there exists i, where 0 ≤ i ≤ targetTouches.length-1, and j, where 0 ≤ j ≤ changedTouches.length-1, such that targetTouches.item(i).identifier == changedTouches.item(j).identifier

Y
1.3.3.9 For any touchstart event object, the target attribute of each item in targetTouches must be the element receiving the event Y Y
touches 1.3.4.1 For any touchstart event object, touches.length == 1 Y
1.3.4.2 For any touchstart event object, touches.length ≥ 1 Y
1.3.4.3 For the first received touchstart event object, touches.length == changedTouches.length Y
1.3.4.4 For each subsequent touchstart event object, touches.length must be greater than the touches.length value of the last received touch event. Additionally, the different must be == changedTouches.length

Precondition: the element is listening to ALL touch events

Y
1.3.4.5 For each subsequent touchstart event object, each item in touches must also appear either in changedTouches of the same touch event or in touches of the last received touch event.

In other words, for i where 0 ≤ i ≤ touches.length-1, either there exists j where 0 ≤ j ≤ changedTouches.length-1 such that touches.item(i).identifier == changedTouches.item(j).identifier, or there exists k where 0 ≤ k ≤ lastTouches.length-1 such that touches.item(i).identifier == lastTouches.item(k) where lastTouches is the value of the touches attribute of the last received touch event.

Precondition: the element is listening to ALL touch events

Y

Test Assertions for touchmove event

Assertion Applies to Single-touch Applies to Multi-touch
Event attributes 1.4.1.1 For any touchmove event object, each of the attributes must exist Y Y
1.4.1.2 For any touchmove event object, each of the attributes must be of the specified data type Y Y
changedTouches 1.4.2.1 For any touchmove event object, changedTouches.length==1 Y
1.4.2.2 For any touchmove event object, 1 ≤ changedTouches.length ≤ touches.length Y
1.4.2.3 For any touchmove event object, changedTouches.item(0).identifier == touches.item(0).identifier Y
1.4.2.4 For any touchmove event object, each item in changedTouches must also appear in touches

In other words, for i where 0 ≤ i ≤ changedTouches.length-1, there exists j where 0 ≤ j ≤ touches.length-1 such that changedTouches.item(i).identifier == touches.item(j).identifier

Y
targetTouches 1.4.3.1 For any touchmove event object, targetTouches.length == 1 Y
1.4.3.2 For any touchmove event object, 1 ≤ targetTouches.length ≤ touches.length Y
1.4.3.3 For any touchmove event object, targetTouches.item(0).identifier == touches.item(0).identifier Y
1.4.3.4 For any touchmove event object, each item in targetTouches must also appear in touches

In other words, for i where 0 ≤ i ≤ targetTouches.length-1, there exists j where 0 ≤ j ≤ touches.length-1 such that targetTouches.item(i).identifier == touches.item(j).identifier

Y
1.4.3.5 For any touchmove event object, targetTouches.item(0).identifier == changedTouches.item(0).identifier Y
1.4.3.6 For any touchmove event object, at least one item in targetTouches must appear in changedTouches.

In other words, there exists i, where 0 ≤ i ≤ targetTouches.length-1, and j, where 0 ≤ j ≤ changedTouches.length-1, such that targetTouches.item(i).identifier == changedTouches.item(j).identifier

Y
1.4.3.7 For any touchmove event object, targetTouches.length must be the same as the targetTouches.length value in the last received touch event.

Precondition: the element is listening to ALL touch events

Y
1.4.3.8 For any touchmove event object, the target attribute of each item in targetTouches must be the element receiving the event Y Y
touches 1.4.4.1 For any touchmove event object, touches.length == 1 Y
1.4.4.2 For any touchmove event object, touches.length must be the same as the touches.length value of the last received touch event.

Precondition: the element is listening to ALL touch events

Y
1.4.4.3 For any touchmove event object, each item in touches must also appear in touches of the last received touch event.

In other words, for i where 0 ≤ i ≤ touches.length-1, there exists j where 0 ≤ j ≤ lastTouches.length-1 such that touches.item(i).identifier == lastTouches.item(j) where lastTouches is the value of the touches attribute of the last received touch event.

Precondition: the element is listening to ALL touch events

Y Y

Test Assertions for touchend and touchcancel events

Assertion Applies to Single-touch Applies to Multi-touch
Event attributes 1.5.1.1 For any touchend or touchcancel event object, each of the attributes must exist Y Y
1.5.1.2 For any touchend or touchcancel event object, each of the attributes must be of the specified data type Y Y
changedTouches 1.5.2.1 For any touchend or touchcancel event object, changedTouches.length==1 Y
1.5.2.2 For any touchend or touchcancel event object, changedTouches.length ≥ 1 Y
1.5.2.3 For any touchend or touchcancel event object, each item in changedTouches must also appear in touches of the last received touch event.

In other words, for i where 0 ≤ i ≤ changedTouches.length-1, there exists j where 0 ≤ j ≤ lastTouches.length-1 such that changedTouches.item(i).identifier == lastTouches.item(j) where lastTouches is the value of the touches attribute of the last received touch event.

Precondition: the element is listening to ALL touch events

Y Y
1.5.2.4 For any touchend or touchcancel event object, each item in changedTouches must NOT appear in touches

In other words, for i where 0 ≤ i ≤ changedTouches.length-1, there must not exist j where 0 ≤ j ≤ touches.length-1 such that changedTouches.item(i).identifier == touches.item(j).identifier

Y
1.5.2.5 For any touchend or touchcancel event object, each item in changedTouches must NOT appear in targetTouches

In other words, for i where 0 ≤ i ≤ changedTouches.length-1, there must not exist j where 0 ≤ j ≤ targetTouches.length-1 such that changedTouches.item(i).identifier == targetTouches.item(j).identifier

Y
1.5.2.6 For any touchend or touchcancel event object, the target attribute of at least one item in changedTouches must be the element receiving the event Y Y
targetTouches 1.5.3.1 For any touchend or touchcancel event object, targetTouches.length == 0 Y
1.5.3.2 For any touchend or touchcancel event object, 0 ≤ targetTouches.length ≤ touches.length Y
1.5.3.3 For any touchend or touchcancel event object, each item in targetTouches must also appear in touches

In other words, for i where 0 ≤ i ≤ targetTouches.length-1, there exists j where 0 ≤ j ≤ touches.length-1 such that targetTouches.item(i).identifier == touches.item(j).identifier

Y
1.5.3.4 For any touchend or touchcancel event object, targetTouches.length must be smaller than the targetTouches.length value in the last received touch event. Additionally, the difference must be ≤ changedTouches.length

Precondition: the element is listening to ALL touch events

Y
touches 1.5.4.1 For any touchend or touchcancel event object, touches.length == 0 Y
1.5.4.2 For any touchend or touchcancel event object, touches.length must be smaller than the touches.length value of the last received touch event. Additionally, the different must be == changedTouches.length

Precondition: the element is listening to ALL touch events

Y

Test Assertions on relationship between touch events

Assertion Applies to Single-touch Applies to Multi-touch
1.6.1 The first received touch event must be a touchstart event

Precondition: the element is listening to ALL touch events

Y Y
1.6.2 The element at which a Touch starts must receive the touchstart event that includes that Touch in changedTouches

Precondition: the element is listening to touchstart events

Y Y
1.6.3 The element at which a Touch starts must receive all subsequent touchmove events that include that Touch in changedTouches

Precondition: the element is listening to touchmove events

Y Y
1.6.4 The element at which a Touch starts must receive the touchend or touchcancel event that includes that Touch in changedTouches

Precondition: the element is listening to touchend and touchcancel events

Y Y

TO DO

The following areas are yet to be covered:

  • createTouch and createTouchList methods
  • interaction with mouse events
  • use of preventDefault