test/touchevents/single-touch.html
changeset 56 6343517cbbee
parent 55 7df98116715b
child 88 dcdef856c426
equal deleted inserted replaced
55:7df98116715b 56:6343517cbbee
    18 
    18 
    19       var touchstart_received = false;
    19       var touchstart_received = false;
    20       var touchmove_received = false;
    20       var touchmove_received = false;
    21       var touchend_received = false;
    21       var touchend_received = false;
    22       var invalid_touchmove_received = false;
    22       var invalid_touchmove_received = false;
       
    23       var touchstart_identifier;
    23 
    24 
    24       on_event(target0, "touchstart", function onTouchStart(ev) {
    25       on_event(target0, "touchstart", function onTouchStart(ev) {
    25         ev.preventDefault();
    26         ev.preventDefault();
    26 
    27 
    27         touchstart_received = true;
    28         touchstart_received = true;
    64           assert_equals(t.identifier, 0, "touches identifier is 0.");
    65           assert_equals(t.identifier, 0, "touches identifier is 0.");
    65           assert_equals(ct.identifier, 0, "changedTouches identifier is 0.");
    66           assert_equals(ct.identifier, 0, "changedTouches identifier is 0.");
    66           assert_equals(tt.identifier, 0, "targetTouches identifier is 0.");
    67           assert_equals(tt.identifier, 0, "targetTouches identifier is 0.");
    67         }, "Touch identifiers are correct.");
    68         }, "Touch identifiers are correct.");
    68 
    69 
       
    70         touchstart_identifier = t.identifier;
       
    71         test(function() {
       
    72           assert_equals(ev.touches.identifiedTouch(touchstart_identifier), t, "touches.identifiedTouch is correct.");
       
    73         }, "identifiedTouch");
       
    74 
    69         test(function() {
    75         test(function() {
    70           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
    76           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
    71           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
    77           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
    72 
    78 
    73           assert_true(t.radiusX > 0, "radiusX is positive.");
    79           assert_true(t.radiusX > 0, "radiusX is positive.");
   103         test(function() {
   109         test(function() {
   104           assert_equals(ev.touches.length, 1, "One touch point.");
   110           assert_equals(ev.touches.length, 1, "One touch point.");
   105           assert_equals(ev.changedTouches.length, 1, "One changed touch point.");
   111           assert_equals(ev.changedTouches.length, 1, "One changed touch point.");
   106           assert_equals(ev.targetTouches.length, 1, "One target touch point.");
   112           assert_equals(ev.targetTouches.length, 1, "One target touch point.");
   107         }, "touchmove TouchList lengths are correct.");
   113         }, "touchmove TouchList lengths are correct.");
       
   114 
       
   115         test(function() {
       
   116           assert_equals(ev.touches[0].identifier, touchstart_identifier, "Touch identifier matches.");
       
   117           assert_equals(ev.changedTouches[0].identifier, touchstart_identifier, "Changed touch identifier matches.");
       
   118           assert_equals(ev.targetTouches[0].identifier, touchstart_identifier, "Target touch identifier matches.");
       
   119         }, "touchmove identifier matches touchstart identifier.");
   108       });
   120       });
   109 
   121 
   110       on_event(target1, "touchmove", function onTouchMove(ev) {
   122       on_event(target1, "touchmove", function onTouchMove(ev) {
   111         invalid_touchmove_received = true;
   123         invalid_touchmove_received = true;
   112       });
   124       });
   136         }, "touchend TouchList lengths are correct.");
   148         }, "touchend TouchList lengths are correct.");
   137 
   149 
   138         var t = ev.changedTouches[0];
   150         var t = ev.changedTouches[0];
   139 
   151 
   140         test(function() {
   152         test(function() {
   141           assert_equals(t.identifier, 0, "changedTouches identifier is 0.");
   153           assert_equals(t.identifier, touchstart_identifier, "changedTouches identifier matches.");
   142         }, "Touch identifier is correct.");
   154         }, "touchend identifier matches.");
   143 
   155 
   144         test(function() {
   156         test(function() {
   145           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
   157           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
   146           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
   158           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
   147 
   159