1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.inputmethod.keyboard.internal; 18 19 import android.test.suitebuilder.annotation.SmallTest; 20 21 @SmallTest 22 public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { 23 // Chording input in alphabet. testChordingAlphabet()24 public void testChordingAlphabet() { 25 // Press shift key and hold, enter into choring shift state. 26 pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 27 // Press/release letter key. 28 chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 29 // Release shift key, switch back to alphabet. 30 releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 31 32 // Press "?123" key and hold, enter into choring symbols state. 33 pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); 34 // Press/release symbol letter key. 35 chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 36 // Release "ABC" key, switch back to alphabet. 37 releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 38 } 39 40 // Chording input in shifted. testChordingShifted()41 public void testChordingShifted() { 42 // Press shift key, enter alphabet shifted. 43 pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 44 45 // Press shift key and hold, enter into choring shift state. 46 pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 47 // Press/release letter key. 48 chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 49 // Release shift key, switch back to alphabet shifted. 50 releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 51 52 // Press "?123" key and hold, enter into choring symbols state. 53 pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); 54 // Press/release symbol letter key. 55 chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 56 // Release "123?" key, switch back to alphabet unshifted. 57 releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 58 } 59 60 // Chording input in shift locked. testChordingShiftLocked()61 public void testChordingShiftLocked() { 62 // Long press shift key, enter alphabet shift locked. 63 longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, 64 ALPHABET_SHIFT_LOCKED); 65 66 // Press shift key and hold, enter into choring shift state. 67 pressKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED); 68 // Press/release letter key. 69 chordingPressAndReleaseKey('Z', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); 70 // Release shift key, switch back to alphabet shift locked. 71 releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); 72 73 // Press "?123" key and hold, enter into choring symbols state. 74 pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); 75 // Press/release symbol letter key. 76 chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 77 // Release "123?" key, switch back to alphabet shift locked. 78 releaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); 79 } 80 81 // Chording input in symbols. testChordingSymbols()82 public void testChordingSymbols() { 83 // Press/release "?123" key, enter symbols. 84 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 85 86 // Press "=\<" key and hold, enter into choring symbols shifted state. 87 pressKey(CODE_SHIFT, SYMBOLS_SHIFTED); 88 // Press/release symbol letter key. 89 chordingPressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); 90 // Release "=\<" key, switch back to symbols. 91 releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); 92 93 // Press "ABC" key and hold, enter into choring alphabet state. 94 pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 95 // Press/release letter key. 96 chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); 97 // Release "ABC" key, switch back to symbols. 98 releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); 99 100 // Alphabet shifted -> symbols -> "ABC" key + letter -> symbols 101 // -> alphabet. 102 // Load keyboard 103 loadKeyboard(ALPHABET_UNSHIFTED); 104 // Press/release shift key, enter alphabet shifted. 105 pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 106 // Press/release "?123" key, enter into symbols. 107 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 108 // Press "ABC" key, enter into chording alphabet state. 109 pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 110 // Enter/release letter key. 111 chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); 112 // Release "ABC" key, switch back to symbols. 113 releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); 114 // Press/release "ABC" key, switch to alphabet (not alphabet shifted). 115 pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); 116 117 // Alphabet shift locked -> symbols -> "ABC" key + letter -> symbols -> 118 // alphabet shift locked. 119 // Load keyboard 120 loadKeyboard(ALPHABET_UNSHIFTED); 121 // Long press shift key, enter alphabet shift locked. 122 longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, 123 ALPHABET_SHIFT_LOCKED); 124 // Press/release "?123" key, enter into symbols. 125 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 126 // Press "ABC" key, enter into chording alphabet shift locked. 127 pressKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); 128 // Enter/release letter key. 129 chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); 130 // Release "ABC" key, switch back to symbols. 131 releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); 132 // Press/release "ABC" key, switch to alphabet shift locked. 133 pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); 134 135 // Alphabet shift locked -> symbols -> "=\<" key + letter -> symbols -> 136 // alphabet shift locked. 137 // Load keyboard 138 loadKeyboard(ALPHABET_UNSHIFTED); 139 // Long press shift key, enter alphabet shift locked. 140 longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, 141 ALPHABET_SHIFT_LOCKED); 142 // Press/release "?123" key, enter into symbols. 143 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 144 // Press "=\<" key, enter into symbols shifted chording state. 145 pressKey(CODE_SHIFT, SYMBOLS_SHIFTED); 146 // Enter/release symbols shift letter key. 147 chordingPressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); 148 // Release "=\<" key, switch back to symbols. 149 releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); 150 // Press/release "ABC" key, switch to alphabet shift locked. 151 pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); 152 } 153 154 // Chording input in symbol shifted. testChordingSymbolsShifted()155 public void testChordingSymbolsShifted() { 156 // Press/release "?123" key, enter symbols. 157 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 158 // Press/release "=\<" key, enter symbols shifted. 159 pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); 160 161 // Press "?123" key and hold, enter into chording symbols state. 162 pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); 163 // Press/release symbol letter key. 164 chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 165 // Release "=\<" key, switch back to symbols shifted state. 166 releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED); 167 168 // Press "ABC" key and hold, enter into choring alphabet state. 169 pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 170 // Press/release letter key. 171 chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); 172 // Release "ABC" key, switch back to symbols. 173 releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); 174 175 // Alphabet shifted -> symbols shifted -> "ABC" key + letter -> symbols shifted -> 176 // alphabet. 177 // Load keyboard 178 loadKeyboard(ALPHABET_UNSHIFTED); 179 // Press/release shift key, enter alphabet shifted. 180 pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 181 // Press/release "?123" key, enter into symbols. 182 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 183 // Press/release "=\<" key, enter symbols shifted. 184 pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); 185 // Press "ABC" key, enter into chording alphabet state. 186 pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 187 // Enter/release letter key. 188 chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); 189 // Release "ABC" key, switch back to symbols shifted. 190 releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); 191 // Press/release "ABC" key, switch to alphabet (not alphabet shifted). 192 pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); 193 194 // Alphabet shift locked -> symbols shifted -> "ABC" key + letter -> symbols shifted 195 // -> alphabet shift locked. 196 // Load keyboard 197 loadKeyboard(ALPHABET_UNSHIFTED); 198 // Long press shift key, enter alphabet shift locked. 199 longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, 200 ALPHABET_SHIFT_LOCKED); 201 // Press/release "?123" key, enter into symbols. 202 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 203 // Press/release "=\<" key, enter symbols shifted. 204 pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); 205 // Press "ABC" key, enter into chording alphabet shift locked. 206 pressKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); 207 // Enter/release letter key. 208 chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); 209 // Release "ABC" key, switch back to symbols shifted. 210 releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); 211 // Press/release "ABC" key, switch to alphabet shift locked. 212 pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); 213 214 // Alphabet shift locked -> symbols shifted -> "=\<" key + letter -> symbols shifted 215 // -> alphabet shift locked. 216 // Load keyboard 217 loadKeyboard(ALPHABET_UNSHIFTED); 218 // Long press shift key, enter alphabet shift locked. 219 longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, 220 ALPHABET_SHIFT_LOCKED); 221 // Press/release "?123" key, enter into symbols. 222 pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 223 // Press/release "=\<" key, enter symbols shifted. 224 pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); 225 // Press "=\<" key, enter into symbols chording state. 226 pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); 227 // Enter/release symbols letter key. 228 chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 229 // Release "=\<" key, switch back to symbols shifted. 230 releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED); 231 // Press/release "ABC" key, switch to alphabet shift locked. 232 pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); 233 } 234 235 // Chording input in automatic upper case. testChordingAutomaticUpperCase()236 public void testChordingAutomaticUpperCase() { 237 // Set capitalize the first character of all words mode. 238 setAutoCapsMode(CAP_MODE_WORDS); 239 240 // Update shift state with auto caps enabled. 241 pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); 242 // Press shift key and hold, enter into chording shift state. 243 pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 244 // Press/release letter key. 245 chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 246 // Release shift key, switch back to alphabet. 247 releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 248 249 // Update shift state with auto caps enabled. 250 pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); 251 // Press "123?" key and hold, enter into chording symbols state. 252 pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); 253 // Press/release symbol letter key. 254 chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 255 // Release "123?" key, switch back to alphabet. 256 releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 257 } 258 259 // Chording letter key with shift key. testChordingLetterAndShiftKey()260 public void testChordingLetterAndShiftKey() { 261 // Press letter key and hold. 262 pressKey('z', ALPHABET_UNSHIFTED); 263 // Press shift key, {@link PointerTracker} will fire a phantom release letter key. 264 chordingReleaseKey('z', ALPHABET_UNSHIFTED); 265 chordingPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 266 // Press another letter key and hold. 267 chordingPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 268 // Release shift key 269 releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 270 } 271 272 // Multi touch input in manual shifted. testMultiTouchManualShifted()273 public void testMultiTouchManualShifted() { 274 // Press/release shift key, enter into alphabet shifted. 275 pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 276 277 // Press 'X' key and hold 278 pressKey('X', ALPHABET_MANUAL_SHIFTED); 279 // Press 'z' key and hold, switch back to alphabet unshifted. 280 chordingPressKey('z', ALPHABET_UNSHIFTED); 281 // Release 'X' key 282 releaseKey('X', ALPHABET_UNSHIFTED); 283 // Release 'z' key 284 releaseKey('z', ALPHABET_UNSHIFTED); 285 } 286 287 // Multi touch input in automatic upper case. testMultiTouchAutomaticUpperCase()288 public void testMultiTouchAutomaticUpperCase() { 289 // Set auto word caps mode on. 290 setAutoCapsMode(CAP_MODE_WORDS); 291 // Update shift state with auto caps enabled. 292 pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); 293 294 // Press 'X' key and hold 295 pressKey('X', ALPHABET_AUTOMATIC_SHIFTED); 296 // Press 'z' key and hold, switch back to alphabet unshifted. 297 chordingPressKey('z', ALPHABET_UNSHIFTED); 298 // Release 'X' key 299 releaseKey('X', ALPHABET_UNSHIFTED); 300 // Release 'z' key 301 releaseKey('z', ALPHABET_UNSHIFTED); 302 } 303 304 // Multi touch input in capitalize character mode. testMultiTouchCapModeCharacter()305 public void testMultiTouchCapModeCharacter() { 306 // Set auto character caps mode on. 307 setAutoCapsMode(CAP_MODE_CHARACTERS); 308 // Update shift state with auto caps enabled. 309 pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); 310 311 // Press 'X' key and hold 312 pressKey('X', ALPHABET_AUTOMATIC_SHIFTED); 313 // Press 'Z' key and hold, stay in automatic shifted mode. 314 chordingPressKey('Z', ALPHABET_AUTOMATIC_SHIFTED); 315 // Release 'X' key 316 releaseKey('X', ALPHABET_AUTOMATIC_SHIFTED); 317 // Release 'Z' key 318 releaseKey('Z', ALPHABET_AUTOMATIC_SHIFTED); 319 } 320 321 // Multi touch shift chording input in manual shifted. testMultiTouchShiftChordingManualShifted()322 public void testMultiTouchShiftChordingManualShifted() { 323 // Press/release shift key, enter into alphabet shifted. 324 pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 325 326 // Press shift key and hold, stays in alphabet shifted. 327 pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 328 // Press 'X' key and hold 329 chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); 330 // Press 'Z' key and hold, stays in alphabet shifted. 331 chordingPressKey('Z', ALPHABET_MANUAL_SHIFTED); 332 // Release 'X' key 333 releaseKey('X', ALPHABET_MANUAL_SHIFTED); 334 // Release 'Z' key 335 releaseKey('Z', ALPHABET_MANUAL_SHIFTED); 336 // Release shift key, switch back to alphabet shifted. 337 releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 338 } 339 340 // Multi touch shift chording input in automatic upper case. testMultiTouchShiftChordingAutomaticUpperCase()341 public void testMultiTouchShiftChordingAutomaticUpperCase() { 342 // Set auto word caps mode on. 343 setAutoCapsMode(CAP_MODE_WORDS); 344 // Update shift state with auto caps enabled. 345 pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); 346 347 // Press shift key and hold, switch to alphabet shifted. 348 pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 349 // Press 'X' key and hold 350 chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); 351 // Press 'Z' key and hold, stays in alphabet shifted. 352 chordingPressKey('Z', ALPHABET_MANUAL_SHIFTED); 353 // Release 'X' key 354 releaseKey('X', ALPHABET_MANUAL_SHIFTED); 355 // Release 'Z' key 356 releaseKey('Z', ALPHABET_MANUAL_SHIFTED); 357 // Release shift key, updated to alphabet unshifted. 358 releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 359 360 // Update shift state with auto caps enabled. 361 pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); 362 363 // Press shift key and hold, switch to alphabet shifted. 364 pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 365 // Press 'X' key and hold 366 chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); 367 // Release 'X' key 368 releaseKey('X', ALPHABET_MANUAL_SHIFTED); 369 // Press key and hold, stays in alphabet shifted. 370 chordingPressKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_MANUAL_SHIFTED); 371 // Release 'Z' key 372 releaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_MANUAL_SHIFTED); 373 // Release shift key, updated to alphabet automatic shifted. 374 releaseKey(CODE_SHIFT, ALPHABET_AUTOMATIC_SHIFTED); 375 } 376 377 // Multi touch shift chording input in capitalize character mode. testMultiTouchShiftChordingCapModeCharacter()378 public void testMultiTouchShiftChordingCapModeCharacter() { 379 // Set auto character caps mode on. 380 setAutoCapsMode(CAP_MODE_CHARACTERS); 381 // Update shift state with auto caps enabled. 382 pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); 383 384 // Press shift key and hold, switch to alphabet shifted. 385 pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 386 // Press 'X' key and hold 387 chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); 388 // Press 'Z' key and hold, stay in automatic shifted mode. 389 chordingPressKey('Z', ALPHABET_MANUAL_SHIFTED); 390 // Release 'X' key 391 releaseKey('X', ALPHABET_MANUAL_SHIFTED); 392 // Release 'Z' key 393 releaseKey('Z', ALPHABET_MANUAL_SHIFTED); 394 // Release shift key, updated to alphabet automatic shifted. 395 releaseKey(CODE_SHIFT, ALPHABET_AUTOMATIC_SHIFTED); 396 } 397 testLongPressShiftAndChording()398 public void testLongPressShiftAndChording() { 399 // Long press shift key, enter maybe shift locked. 400 longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 401 // Press/release letter key, remain in manual shifted. 402 chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 403 // Release shift key, back to alphabet (not shift locked). 404 releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 405 406 // Long press shift key, enter alphabet shift locked. 407 longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, 408 ALPHABET_SHIFT_LOCKED); 409 // Long press shift key, enter maybe alphabet. 410 longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); 411 // Press/release letter key, remain in manual shifted. 412 chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); 413 // Release shift key, back to shift locked (not alphabet). 414 releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); 415 // Long press shift key, enter alphabet 416 longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, 417 ALPHABET_UNSHIFTED); 418 419 // Press/release shift key, enter alphabet shifted. 420 pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 421 // Long press shift key, enter maybe alphabet. 422 longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 423 // Press/release letter key, remain in manual shifted. 424 chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 425 // Release shift key, back to alphabet shifted (not alphabet). 426 releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 427 428 // Set capitalize the first character of all words mode. 429 setAutoCapsMode(CAP_MODE_WORDS); 430 // Load keyboard, should be in automatic shifted. 431 loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); 432 // Long press shift key, enter maybe shift locked. 433 longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 434 // Press/release letter key, remain in manual shifted. 435 chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 436 // Release shift key, back to alphabet (not shift locked). 437 releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 438 } 439 testDoubleTapShiftAndChording()440 public void testDoubleTapShiftAndChording() { 441 // TODO: The following tests fail due to bug. Temporarily commented. 442 // // First shift key tap. 443 // pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 444 // // Second shift key tap, maybe shift locked. 445 // secondPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 446 // // Press/release letter key, remain in manual shifted. 447 // chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 448 // // Release shift key, back to alphabet shifted (not shift locked). 449 // releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 450 // 451 // // Long press shift key, enter alphabet shift locked. 452 // longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, 453 // ALPHABET_SHIFT_LOCKED); 454 // // First shift key tap. 455 // pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); 456 // // Second shift key tap, maybe shift unlocked. 457 // secondPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 458 // // Press/release letter key, remain in manual shifted. 459 // chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 460 // // Release shift key, back to alphabet (not shift locked). 461 // releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 462 // 463 // // Set capitalize the first character of all words mode. 464 // setAutoCapsMode(CAP_MODE_WORDS); 465 // // Load keyboard, should be in automatic shifted. 466 // loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); 467 // // First shift key tap. 468 // pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); 469 // // Second shift key tap, maybe shift locked. 470 // secondPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); 471 // // Press/release letter key, remain in manual shifted. 472 // chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 473 // // Release shift key, back to alphabet (not shift locked). 474 // releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 475 } 476 } 477