| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 function testShiftHighlight() { | 7 function testShiftHighlightAsync(testDoneCallback) { |
| 8 // Start in lower case. | 8 var test = function() { |
| 9 mockTouchType('l'); | 9 // Start in lower case. |
| 10 var shift = getKey("leftShift"); | 10 mockTouchType('l'); |
| 11 generateTouchEvent(shift, 'touchstart', true, true); | 11 var shift = getKey("leftShift"); |
| 12 generateTouchEvent(shift, 'touchend', true, true); | 12 generateTouchEvent(shift, 'touchstart', true, true); |
| 13 // Transitioned to upper case. | 13 generateTouchEvent(shift, 'touchend', true, true); |
| 14 mockTouchType('A'); | 14 // Transitioned to upper case. |
| 15 // Should revert to lower case. | 15 mockTouchType('A'); |
| 16 mockTouchType('p'); | 16 // Should revert to lower case. |
| 17 // Should remain in lower case. | 17 mockTouchType('p'); |
| 18 mockTouchType('c'); | 18 // Should remain in lower case. |
| 19 mockTouchType('c'); |
| 20 } |
| 21 RunTest(test, testDoneCallback); |
| 19 } | 22 } |
| 20 | 23 |
| 21 function testCapslock() { | 24 function testCapslockAsync(testDoneCallback) { |
| 22 // Skip this test for compact layouts since they don't have capslock keys. | 25 // Skip this test for compact layouts since they don't have capslock keys. |
| 23 var id = getLayoutId(); | 26 var id = getLayoutId(); |
| 24 if (id.indexOf("compact") > 0) | 27 if (id.indexOf("compact") > 0) { |
| 28 testDoneCallback(false); |
| 25 return; | 29 return; |
| 30 } |
| 31 var test = function() { |
| 32 // Start in lower case. |
| 33 mockTouchType('l'); |
| 34 // To upper case. |
| 35 // TODO(rsadam@): Only test this for the full layout. |
| 36 var caps = getKey("capslock") |
| 37 generateTouchEvent(caps, 'touchstart', true, true); |
| 38 generateTouchEvent(caps, 'touchend', true, true); |
| 39 mockTouchType('A'); |
| 40 // Should persist upper case. |
| 41 mockTouchType('P'); |
| 42 mockTouchType('C'); |
| 43 // Back to lower case. |
| 44 generateTouchEvent(caps, 'touchstart', true, true); |
| 45 generateTouchEvent(caps, 'touchend', true, true); |
| 46 mockTouchType('p'); |
| 47 // Persist lower case. |
| 48 mockTouchType('c') |
| 49 mockTouchType('d') |
| 26 | 50 |
| 27 // Start in lower case. | 51 // Same test, but using mouse events. |
| 28 mockTouchType('l'); | 52 // Start in lower case. |
| 29 // To upper case. | 53 mockMouseType('l'); |
| 30 // TODO(rsadam@): Only test this for the full layout. | 54 // To upper case. |
| 31 var caps = getKey("capslock") | 55 mockMouseTypeOnKey(caps); |
| 32 generateTouchEvent(caps, 'touchstart', true, true); | 56 mockMouseType('A'); |
| 33 generateTouchEvent(caps, 'touchend', true, true); | 57 // Should persist upper case. |
| 34 mockTouchType('A'); | 58 mockMouseType('P'); |
| 35 // Should persist upper case. | 59 mockMouseType('C'); |
| 36 mockTouchType('P'); | 60 // Back to lower case. |
| 37 mockTouchType('C'); | 61 mockMouseTypeOnKey(caps); |
| 38 // Back to lower case. | 62 mockMouseType('p'); |
| 39 generateTouchEvent(caps, 'touchstart', true, true); | 63 // Persist lower case. |
| 40 generateTouchEvent(caps, 'touchend', true, true); | 64 mockMouseType('c') |
| 41 mockTouchType('p'); | 65 mockMouseType('d') |
| 42 // Persist lower case. | 66 } |
| 43 mockTouchType('c') | 67 RunTest(test, testDoneCallback); |
| 44 mockTouchType('d') | |
| 45 | |
| 46 // Same test, but using mouse events. | |
| 47 // Start in lower case. | |
| 48 mockMouseType('l'); | |
| 49 // To upper case. | |
| 50 mockMouseTypeOnKey(caps); | |
| 51 mockMouseType('A'); | |
| 52 // Should persist upper case. | |
| 53 mockMouseType('P'); | |
| 54 mockMouseType('C'); | |
| 55 // Back to lower case. | |
| 56 mockMouseTypeOnKey(caps); | |
| 57 mockMouseType('p'); | |
| 58 // Persist lower case. | |
| 59 mockMouseType('c') | |
| 60 mockMouseType('d') | |
| 61 } | 68 } |
| OLD | NEW |