tests/touch-events-v1/approved/single-touch.html
author Art Barstow <art.barstow@nokia.com>
Sat, 08 Dec 2012 17:02:45 -0500
changeset 165 5a5df40e3cbf
child 167 418583839ba5
permissions -rw-r--r--
Approved test files copied to approved directory
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>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    16
  <title>Touch Events tests (based on Matt Brubeck's single-touch tests)</title>
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">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    18
  <script src="../../../testharness.js"></script>
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
    var hasIdentifiedTouch = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    23
    
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    24
    // 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
    25
    // TA: 1.1.2, 1.1.3
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    26
    function check_Touch_object (t) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    27
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    28
           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
    29
        }, "touch point is a Touch object");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    30
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    31
          ["long", "identifier"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    32
          ["EventTarget", "target"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    33
          ["long", "screenX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    34
          ["long", "screenY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    35
          ["long", "clientX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    36
          ["long", "clientY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    37
          ["long", "pageX"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    38
          ["long", "pageY"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    39
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    40
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    41
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    42
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    43
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    44
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    45
                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
    46
            }, "Touch." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    47
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    48
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    49
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    50
            case "long":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    51
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    52
                    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
    53
                }, "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
    54
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    55
            case "EventTarget":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    56
                // 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
    57
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    58
                    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
    59
                }, "Touch." + name + " attribute is of type Element");
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
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    62
                break;
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
    }
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
    // 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
    68
    // 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
    69
    // 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
    70
    function check_TouchList_object (tl) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    71
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    72
           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
    73
        }, "touch list is a TouchList object");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    74
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    75
          ["unsigned long", "length"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    76
          ["function", "item"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    77
          ["function", "identifiedTouch"],
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
            if (name == "identifiedTouch" && !hasIdentifiedTouch)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    83
              return;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    84
              
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    85
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    86
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    87
                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
    88
            }, "TouchList." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    89
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    90
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    91
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    92
            case "unsigned long":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    93
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    94
                    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
    95
                }, "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
    96
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    97
            case "function":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    98
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
    99
                    assert_equals(typeof tl[name], "function", name + " attribute of type long");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   100
                }, "TouchList." + name + " attribute is of type function");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   101
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   102
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   103
                break;
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
       // 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
   107
       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
   108
           check_Touch_object(tl.item(i));
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   109
       }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   110
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   111
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   112
    // 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
   113
    // 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
   114
    // 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
   115
    function check_TouchEvent(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   116
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   117
           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
   118
        }, ev.type + " event is a TouchEvent event");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   119
        [
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   120
          ["TouchList", "touches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   121
          ["TouchList", "targetTouches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   122
          ["TouchList", "changedTouches"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   123
          ["boolean", "altKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   124
          ["boolean", "metaKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   125
          ["boolean", "ctrlKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   126
          ["boolean", "shiftKey"],
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   127
        ].forEach(function(attr) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   128
            var type = attr[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   129
            var name = attr[1];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   130
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   131
            // existence check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   132
            test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   133
                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
   134
            }, ev.type + "." + name + " attribute exists");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   135
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   136
            // type check
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   137
            switch(type) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   138
            case "boolean":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   139
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   140
                    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
   141
                }, 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
   142
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   143
            case "TouchList":
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   144
                test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   145
                    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
   146
                }, 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
   147
                // Now check the validity of the TouchList
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   148
                check_TouchList_object(ev[name]);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   149
                break;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   150
            default:
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   151
                break;
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
       }); 
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 is_touch_over_element(touch, element) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   157
      var bounds = element.getBoundingClientRect();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   158
      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
   159
          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
   160
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   161
    
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   162
    function check_touch_clientXY(touch) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   163
      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
   164
      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
   165
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   166
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   167
    function run() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   168
      var target0 = document.getElementById("target0");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   169
      var target1 = document.getElementById("target1");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   170
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   171
      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
   172
      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
   173
      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
   174
      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
   175
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   176
      var touchstart_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   177
      var touchmove_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   178
      var touchend_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   179
      var invalid_touchmove_received = false;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   180
      var touchstart_identifier;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   181
      
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   182
      var touch;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   183
      test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   184
        touch = document.createTouch(window, target0, 42, 15, 20, 35, 40);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   185
        assert_equals(touch.target, target0, "touch.target is target0");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   186
        assert_equals(touch.identifier, 42, "touch.identifier is requested value");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   187
        assert_equals(touch.pageX, 15, "touch.pageX is requested value");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   188
        assert_equals(touch.pageY, 20, "touch.pageY is requested value");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   189
        check_touch_clientXY(touch);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   190
        assert_equals(touch.screenX, 35, "touch.screenX is requested value");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   191
        assert_equals(touch.screenY, 40, "touch.screenY is requested value");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   192
      }, "document.createTouch exists and creates a Touch object with requested properties");
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
      var touchList;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   195
      test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   196
        touchList = document.createTouchList(touch);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   197
        assert_equals(touchList.length, 1, "touchList.length is 1");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   198
        assert_equals(touchList.item(0), touch, "touchList.item(0) is input touch");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   199
      }, "document.createTouchList exists and correctly creates a TouchList from a single Touch");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   200
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   201
      test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   202
        // A common failure mode (eg. WebKit bug 96294), don't report multiple errors for it
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   203
        hasIdentifiedTouch = 'identifiedTouch' in touchList;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   204
        assert_true(hasIdentifiedTouch);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   205
      }, "TouchList contains an identifiedTouch property");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   206
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   207
      if (touchList)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   208
        check_TouchList_object(touchList);
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
      test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   211
        touchList = document.createTouchList([touch]);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   212
        assert_equals(touchList.length, 1, "touchList.length is 1");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   213
        assert_equals(touchList.item(0), touch, "touchList.item(0) is input touch");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   214
      }, "document.createTouchList exists and correctly creates a TouchList from a Touch array");
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
      on_event(target0, "touchstart", function onTouchStart(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   217
        ev.preventDefault();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   218
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   219
        // Check event ordering TA: 1.6.2
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   220
        test_touchstart.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   221
          assert_false(touchstart_received, "duplicate touchstart event");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   222
          assert_false(touchmove_received, "touchstart precedes touchmove");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   223
          assert_false(touchend_received, "touchstart precedes touchend");
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
        test_touchstart.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   226
        if (touchstart_received)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   227
          return;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   228
        touchstart_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   229
        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
   230
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   231
        check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   232
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   233
        // 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
   234
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   235
          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
   236
          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
   237
          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
   238
        }, "touchstart: all TouchList lengths are correct");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   239
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   240
        var t = ev.touches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   241
        var ct = ev.changedTouches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   242
        var tt = ev.targetTouches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   243
        
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   244
        touchstart_identifier = t.identifier;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   245
        // 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
   246
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   247
          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
   248
          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
   249
        }, "touchstart: all TouchList identifiers are consistent");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   250
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   251
        // TA: 1.3.3.9
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   252
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   253
          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
   254
        }, "touchstart: event target same as targetTouches target");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   255
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   256
        // TA: @TBD
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   257
        if (hasIdentifiedTouch) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   258
          test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   259
            assert_equals(ev.touches.identifiedTouch(touchstart_identifier), t, "touches.identifiedTouch is correct.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   260
          }, "touchstart: touches.identifiedTouch same as first touch point id");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   261
        }
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(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
   266
        }, "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
   267
        test(function() { 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   268
          check_touch_clientXY(t); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   269
        }, "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
   270
        // 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
   271
        // 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
   272
        // 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
   273
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   274
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   275
      on_event(target0, "touchmove", function onTouchMove(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   276
        ev.preventDefault();
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
        if (touchmove_received)
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   279
          return;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   280
        touchmove_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   281
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   282
        test_touchmove.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   283
          assert_true(touchstart_received, "touchmove follows touchstart");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   284
          assert_false(touchend_received, "touchmove precedes touchend");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   285
        });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   286
        test_touchmove.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   287
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   288
        check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   289
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   290
        // 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
   291
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   292
          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
   293
          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
   294
          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
   295
        }, "touchmove: all TouchList lengths are correct");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   296
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   297
        // 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
   298
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   299
          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
   300
          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
   301
          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
   302
        }, "touchmove: all TouchList identifiers matches touchstart identifier");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   303
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   304
        // TA: 1.4.3.8
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   305
        var tt = ev.targetTouches[0];
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_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
   308
        }, "touchmove: event target same as targetTouches target");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   309
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   310
        // TA: @TBD
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   311
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   312
          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
   313
            "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
   314
        }, "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
   315
        test(function() { 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   316
          check_touch_clientXY(tt); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   317
        }, "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
   318
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   319
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   320
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   321
      on_event(target1, "touchmove", function onTouchMove(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   322
        invalid_touchmove_received = true;
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
      on_event(window, "touchend", function onTouchEnd(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   326
        touchend_received = true;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   327
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   328
        test_touchend.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   329
          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
   330
          assert_true(touchstart_received, "touchend follows touchstart");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   331
          assert_true(touchmove_received, "touchend follows touchmove");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   332
          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
   333
        });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   334
        test_touchend.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   335
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   336
        check_TouchEvent(ev);
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   337
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   338
        // 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
   339
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   340
          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
   341
          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
   342
          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
   343
        }, "touchend: all TouchList lengths are correct");
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
        var t = ev.changedTouches[0];
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   346
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   347
        // 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
   348
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   349
          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
   350
        }, "touchend: touches identifier matches changedTouches identifier");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   351
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   352
        // TA: @TBD
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   353
        test(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   354
          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
   355
            "touch.pageX/pageY is over target1.");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   356
        }, "touchend: touch pageX/pageY inside expected element");
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   357
        test(function() { 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   358
          check_touch_clientXY(t); 
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   359
        }, "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
   360
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   361
        done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   362
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   363
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   364
      on_event(target0, "mousedown", function onMouseDown(ev) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   365
        test_mousedown.step(function() {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   366
          assert_true(touchstart_received,
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   367
            "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
   368
            "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
   369
            "not implement W3C touch events at all.)"
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   370
          );
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   371
        });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   372
        test_mousedown.done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   373
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   374
        if (!touchstart_received) {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   375
          // 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
   376
          // 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
   377
          // time out with misleading results.
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   378
          done();
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   379
        }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   380
      });
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   381
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   382
  </script>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   383
  <style>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   384
    div {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   385
      margin: 0em;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   386
      padding: 2em;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   387
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   388
    #target0 {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   389
      background: yellow;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   390
      border: 1px solid orange;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   391
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   392
    #target1 {
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   393
      background: lightblue;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   394
      border: 1px solid blue;
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   395
    }
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   396
  </style>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   397
</head>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   398
<body onload="run()">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   399
  <h1>Touch Events: single-touch tests</h1>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   400
  <div id="target0">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   401
    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
   402
  </div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   403
  <div id="target1">
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   404
    ...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
   405
  </div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   406
  <div id="log"></div>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   407
</body>
5a5df40e3cbf Approved test files copied to approved directory
Art Barstow <art.barstow@nokia.com>
parents:
diff changeset
   408
</html>