tests/touch-events-v1/approved/multi-touch-interfaces.html
author Cathy Chan <cathy.chan@nokia.com>
Tue, 22 Jan 2013 13:28:15 -0500
changeset 177 19c6f3d0eb8a
parent 167 418583839ba5
permissions -rw-r--r--
Removed TouchList.identifiedTouch.
Fixed a few typos.
165
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     1
<!DOCTYPE HTML>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     2
<html>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     3
<!-- 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     4
     Test cases for Touch Events v1 Candiate Recommendation
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     5
     http://www.w3.org/TR/2011/CR-touch-events-20111215/
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     6
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     7
     These tests are based on Mozilla-Nokia-Google's single-touch tests and to some extent Olli Pettay's multi-touch tests. 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     8
	 http://w3c-test.org/webevents/tests/touch-events-v1/submissions/Moz-Nok-Goog/single-touch.html
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     9
     http://w3c-test.org/webevents/tests/touch-events-v1/submissions/Mozilla/multi-touch.html
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    10
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    11
	 The primary purpose of the tests in this document is checking that the various interfaces of the Touch Events APIs are correctly implemented.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    12
	 Other interactions are covered in other test files.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    13
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    14
     This document references Test Assertions (abbrev TA below) written by Cathy Chan
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    15
     http://www.w3.org/2010/webevents/wiki/TestAssertions
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    16
-->
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    17
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    18
<head>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    19
<title>Touch Events Multi-Touch Interface Tests</title>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    20
<meta name="viewport" content="width=device-width">
167
418583839ba5 Change path to testharness.js to use version in /resources/
Art Barstow <art.barstow@nokia.com>
parents: 165
diff changeset
    21
