| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.test.util; | 5 package org.chromium.content.browser.test.util; |
| 6 | 6 |
| 7 import android.os.IBinder; | 7 import android.os.IBinder; |
| 8 import android.os.ResultReceiver; | 8 import android.os.ResultReceiver; |
| 9 import android.util.Pair; | 9 import android.util.Pair; |
| 10 import android.view.View; | 10 import android.view.View; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 private InputConnection mInputConnection; | 32 private InputConnection mInputConnection; |
| 33 private int mRestartInputCounter; | 33 private int mRestartInputCounter; |
| 34 private int mShowSoftInputCounter; | 34 private int mShowSoftInputCounter; |
| 35 private int mHideSoftInputCounter; | 35 private int mHideSoftInputCounter; |
| 36 private final Range mSelection = new Range(-1, -1); | 36 private final Range mSelection = new Range(-1, -1); |
| 37 private final Range mComposition = new Range(-1, -1); | 37 private final Range mComposition = new Range(-1, -1); |
| 38 private boolean mIsShowWithoutHideOutstanding; | 38 private boolean mIsShowWithoutHideOutstanding; |
| 39 private final List<Pair<Range, Range>> mUpdateSelectionList; | 39 private final List<Pair<Range, Range>> mUpdateSelectionList; |
| 40 private int mUpdateCursorAnchorInfoCounter; | 40 private int mUpdateCursorAnchorInfoCounter; |
| 41 private CursorAnchorInfo mLastCursorAnchorInfo; | 41 private CursorAnchorInfo mLastCursorAnchorInfo; |
| 42 private final ArrayList<EditorInfo> mEditorInfoList = new ArrayList<>(); | |
| 43 | 42 |
| 44 public TestInputMethodManagerWrapper(ContentViewCore contentViewCore) { | 43 public TestInputMethodManagerWrapper(ContentViewCore contentViewCore) { |
| 45 super(null); | 44 super(null); |
| 46 Log.d(TAG, "TestInputMethodManagerWrapper constructor"); | 45 Log.d(TAG, "TestInputMethodManagerWrapper constructor"); |
| 47 mContentViewCore = contentViewCore; | 46 mContentViewCore = contentViewCore; |
| 48 mUpdateSelectionList = new ArrayList<>(); | 47 mUpdateSelectionList = new ArrayList<>(); |
| 49 } | 48 } |
| 50 | 49 |
| 51 @Override | 50 @Override |
| 52 public void restartInput(View view) { | 51 public void restartInput(View view) { |
| 53 mRestartInputCounter++; | 52 mRestartInputCounter++; |
| 54 Log.d(TAG, "restartInput: count [%d]", mRestartInputCounter); | 53 Log.d(TAG, "restartInput: count [%d]", mRestartInputCounter); |
| 55 EditorInfo editorInfo = new EditorInfo(); | 54 EditorInfo editorInfo = new EditorInfo(); |
| 56 mInputConnection = mContentViewCore.onCreateInputConnection(editorInfo); | 55 mInputConnection = mContentViewCore.onCreateInputConnection(editorInfo); |
| 57 mEditorInfoList.add(editorInfo); | |
| 58 } | 56 } |
| 59 | 57 |
| 60 @Override | 58 @Override |
| 61 public void showSoftInput(View view, int flags, ResultReceiver resultReceive
r) { | 59 public void showSoftInput(View view, int flags, ResultReceiver resultReceive
r) { |
| 62 mIsShowWithoutHideOutstanding = true; | 60 mIsShowWithoutHideOutstanding = true; |
| 63 mShowSoftInputCounter++; | 61 mShowSoftInputCounter++; |
| 64 Log.d(TAG, "showSoftInput: count [%d]", mShowSoftInputCounter); | 62 Log.d(TAG, "showSoftInput: count [%d]", mShowSoftInputCounter); |
| 65 if (mInputConnection != null) return; | 63 if (mInputConnection != null) return; |
| 66 EditorInfo editorInfo = new EditorInfo(); | 64 EditorInfo editorInfo = new EditorInfo(); |
| 67 mInputConnection = mContentViewCore.onCreateInputConnection(editorInfo); | 65 mInputConnection = mContentViewCore.onCreateInputConnection(editorInfo); |
| 68 mEditorInfoList.add(editorInfo); | |
| 69 } | 66 } |
| 70 | 67 |
| 71 @Override | 68 @Override |
| 72 public boolean isActive(View view) { | 69 public boolean isActive(View view) { |
| 73 boolean result = mInputConnection != null; | 70 boolean result = mInputConnection != null; |
| 74 Log.d(TAG, "isActive: returns [%b]", result); | 71 Log.d(TAG, "isActive: returns [%b]", result); |
| 75 return result; | 72 return result; |
| 76 } | 73 } |
| 77 | 74 |
| 78 @Override | 75 @Override |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 public int getHideSoftInputCounter() { | 131 public int getHideSoftInputCounter() { |
| 135 return mHideSoftInputCounter; | 132 return mHideSoftInputCounter; |
| 136 } | 133 } |
| 137 | 134 |
| 138 public void reset() { | 135 public void reset() { |
| 139 Log.d(TAG, "reset"); | 136 Log.d(TAG, "reset"); |
| 140 mRestartInputCounter = 0; | 137 mRestartInputCounter = 0; |
| 141 mShowSoftInputCounter = 0; | 138 mShowSoftInputCounter = 0; |
| 142 mHideSoftInputCounter = 0; | 139 mHideSoftInputCounter = 0; |
| 143 mUpdateSelectionList.clear(); | 140 mUpdateSelectionList.clear(); |
| 144 mEditorInfoList.clear(); | |
| 145 } | 141 } |
| 146 | 142 |
| 147 public InputConnection getInputConnection() { | 143 public InputConnection getInputConnection() { |
| 148 return mInputConnection; | 144 return mInputConnection; |
| 149 } | 145 } |
| 150 | 146 |
| 151 public Range getSelection() { | 147 public Range getSelection() { |
| 152 return mSelection; | 148 return mSelection; |
| 153 } | 149 } |
| 154 | 150 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 } | 161 } |
| 166 | 162 |
| 167 public void clearLastCursorAnchorInfo() { | 163 public void clearLastCursorAnchorInfo() { |
| 168 mLastCursorAnchorInfo = null; | 164 mLastCursorAnchorInfo = null; |
| 169 } | 165 } |
| 170 | 166 |
| 171 public CursorAnchorInfo getLastCursorAnchorInfo() { | 167 public CursorAnchorInfo getLastCursorAnchorInfo() { |
| 172 return mLastCursorAnchorInfo; | 168 return mLastCursorAnchorInfo; |
| 173 } | 169 } |
| 174 | 170 |
| 175 public ArrayList<EditorInfo> getEditorInfoList() { | |
| 176 return mEditorInfoList; | |
| 177 } | |
| 178 | |
| 179 public void onUpdateSelection(Range oldSel, Range oldComp, Range newSel, Ran
ge newComp) {} | 171 public void onUpdateSelection(Range oldSel, Range oldComp, Range newSel, Ran
ge newComp) {} |
| 180 | 172 |
| 181 public void expectsSelectionOutsideComposition() {} | 173 public void expectsSelectionOutsideComposition() {} |
| 182 } | 174 } |
| OLD | NEW |