OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.content.ClipData; | 9 import android.content.ClipData; |
10 import android.content.ClipboardManager; | 10 import android.content.ClipboardManager; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 int restartCount = mInputMethodManagerWrapper.getRestartInputCounter(); | 190 int restartCount = mInputMethodManagerWrapper.getRestartInputCounter(); |
191 Integer[] history = mConnectionFactory.getTextInputTypeHistory(); | 191 Integer[] history = mConnectionFactory.getTextInputTypeHistory(); |
192 return stringifyKeyboardStates(showCount, hideCount, restartCount, histo
ry); | 192 return stringifyKeyboardStates(showCount, hideCount, restartCount, histo
ry); |
193 } | 193 } |
194 | 194 |
195 String stringifyKeyboardStates(int show, int hide, int restart, Integer[] hi
story) { | 195 String stringifyKeyboardStates(int show, int hide, int restart, Integer[] hi
story) { |
196 return "show count: " + show + ", hide count: " + hide + ", restart coun
t: " + restart | 196 return "show count: " + show + ", hide count: " + hide + ", restart coun
t: " + restart |
197 + ", input type history: " + Arrays.deepToString(history); | 197 + ", input type history: " + Arrays.deepToString(history); |
198 } | 198 } |
199 | 199 |
| 200 void performEditorAction(final int action) { |
| 201 mConnection.performEditorAction(action); |
| 202 } |
| 203 |
200 void performGo(TestCallbackHelperContainer testCallbackHelperContainer) thro
ws Throwable { | 204 void performGo(TestCallbackHelperContainer testCallbackHelperContainer) thro
ws Throwable { |
201 final InputConnection inputConnection = mConnection; | 205 final InputConnection inputConnection = mConnection; |
202 final Callable<Void> callable = new Callable<Void>() { | 206 final Callable<Void> callable = new Callable<Void>() { |
203 @Override | 207 @Override |
204 public Void call() throws Exception { | 208 public Void call() throws Exception { |
205 inputConnection.performEditorAction(EditorInfo.IME_ACTION_GO); | 209 inputConnection.performEditorAction(EditorInfo.IME_ACTION_GO); |
206 return null; | 210 return null; |
207 } | 211 } |
208 }; | 212 }; |
209 | 213 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 527 } |
524 }); | 528 }); |
525 } | 529 } |
526 | 530 |
527 /** | 531 /** |
528 * Focus element, wait for a single state update, reset state update list. | 532 * Focus element, wait for a single state update, reset state update list. |
529 * @param id ID of the element to focus. | 533 * @param id ID of the element to focus. |
530 */ | 534 */ |
531 void focusElementAndWaitForStateUpdate(String id) | 535 void focusElementAndWaitForStateUpdate(String id) |
532 throws InterruptedException, TimeoutException { | 536 throws InterruptedException, TimeoutException { |
533 resetUpdateSelectionList(); | 537 resetAllStates(); |
534 focusElement(id); | 538 focusElement(id); |
535 waitAndVerifyUpdateSelection(0, 0, 0, -1, -1); | 539 waitAndVerifyUpdateSelection(0, 0, 0, -1, -1); |
536 resetUpdateSelectionList(); | 540 resetAllStates(); |
537 } | 541 } |
538 | 542 |
539 void focusElement(final String id) throws InterruptedException, TimeoutExcep
tion { | 543 void focusElement(final String id) throws InterruptedException, TimeoutExcep
tion { |
540 focusElement(id, true); | 544 focusElement(id, true); |
541 } | 545 } |
542 | 546 |
543 void focusElement(final String id, boolean shouldShowKeyboard) | 547 void focusElement(final String id, boolean shouldShowKeyboard) |
544 throws InterruptedException, TimeoutException { | 548 throws InterruptedException, TimeoutException { |
545 DOMUtils.focusNode(getWebContents(), id); | 549 DOMUtils.focusNode(getWebContents(), id); |
546 assertWaitForKeyboardStatus(shouldShowKeyboard); | 550 assertWaitForKeyboardStatus(shouldShowKeyboard); |
(...skipping 16 matching lines...) Expand all Loading... |
563 public TestInputConnectionFactory(ChromiumBaseInputConnection.Factory fa
ctory) { | 567 public TestInputConnectionFactory(ChromiumBaseInputConnection.Factory fa
ctory) { |
564 mFactory = factory; | 568 mFactory = factory; |
565 } | 569 } |
566 | 570 |
567 @Override | 571 @Override |
568 public ChromiumBaseInputConnection initializeAndGet(View view, ImeAdapte
r imeAdapter, | 572 public ChromiumBaseInputConnection initializeAndGet(View view, ImeAdapte
r imeAdapter, |
569 int inputType, int inputFlags, int inputMode, int selectionStart
, int selectionEnd, | 573 int inputType, int inputFlags, int inputMode, int selectionStart
, int selectionEnd, |
570 EditorInfo outAttrs) { | 574 EditorInfo outAttrs) { |
571 mTextInputTypeList.add(inputType); | 575 mTextInputTypeList.add(inputType); |
572 mOutAttrs = outAttrs; | 576 mOutAttrs = outAttrs; |
573 return mFactory.initializeAndGet(view, imeAdapter, inputType, inputM
ode, inputFlags, | 577 return mFactory.initializeAndGet(view, imeAdapter, inputType, inputF
lags, inputMode, |
574 selectionStart, selectionEnd, outAttrs); | 578 selectionStart, selectionEnd, outAttrs); |
575 } | 579 } |
576 | 580 |
577 @Override | 581 @Override |
578 public Handler getHandler() { | 582 public Handler getHandler() { |
579 return mFactory.getHandler(); | 583 return mFactory.getHandler(); |
580 } | 584 } |
581 | 585 |
582 public Integer[] getTextInputTypeHistory() { | 586 public Integer[] getTextInputTypeHistory() { |
583 Integer[] result = new Integer[mTextInputTypeList.size()]; | 587 Integer[] result = new Integer[mTextInputTypeList.size()]; |
(...skipping 23 matching lines...) Expand all Loading... |
607 public void onViewAttachedToWindow() { | 611 public void onViewAttachedToWindow() { |
608 mFactory.onViewAttachedToWindow(); | 612 mFactory.onViewAttachedToWindow(); |
609 } | 613 } |
610 | 614 |
611 @Override | 615 @Override |
612 public void onViewDetachedFromWindow() { | 616 public void onViewDetachedFromWindow() { |
613 mFactory.onViewDetachedFromWindow(); | 617 mFactory.onViewDetachedFromWindow(); |
614 } | 618 } |
615 } | 619 } |
616 } | 620 } |
OLD | NEW |