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; |
| 11 import android.view.inputmethod.CursorAnchorInfo; |
11 import android.view.inputmethod.EditorInfo; | 12 import android.view.inputmethod.EditorInfo; |
12 import android.view.inputmethod.InputConnection; | 13 import android.view.inputmethod.InputConnection; |
13 | 14 |
14 import org.chromium.base.Log; | 15 import org.chromium.base.Log; |
15 import org.chromium.content.browser.ContentViewCore; | 16 import org.chromium.content.browser.ContentViewCore; |
16 import org.chromium.content.browser.input.InputMethodManagerWrapper; | 17 import org.chromium.content.browser.input.InputMethodManagerWrapper; |
17 import org.chromium.content.browser.input.Range; | 18 import org.chromium.content.browser.input.Range; |
18 | 19 |
19 import java.util.ArrayList; | 20 import java.util.ArrayList; |
20 import java.util.List; | 21 import java.util.List; |
21 | 22 |
22 /** | 23 /** |
23 * Overrides InputMethodManagerWrapper for testing purposes. | 24 * Overrides InputMethodManagerWrapper for testing purposes. |
24 */ | 25 */ |
25 public class TestInputMethodManagerWrapper extends InputMethodManagerWrapper { | 26 public class TestInputMethodManagerWrapper extends InputMethodManagerWrapper { |
26 private static final String TAG = "cr_Ime"; | 27 private static final String TAG = "cr_Ime"; |
27 | 28 |
28 private final ContentViewCore mContentViewCore; | 29 private final ContentViewCore mContentViewCore; |
29 private InputConnection mInputConnection; | 30 private InputConnection mInputConnection; |
30 private int mRestartInputCounter; | 31 private int mRestartInputCounter; |
31 private int mShowSoftInputCounter; | 32 private int mShowSoftInputCounter; |
32 private int mHideSoftInputCounter; | 33 private int mHideSoftInputCounter; |
33 private final Range mSelection = new Range(-1, -1); | 34 private final Range mSelection = new Range(-1, -1); |
34 private final Range mComposition = new Range(-1, -1); | 35 private final Range mComposition = new Range(-1, -1); |
35 private boolean mIsShowWithoutHideOutstanding; | 36 private boolean mIsShowWithoutHideOutstanding; |
36 private final List<Pair<Range, Range>> mUpdateSelectionList; | 37 private final List<Pair<Range, Range>> mUpdateSelectionList; |
| 38 private int mUpdateCursorAnchorInfoCounter; |
| 39 private CursorAnchorInfo mLastCursorAnchorInfo; |
37 | 40 |
38 public TestInputMethodManagerWrapper(ContentViewCore contentViewCore) { | 41 public TestInputMethodManagerWrapper(ContentViewCore contentViewCore) { |
39 super(null); | 42 super(null); |
40 Log.d(TAG, "TestInputMethodManagerWrapper constructor"); | 43 Log.d(TAG, "TestInputMethodManagerWrapper constructor"); |
41 mContentViewCore = contentViewCore; | 44 mContentViewCore = contentViewCore; |
42 mUpdateSelectionList = new ArrayList<>(); | 45 mUpdateSelectionList = new ArrayList<>(); |
43 } | 46 } |
44 | 47 |
45 @Override | 48 @Override |
46 public void restartInput(View view) { | 49 public void restartInput(View view) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 public void notifyUserAction() {} | 103 public void notifyUserAction() {} |
101 | 104 |
102 public final List<Pair<Range, Range>> getUpdateSelectionList() { | 105 public final List<Pair<Range, Range>> getUpdateSelectionList() { |
103 return mUpdateSelectionList; | 106 return mUpdateSelectionList; |
104 } | 107 } |
105 | 108 |
106 public int getRestartInputCounter() { | 109 public int getRestartInputCounter() { |
107 return mRestartInputCounter; | 110 return mRestartInputCounter; |
108 } | 111 } |
109 | 112 |
| 113 @Override |
| 114 public void updateCursorAnchorInfo(View view, CursorAnchorInfo cursorAnchorI
nfo) { |
| 115 mUpdateCursorAnchorInfoCounter++; |
| 116 mLastCursorAnchorInfo = cursorAnchorInfo; |
| 117 } |
| 118 |
110 public int getShowSoftInputCounter() { | 119 public int getShowSoftInputCounter() { |
111 Log.d(TAG, "getShowSoftInputCounter: %d", mShowSoftInputCounter); | 120 Log.d(TAG, "getShowSoftInputCounter: %d", mShowSoftInputCounter); |
112 return mShowSoftInputCounter; | 121 return mShowSoftInputCounter; |
113 } | 122 } |
114 | 123 |
115 public int getHideSoftInputCounter() { | 124 public int getHideSoftInputCounter() { |
116 return mHideSoftInputCounter; | 125 return mHideSoftInputCounter; |
117 } | 126 } |
118 | 127 |
119 public void reset() { | 128 public void reset() { |
(...skipping 12 matching lines...) Expand all Loading... |
132 return mSelection; | 141 return mSelection; |
133 } | 142 } |
134 | 143 |
135 public Range getComposition() { | 144 public Range getComposition() { |
136 return mComposition; | 145 return mComposition; |
137 } | 146 } |
138 | 147 |
139 public boolean isShowWithoutHideOutstanding() { | 148 public boolean isShowWithoutHideOutstanding() { |
140 return mIsShowWithoutHideOutstanding; | 149 return mIsShowWithoutHideOutstanding; |
141 } | 150 } |
142 } | 151 |
| 152 public int getUpdateCursorAnchorInfoCounter() { |
| 153 return mUpdateCursorAnchorInfoCounter; |
| 154 } |
| 155 |
| 156 public void clearLastCursorAnchorInfo() { |
| 157 mLastCursorAnchorInfo = null; |
| 158 } |
| 159 |
| 160 public CursorAnchorInfo getLastCursorAnchorInfo() { |
| 161 return mLastCursorAnchorInfo; |
| 162 } |
| 163 } |
OLD | NEW |