OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var pinchtest = (function() { | 5 var pinchtest = (function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 function assertTrue(condition, message) { | 8 function assertTrue(condition, message) { |
9 if (!condition) { | 9 if (!condition) { |
10 message = message || "Assertion failed"; | 10 message = message || "Assertion failed"; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 t.updateTouchPoint(0, 100, 100); | 362 t.updateTouchPoint(0, 100, 100); |
363 t.updateTouchPoint(1, 100, 100); | 363 t.updateTouchPoint(1, 100, 100); |
364 pincher.handleTouchMove(t.events()); | 364 pincher.handleTouchMove(t.events()); |
365 assertTrue(pincher.status().clampedScale < 0.9); | 365 assertTrue(pincher.status().clampedScale < 0.9); |
366 assertTrue(pincher.status().clampedScale > 0); | 366 assertTrue(pincher.status().clampedScale > 0); |
367 assertTrue(pincher.status().scale > 0); | 367 assertTrue(pincher.status().scale > 0); |
368 | 368 |
369 pincher.handleTouchCancel(); | 369 pincher.handleTouchCancel(); |
370 } | 370 } |
371 | 371 |
| 372 function testFontScaling() { |
| 373 pincher.reset(); |
| 374 useFontScaling(1.5); |
| 375 assertClose(pincher.status().clampedScale, 1.5); |
| 376 |
| 377 var t = new touch(); |
| 378 |
| 379 var oldState = pincher.status(); |
| 380 t.addTouchPoint(100, 100); |
| 381 pincher.handleTouchStart(t.events()); |
| 382 t.addTouchPoint(300, 300); |
| 383 pincher.handleTouchStart(t.events()); |
| 384 |
| 385 t.updateTouchPoint(0, 150, 150); |
| 386 t.updateTouchPoint(1, 250, 250); |
| 387 pincher.handleTouchMove(t.events()); |
| 388 assertTrue(pincher.status().clampedScale < 0.9 * oldState.clampedScale); |
| 389 |
| 390 pincher.handleTouchCancel(); |
| 391 |
| 392 useFontScaling(0.8); |
| 393 assertClose(pincher.status().clampedScale, 0.8); |
| 394 |
| 395 t = new touch(); |
| 396 oldState = pincher.status(); |
| 397 t.addTouchPoint(150, 150); |
| 398 pincher.handleTouchStart(t.events()); |
| 399 t.addTouchPoint(250, 250); |
| 400 pincher.handleTouchStart(t.events()); |
| 401 |
| 402 t.updateTouchPoint(0, 100, 100); |
| 403 t.updateTouchPoint(1, 300, 300); |
| 404 pincher.handleTouchMove(t.events()); |
| 405 assertTrue(pincher.status().clampedScale > 1.1 * oldState.clampedScale); |
| 406 pincher.handleTouchCancel(); |
| 407 } |
| 408 |
372 return { | 409 return { |
373 run: function(){ | 410 run: function(){ |
374 testZoomOut(); | 411 testZoomOut(); |
375 testZoomIn(); | 412 testZoomIn(); |
376 testZoomOutAndPan(); | 413 testZoomOutAndPan(); |
377 testReversible(); | 414 testReversible(); |
378 testMultitouchZoomOut(); | 415 testMultitouchZoomOut(); |
379 testZoomOutThenMulti(); | 416 testZoomOutThenMulti(); |
380 testCancel(); | 417 testCancel(); |
381 testSingularity(); | 418 testSingularity(); |
382 testMinSpan(); | 419 testMinSpan(); |
| 420 testFontScaling(); |
383 pincher.reset(); | 421 pincher.reset(); |
384 | 422 |
385 return {success: true}; | 423 return {success: true}; |
386 } | 424 } |
387 }; | 425 }; |
388 }()); | 426 }()); |
OLD | NEW |