tests/touch-events-v1/approved/single-touch.html
author Cathy Chan <cathy.chan@nokia.com>
Tue, 22 Jan 2013 13:52:20 -0500
changeset 179 7cd6d8c1e3bc
parent 177 19c6f3d0eb8a
permissions -rw-r--r--
Updated single-touch test file to remove createTouch and createTouchList tests,
which are now covered in create-touch-touchlist test file.
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 Matt Bruebeck's single-touch tests. 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
     8
     There are NO multi-touch tests in this document.
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/single-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
     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
    12
     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
    13
-->
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    14
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    15
<head>
179
7cd6d8c1e3bc Updated single-touch test file to remove createTouch and createTouchList tests,
Cathy Chan <cathy.chan@nokia.com>
parents: 177
diff changeset
    16
  <title>Touch Events Single Touch Tests</title>
165
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    17
  <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
    18
  <script src="/resources/testharness.js"></script>
165
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    19
  <script>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    20
    setup({explicit_done: true});
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    21
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    22
    // 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
    23
    // TA: 1.1.2, 1.1.3
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    24
    function check_Touch_object (t) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    25
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    26
           assert_equals(Object.prototype.toString.call(t), "[object Touch]", name + " attribute of type TouchList");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    27
        }, "touch point is a Touch object");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    28
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    29
          ["long", "identifier"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    30
          ["EventTarget", "target"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    31
          ["long", "screenX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    32
          ["long", "screenY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    33
          ["long", "clientX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    34
          ["long", "clientY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    35
          ["long", "pageX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    36
          ["long", "pageY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    37
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    38
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    39
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    40
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    41
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    42
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    43
                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
    44
            }, "Touch." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    45
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    46
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    47
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    48
            case "long":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    49
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    50
                    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
    51
                }, "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
    52
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    53
            case "EventTarget":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    54
                // 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
    55
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    56
                    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
    57
                }, "Touch." + name + " attribute is of type Element");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    58
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    59
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    60
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    61
            }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    62
       }); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    63
    }
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
    // 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
    66
    // 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
    67
    // TA: 1.2.1, 1.2.2, 1.2.5
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    68
    function check_TouchList_object (tl) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    69
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    70
           assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", name + " attribute of type TouchList");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    71
        }, "touch list is a TouchList object");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    72
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    73
          ["unsigned long", "length"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    74
          ["function", "item"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    75
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    76
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    77
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    78
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    79
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    80
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    81
                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
    82
            }, "TouchList." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    83
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    84
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    85
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    86
            case "unsigned long":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    87
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    88
                    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
    89
                }, "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
    90
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    91
            case "function":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    92
                test(function() {
177
19c6f3d0eb8a Removed TouchList.identifiedTouch.
Cathy Chan <cathy.chan@nokia.com>
parents: 167
diff changeset
    93
                    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
    94
                }, "TouchList." + name + " attribute is of type function");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    95
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    96
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    97
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    98
            }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    99
       }); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   100
       // 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
   101
       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
   102
           check_Touch_object(tl.item(i));
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   103
       }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   104
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   105
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   106
    // 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
   107
    // 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
   108
    // 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
   109
    function check_TouchEvent(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   110
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   111
           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
   112
        }, ev.type + " event is a TouchEvent event");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   113
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   114
          ["TouchList", "touches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   115
          ["TouchList", "targetTouches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   116
          ["TouchList", "changedTouches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   117
          ["boolean", "altKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   118
          ["boolean", "metaKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   119
          ["boolean", "ctrlKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   120
          ["boolean", "shiftKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   121
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   122
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   123
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   124
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   125
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   126
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   127
                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
   128
            }, ev.type + "." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   129
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   130
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   131
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   132
            case "boolean":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   133
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   134
                    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
   135
                }, 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
   136
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   137
            case "TouchList":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   138
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   139
                    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
   140
                }, 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
   141
                // Now check the validity of the TouchList
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   142
                check_TouchList_object(ev[name]);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   143
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   144
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   145
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   146
            }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   147
       }); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   148
    }
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
    function is_touch_over_element(touch, element) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   151
      var bounds = element.getBoundingClientRect();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   152
      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
   153
          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
   154
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   155
    
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   156
    function check_touch_clientXY(touch) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   157
      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
   158
      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
   159
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   160
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   161
    function run() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   162
      var target0 = document.getElementById("target0");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   163
      var target1 = document.getElementById("target1");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   164
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   165
      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
   166
      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
   167
      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
   168
      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
   169
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   170
      var touchstart_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   171
      var touchmove_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   172
      var touchend_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   173
      var invalid_touchmove_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   174
      var touchstart_identifier;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   175
      
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   176
      on_event(target0, "touchstart", function onTouchStart(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   177
        ev.preventDefault();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   178
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   179
        // Check event ordering TA: 1.6.2
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   180
        test_touchstart.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   181
          assert_false(touchstart_received, "duplicate touchstart event");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   182
          assert_false(touchmove_received, "touchstart precedes touchmove");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   183
          assert_false(touchend_received, "touchstart precedes touchend");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   184
        });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   185
        test_touchstart.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   186
        if (touchstart_received)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   187
          return;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   188
        touchstart_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   189
        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
   190
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   191
        check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   192
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   193
        // TA: 1.3.2.1, 1.3.3.1, 1.3.4.1
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   194
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   195
          assert_equals(ev.touches.length, 1, "One touch point.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   196
          assert_equals(ev.changedTouches.length, 1, "One changed touch point.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   197
          assert_equals(ev.targetTouches.length, 1, "One target touch point.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   198
        }, "touchstart: all TouchList lengths are correct");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   199
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   200
        var t = ev.touches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   201
        var ct = ev.changedTouches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   202
        var tt = ev.targetTouches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   203
        
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   204
        touchstart_identifier = t.identifier;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   205
        // TA: 1.3.3.3, 1.3.2.3, 1.3.3.4 (indirect (transitive))
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   206
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   207
          assert_equals(ct.identifier, touchstart_identifier, "changedTouches identifier matches.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   208
          assert_equals(tt.identifier, touchstart_identifier, "targetTouches identifier matches.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   209
        }, "touchstart: all TouchList identifiers are consistent");
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
        // TA: 1.3.3.9
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   212
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   213
          assert_equals(tt.target, ev.target, "event target same as targetTouches target.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   214
        }, "touchstart: event target same as targetTouches target");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   215
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   216
        // TA: @TBD
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   217
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   218
          assert_true(is_touch_over_element(t, target0), "touch.pageX/pageY is over target0.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   219
        }, "touchstart: touch pageX/pageY inside of target element");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   220
        test(function() { 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   221
          check_touch_clientXY(t); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   222
        }, "touchstart: touch clientX/clientY is consistent with pageX/pageY");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   223
        // Note we don't bother testing screenX/screenY values - there's no reliable way to
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   224
        // verify they are consistent with clientX/clientY (due to unknown amount of window
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   225
        // chrome), and also various forms of scaling mean they are in different units.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   226
      });
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
      on_event(target0, "touchmove", function onTouchMove(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   229
        ev.preventDefault();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   230
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   231
        if (touchmove_received)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   232
          return;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   233
        touchmove_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   234
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   235
        test_touchmove.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   236
          assert_true(touchstart_received, "touchmove follows touchstart");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   237
          assert_false(touchend_received, "touchmove precedes touchend");
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
        test_touchmove.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   240
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   241
        check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   242
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   243
        // TA: 1.4.2.1, 1.4.3.1
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   244
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   245
          assert_equals(ev.touches.length, 1, "One touch point.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   246
          assert_equals(ev.changedTouches.length, 1, "One changed touch point.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   247
          assert_equals(ev.targetTouches.length, 1, "One target touch point.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   248
        }, "touchmove: all TouchList lengths are correct");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   249
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   250
        // 1.4.2.3, 1.4.3.3, 1.4.3.5, 1.4.4.3
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   251
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   252
          assert_equals(ev.touches[0].identifier, touchstart_identifier, "Touch identifier matches.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   253
          assert_equals(ev.changedTouches[0].identifier, touchstart_identifier, "Changed touch identifier matches.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   254
          assert_equals(ev.targetTouches[0].identifier, touchstart_identifier, "Target touch identifier matches.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   255
        }, "touchmove: all TouchList identifiers matches touchstart identifier");
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
        // TA: 1.4.3.8
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   258
        var tt = ev.targetTouches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   259
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   260
          assert_equals(tt.target, ev.target, "event target same as targetTouches target.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   261
        }, "touchmove: event target same as targetTouches target");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   262
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   263
        // TA: @TBD
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   264
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   265
          assert_true(is_touch_over_element(tt, target0) || is_touch_over_element(tt, target1),
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   266
            "touch.pageX/pageY is over one of the targets.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   267
        }, "touchmove: touch pageX/pageY inside of one of the target elements");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   268
        test(function() { 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   269
          check_touch_clientXY(tt); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   270
        }, "touchmove: touch clientX/clientY is consistent with pageX/pageY");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   271
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   272
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   273
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   274
      on_event(target1, "touchmove", function onTouchMove(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   275
        invalid_touchmove_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   276
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   277
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   278
      on_event(window, "touchend", function onTouchEnd(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   279
        touchend_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   280
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   281
        test_touchend.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   282
          assert_equals(ev.target, target0, "touchend is dispatched to the original target");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   283
          assert_true(touchstart_received, "touchend follows touchstart");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   284
          assert_true(touchmove_received, "touchend follows touchmove");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   285
          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
   286
        });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   287
        test_touchend.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   288
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   289
        check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   290
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   291
        // TA: 1.5.1.2, 1.5.3.1, 1.5.4.1
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   292
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   293
          assert_equals(ev.touches.length, 0, "Zero touch points.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   294
          assert_equals(ev.changedTouches.length, 1, "One changed touch point.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   295
          assert_equals(ev.targetTouches.length, 0, "Zero target touch points.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   296
        }, "touchend: all TouchList lengths are correct");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   297
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   298
        var t = ev.changedTouches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   299
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   300
        // TA: 1.5.2.6, 1.5.2.3
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   301
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   302
          assert_equals(t.identifier, touchstart_identifier, "changedTouches identifier matches.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   303
        }, "touchend: touches identifier matches changedTouches identifier");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   304
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   305
        // TA: @TBD
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   306
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   307
          assert_true(is_touch_over_element(t, target1),
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   308
            "touch.pageX/pageY is over target1.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   309
        }, "touchend: touch pageX/pageY inside expected element");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   310
        test(function() { 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   311
          check_touch_clientXY(t); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   312
        }, "touchend: touch clientX/clientY is consistent with pageX/pageY");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   313
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   314
        done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   315
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   316
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   317
      on_event(target0, "mousedown", function onMouseDown(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   318
        test_mousedown.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   319
          assert_true(touchstart_received,
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   320
            "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
   321
            "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
   322
            "not implement W3C touch events at all.)"
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   323
          );
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   324
        });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   325
        test_mousedown.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   326
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   327
        if (!touchstart_received) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   328
          // 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
   329
          // 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
   330
          // time out with misleading results.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   331
          done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   332
        }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   333
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   334
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   335
  </script>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   336
  <style>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   337
    div {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   338
      margin: 0em;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   339
      padding: 2em;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   340
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   341
    #target0 {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   342
      background: yellow;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   343
      border: 1px solid orange;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   344
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   345
    #target1 {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   346
      background: lightblue;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   347
      border: 1px solid blue;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   348
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   349
  </style>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   350
</head>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   351
<body onload="run()">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   352
  <h1>Touch Events: single-touch tests</h1>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   353
  <div id="target0">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   354
    Touch this box with one finger (or other pointing device)...
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   355
  </div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   356
  <div id="target1">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   357
    ...then drag to this box and lift your finger.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   358
  </div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   359
  <div id="log"></div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   360
</body>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   361
</html>