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 // Start touch. |
| 380 var oldState = pincher.status(); |
| 381 t.addTouchPoint(100, 100); |
| 382 pincher.handleTouchStart(t.events()); |
| 383 t.addTouchPoint(300, 300); |
| 384 pincher.handleTouchStart(t.events()); |
| 385 |
| 386 // Pinch to zoom out. |
| 387 t.updateTouchPoint(0, 150, 150); |
| 388 t.updateTouchPoint(1, 250, 250); |
| 389 pincher.handleTouchMove(t.events()); |
| 390 |
| 391 // Verify scale is smaller. |
| 392 assertTrue(pincher.status().clampedScale < 0.9 * oldState.clampedScale); |
| 393 pincher.handleTouchCancel(); |
| 394 |
| 395 useFontScaling(0.8); |
| 396 assertClose(pincher.status().clampedScale, 0.8); |
| 397 |
| 398 // Start touch. |
| 399 t = new touch(); |
| 400 oldState = pincher.status(); |
| 401 t.addTouchPoint(150, 150); |
| 402 pincher.handleTouchStart(t.events()); |
| 403 t.addTouchPoint(250, 250); |
| 404 pincher.handleTouchStart(t.events()); |
| 405 |
| 406 // Pinch to zoom in. |
| 407 t.updateTouchPoint(0, 100, 100); |
| 408 t.updateTouchPoint(1, 300, 300); |
| 409 pincher.handleTouchMove(t.events()); |
| 410 |
| 411 // Verify scale is larger. |
| 412 assertTrue(pincher.status().clampedScale > 1.1 * oldState.clampedScale); |
| 413 pincher.handleTouchCancel(); |
| 414 } |
| 415 |
372 return { | 416 return { |
373 run: function(){ | 417 run: function(){ |
374 testZoomOut(); | 418 testZoomOut(); |
375 testZoomIn(); | 419 testZoomIn(); |
376 testZoomOutAndPan(); | 420 testZoomOutAndPan(); |
377 testReversible(); | 421 testReversible(); |
378 testMultitouchZoomOut(); | 422 testMultitouchZoomOut(); |
379 testZoomOutThenMulti(); | 423 testZoomOutThenMulti(); |
380 testCancel(); | 424 testCancel(); |
381 testSingularity(); | 425 testSingularity(); |
382 testMinSpan(); | 426 testMinSpan(); |
| 427 testFontScaling(); |
383 pincher.reset(); | 428 pincher.reset(); |
384 | 429 |
385 return {success: true}; | 430 return {success: true}; |
386 } | 431 } |
387 }; | 432 }; |
388 }()); | 433 }()); |
OLD | NEW |