| 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 | |
| 204 void performGo(TestCallbackHelperContainer testCallbackHelperContainer) thro
ws Throwable { | 200 void performGo(TestCallbackHelperContainer testCallbackHelperContainer) thro
ws Throwable { |
| 205 final InputConnection inputConnection = mConnection; | 201 final InputConnection inputConnection = mConnection; |
| 206 final Callable<Void> callable = new Callable<Void>() { | 202 final Callable<Void> callable = new Callable<Void>() { |
| 207 @Override | 203 @Override |
| 208 public Void call() throws Exception { | 204 public Void call() throws Exception { |
| 209 inputConnection.performEditorAction(EditorInfo.IME_ACTION_GO); | 205 inputConnection.performEditorAction(EditorInfo.IME_ACTION_GO); |
| 210 return null; | 206 return null; |
| 211 } | 207 } |
| 212 }; | 208 }; |
| 213 | 209 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 523 } |
| 528 }); | 524 }); |
| 529 } | 525 } |
| 530 | 526 |
| 531 /** | 527 /** |
| 532 * Focus element, wait for a single state update, reset state update list. | 528 * Focus element, wait for a single state update, reset state update list. |
| 533 * @param id ID of the element to focus. | 529 * @param id ID of the element to focus. |
| 534 */ | 530 */ |
| 535 void focusElementAndWaitForStateUpdate(String id) | 531 void focusElementAndWaitForStateUpdate(String id) |
| 536 throws InterruptedException, TimeoutException { | 532 throws InterruptedException, TimeoutException { |
| 537 resetAllStates(); | 533 resetUpdateSelectionList(); |
| 538 focusElement(id); | 534 focusElement(id); |
| 539 waitAndVerifyUpdateSelection(0, 0, 0, -1, -1); | 535 waitAndVerifyUpdateSelection(0, 0, 0, -1, -1); |
| 540 resetAllStates(); | 536 resetUpdateSelectionList(); |
| 541 } | 537 } |
| 542 | 538 |
| 543 void focusElement(final String id) throws InterruptedException, TimeoutExcep
tion { | 539 void focusElement(final String id) throws InterruptedException, TimeoutExcep
tion { |
| 544 focusElement(id, true); | 540 focusElement(id, true); |
| 545 } | 541 } |
| 546 | 542 |
| 547 void focusElement(final String id, boolean shouldShowKeyboard) | 543 void focusElement(final String id, boolean shouldShowKeyboard) |
| 548 throws InterruptedException, TimeoutException { | 544 throws InterruptedException, TimeoutException { |
| 549 DOMUtils.focusNode(getWebContents(), id); | 545 DOMUtils.focusNode(getWebContents(), id); |
| 550 assertWaitForKeyboardStatus(shouldShowKeyboard); | 546 assertWaitForKeyboardStatus(shouldShowKeyboard); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 567 public TestInputConnectionFactory(ChromiumBaseInputConnection.Factory fa
ctory) { | 563 public TestInputConnectionFactory(ChromiumBaseInputConnection.Factory fa
ctory) { |
| 568 mFactory = factory; | 564 mFactory = factory; |
| 569 } | 565 } |
| 570 | 566 |
| 571 @Override | 567 @Override |
| 572 public ChromiumBaseInputConnection initializeAndGet(View view, ImeAdapte
r imeAdapter, | 568 public ChromiumBaseInputConnection initializeAndGet(View view, ImeAdapte
r imeAdapter, |
| 573 int inputType, int inputFlags, int inputMode, int selectionStart
, int selectionEnd, | 569 int inputType, int inputFlags, int inputMode, int selectionStart
, int selectionEnd, |
| 574 EditorInfo outAttrs) { | 570 EditorInfo outAttrs) { |
| 575 mTextInputTypeList.add(inputType); | 571 mTextInputTypeList.add(inputType); |
| 576 mOutAttrs = outAttrs; | 572 mOutAttrs = outAttrs; |
| 577 return mFactory.initializeAndGet(view, imeAdapter, inputType, inputF
lags, inputMode, | 573 return mFactory.initializeAndGet(view, imeAdapter, inputType, inputM
ode, inputFlags, |
| 578 selectionStart, selectionEnd, outAttrs); | 574 selectionStart, selectionEnd, outAttrs); |
| 579 } | 575 } |
| 580 | 576 |
| 581 @Override | 577 @Override |
| 582 public Handler getHandler() { | 578 public Handler getHandler() { |
| 583 return mFactory.getHandler(); | 579 return mFactory.getHandler(); |
| 584 } | 580 } |
| 585 | 581 |
| 586 public Integer[] getTextInputTypeHistory() { | 582 public Integer[] getTextInputTypeHistory() { |
| 587 Integer[] result = new Integer[mTextInputTypeList.size()]; | 583 Integer[] result = new Integer[mTextInputTypeList.size()]; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 611 public void onViewAttachedToWindow() { | 607 public void onViewAttachedToWindow() { |
| 612 mFactory.onViewAttachedToWindow(); | 608 mFactory.onViewAttachedToWindow(); |
| 613 } | 609 } |
| 614 | 610 |
| 615 @Override | 611 @Override |
| 616 public void onViewDetachedFromWindow() { | 612 public void onViewDetachedFromWindow() { |
| 617 mFactory.onViewDetachedFromWindow(); | 613 mFactory.onViewDetachedFromWindow(); |
| 618 } | 614 } |
| 619 } | 615 } |
| 620 } | 616 } |
| OLD | NEW |