test/touchevents/single-touch.html
branchv1
changeset 101 2d830a098494
parent 91 b2c4ba0eb943
equal deleted inserted replaced
100:4bbe000815dd 101:2d830a098494
    33         test_touchstart.done();
    33         test_touchstart.done();
    34         test_mousedown.done(); // If we got here, then the mouse event test is not needed.
    34         test_mousedown.done(); // If we got here, then the mouse event test is not needed.
    35 
    35 
    36         test(function() {
    36         test(function() {
    37           assert_true(ev.target instanceof Element, "target must be an Element.");
    37           assert_true(ev.target instanceof Element, "target must be an Element.");
    38           assert_equals(ev.relatedTarget, null, "relatedTarget must be null for touchstart event.");
       
    39         }, "touchstart TouchEvent target attributes are correct.");
    38         }, "touchstart TouchEvent target attributes are correct.");
    40 
    39 
    41         test(function() {
    40         test(function() {
    42           var attrs = ["altKey", "metaKey", "ctrlKey", "shiftKey"];
    41           var attrs = ["altKey", "metaKey", "ctrlKey", "shiftKey"];
    43           for (var i = 0; i < attrs.length; i++) {
    42           for (var i = 0; i < attrs.length; i++) {
    68         }, "Touch identifiers are consistent.");
    67         }, "Touch identifiers are consistent.");
    69 
    68 
    70         test(function() {
    69         test(function() {
    71           assert_equals(ev.touches.identifiedTouch(touchstart_identifier), t, "touches.identifiedTouch is correct.");
    70           assert_equals(ev.touches.identifiedTouch(touchstart_identifier), t, "touches.identifiedTouch is correct.");
    72         }, "identifiedTouch");
    71         }, "identifiedTouch");
    73 
       
    74         test(function() {
       
    75           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
       
    76           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
       
    77 
       
    78           assert_true(t.radiusX > 0, "radiusX is positive.");
       
    79           assert_true(t.radiusY > 0, "radiusY is positive.");
       
    80 
       
    81           assert_true(t.force >= 0, "force >= 0.");
       
    82           assert_true(t.force <= 1, "force <= 1.");
       
    83         }, "Touch attribute values are valid");
       
    84 
    72 
    85         test(function() {
    73         test(function() {
    86           var attrs = ["screenX", "screenY", "clientX", "clientY",
    74           var attrs = ["screenX", "screenY", "clientX", "clientY",
    87                        "pageX", "pageY"];
    75                        "pageX", "pageY"];
    88           for (var i = 0; i < attrs.length; i++) {
    76           for (var i = 0; i < attrs.length; i++) {
   151         test(function() {
   139         test(function() {
   152           assert_equals(t.identifier, touchstart_identifier, "changedTouches identifier matches.");
   140           assert_equals(t.identifier, touchstart_identifier, "changedTouches identifier matches.");
   153         }, "touchend identifier matches.");
   141         }, "touchend identifier matches.");
   154 
   142 
   155         test(function() {
   143         test(function() {
   156           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
       
   157           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
       
   158 
       
   159           assert_true(t.radiusX > 0, "radiusX is positive.");
       
   160           assert_true(t.radiusY > 0, "radiusY is positive.");
       
   161 
       
   162           assert_true(t.force >= 0, "force >= 0.");
       
   163           assert_true(t.force <= 1, "force <= 1.");
       
   164         }, "Touch attribute values are valid");
       
   165 
       
   166         test(function() {
       
   167           var attrs = ["screenX", "screenY", "clientX", "clientY",
   144           var attrs = ["screenX", "screenY", "clientX", "clientY",
   168                        "pageX", "pageY"];
   145                        "pageX", "pageY"];
   169           for (var i = 0; i < attrs.length; i++) {
   146           for (var i = 0; i < attrs.length; i++) {
   170             assert_true(attrs[i] in t);
   147             assert_true(attrs[i] in t);
   171           }
   148           }