<script src="/resources/testharness.js"></script>
165
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    22
<script>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    23
    setup({explicit_done: true});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    24
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    25
    // Check a Touch object's atttributes for existence and correct type
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    26
    // TA: 1.1.2, 1.1.3
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    27
    function check_Touch_object (t) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    28
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    29
           assert_equals(Object.prototype.toString.call(t), "[object Touch]", "touch is of type Touch");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    30
        }, "touch point is a Touch object");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    31
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    32
          ["long", "identifier"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    33
          ["EventTarget", "target"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    34
          ["long", "screenX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    35
          ["long", "screenY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    36
          ["long", "clientX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    37
          ["long", "clientY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    38
          ["long", "pageX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    39
          ["long", "pageY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    40
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    41
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    42
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    43
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    44
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    45
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    46
                assert_true(name in t, name + " attribute in Touch object");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    47
            }, "Touch." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    48
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    49
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    50
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    51
            case "long":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    52
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    53
                    assert_equals(typeof t[name], "number", name + " attribute of type long");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    54
                }, "Touch." + name + " attribute is of type number (long)");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    55
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    56
            case "EventTarget":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    57
                // An event target is some type of Element
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    58
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    59
                    assert_true(t[name] instanceof Element, "EventTarget must be an Element.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    60
                }, "Touch." + name + " attribute is of type Element");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    61
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    62
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    63
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    64
            }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    65
       }); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    66
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    67
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    68
    // Check a TouchList object's attributes and methods for existence and proper type
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    69
    // Also make sure all of the members of the list are Touch objects
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    70
    // TA: 1.2.1, 1.2.2, 1.2.5, 1.2.6
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    71
    function check_TouchList_object (tl) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    72
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    73
           assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", "touch list is of type TouchList");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    74
        }, "touch list is a TouchList object");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    75
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    76
          ["unsigned long", "length"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    77
          ["function", "item"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    78
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    79
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    80
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    81
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    82
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    83
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    84
                assert_true(name in tl, name + " attribute in TouchList");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    85
            }, "TouchList." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    86
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    87
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    88
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    89
            case "unsigned long":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    90
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    91
                    assert_equals(typeof tl[name], "number", name + " attribute of type long");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    92
                }, "TouchList." + name + " attribute is of type number (unsigned long)");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    93
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    94
            case "function":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    95
                test(function() {
177
19c6f3d0eb8a Removed TouchList.identifiedTouch.
Cathy Chan <cathy.chan@nokia.com>
parents: 167
diff changeset
    96
                    assert_equals(typeof tl[name], "function", name + " attribute of type function");
165
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    97
                }, "TouchList." + name + " attribute is of type function");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    98
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    99
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   100
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   101
            }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   102
       }); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   103
       // Each member of tl should be a proper Touch object
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   104
       for (var i=0; i < tl.length; i++) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   105
           check_Touch_object(tl.item(i));
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   106
       }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   107
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   108
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   109
    // Check a TouchEvent event's attributes for existence and proper type
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   110
    // Also check that each of the event's TouchList objects are valid
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   111
    // TA: 1.{3,4,5}.1.1, 1.{3,4,5}.1.2
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   112
    function check_TouchEvent(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   113
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   114
           assert_true(ev instanceof TouchEvent, "event is a TouchEvent event");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   115
        }, ev.type + " event is a TouchEvent event");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   116
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   117
          ["TouchList", "touches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   118
          ["TouchList", "targetTouches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   119
          ["TouchList", "changedTouches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   120
          ["boolean", "altKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   121
          ["boolean", "metaKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   122
          ["boolean", "ctrlKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   123
          ["boolean", "shiftKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   124
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   125
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   126
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   127
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   128
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   129
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   130
                assert_true(name in ev, name + " attribute in " + ev.type + " event");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   131
            }, ev.type + "." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   132
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   133
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   134
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   135
            case "boolean":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   136
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   137
                    assert_equals(typeof ev[name], "boolean", name + " attribute of type boolean");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   138
                }, ev.type + "." + name + " attribute is of type boolean");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   139
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   140
            case "TouchList":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   141
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   142
                    assert_equals(Object.prototype.toString.call(ev[name]), "[object TouchList]", name + " attribute of type TouchList");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   143
                }, ev.type + "." + name + " attribute is of type TouchList");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   144
                // Now check the validity of the TouchList
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   145
                check_TouchList_object(ev[name]);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   146
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   147
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   148
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   149
            }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   150
       }); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   151
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   152
    
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   153
    function is_touch_over_element(touch, element) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   154
      var bounds = element.getBoundingClientRect();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   155
      return touch.pageX >= bounds.left && touch.pageX <= bounds.right &&
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   156
          touch.pageY >= bounds.top && touch.pageY <= bounds.bottom;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   157
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   158
    
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   159
    function check_touch_clientXY(touch) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   160
      assert_equals(touch.clientX, touch.pageX - window.pageXOffset, "touch.clientX is touch.pageX - window.pageXOffset.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   161
      assert_equals(touch.clientY, touch.pageY - window.pageYOffset, "touch.clientY is touch.pageY - window.pageYOffset.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   162
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   163
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   164
    function run() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   165
		var target0 = document.getElementById("target0");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   166
		var target1 = document.getElementById("target1");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   167
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   168
		var test_touchstart = async_test("touchstart event received");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   169
		var test_touchmove = async_test("touchmove event received");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   170
		var test_touchend = async_test("touchend event received");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   171
		var test_mousedown = async_test("Interaction with mouse events");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   172
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   173
		var touchstart_received = 0;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   174
		var touchmove_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   175
		var touchend_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   176
		var invalid_touchmove_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   177
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   178
		on_event(target0, "touchstart", function onTouchStart(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   179
			ev.preventDefault();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   180
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   181
			if(!touchstart_received) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   182
				// Check event ordering TA: 1.6.2
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   183
				test_touchstart.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   184
					assert_false(touchmove_received, "touchstart precedes touchmove");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   185
					assert_false(touchend_received, "touchstart precedes touchend");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   186
				});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   187
				test_touchstart.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   188
				test_mousedown.done(); // If we got here, then the mouse event test is not needed.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   189
			}
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   190
			
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   191
			if(++touchstart_received <= 2)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   192
				check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   193
		});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   194
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   195
		on_event(target0, "touchmove", function onTouchMove(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   196
			ev.preventDefault();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   197
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   198
			if (touchmove_received)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   199
			  return;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   200
			touchmove_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   201
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   202
			test_touchmove.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   203
				assert_true(touchstart_received>0, "touchmove follows touchstart");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   204
				assert_false(touchend_received, "touchmove precedes touchend");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   205
			});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   206
			test_touchmove.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   207
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   208
			check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   209
		});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   210
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   211
		on_event(target1, "touchmove", function onTouchMove(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   212
			invalid_touchmove_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   213
		});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   214
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   215
		on_event(window, "touchend", function onTouchEnd(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   216
			touchend_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   217
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   218
			test_touchend.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   219
				assert_true(touchstart_received>0, "touchend follows touchstart");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   220
				assert_true(touchmove_received, "touchend follows touchmove");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   221
				assert_false(invalid_touchmove_received, "touchmove dispatched to correct target");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   222
			});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   223
			test_touchend.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   224
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   225
			check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   226
			done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   227
		});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   228
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   229
		on_event(target0, "mousedown", function onMouseDown(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   230
			test_mousedown.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   231
				assert_true(touchstart_received,
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   232
					"The touchstart event must be dispatched before any mouse " +
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   233
					"events. (If this fails, it might mean that the user agent does " +
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   234
					"not implement W3C touch events at all.)"
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   235
				);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   236
			});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   237
			test_mousedown.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   238
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   239
			if (!touchstart_received) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   240
				// Abort the tests.  If touch events are not supported, then most of
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   241
				// the other event handlers will never be called, and the test will
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   242
				// time out with misleading results.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   243
				done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   244
			}
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   245
		});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   246
	}
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   247
</script>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   248
<style>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   249
	div {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   250
		margin: 0em;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   251
		padding: 2em;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   252
	}
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   253
	#target0 {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   254
		background: yellow;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   255
		border: 1px solid orange;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   256
	}
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   257
	#target1 {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   258
		background: lightblue;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   259
		border: 1px solid blue;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   260
	}
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   261
</style>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   262
</head>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   263
<body onload="run()">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   264
	<h1>Touch Events: multi-touch interface tests</h1>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   265
	<div id="target0">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   266
		Touch this box with one finger, then another one...
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   267
	</div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   268
	<div id="target1">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   269
		...then drag to this box and lift your fingers.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   270
	</div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   271
	<div id="log"></div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   272
</body>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   273
</html>