Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1374)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java

Issue 197763002: Revert "hide the input method window when the user is done typing" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.input; 5 package org.chromium.content.browser.input;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.IBinder; 8 import android.os.IBinder;
9 import android.os.ResultReceiver; 9 import android.os.ResultReceiver;
10 import android.test.suitebuilder.annotation.MediumTest; 10 import android.test.suitebuilder.annotation.MediumTest;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 mConnection.setComposingText("tes", 1); 71 mConnection.setComposingText("tes", 1);
72 assertEquals(0, mWrapper.getUpdateSelectionCallCount()); 72 assertEquals(0, mWrapper.getUpdateSelectionCallCount());
73 mConnection.endBatchEdit(); 73 mConnection.endBatchEdit();
74 mConnection.setComposingText("test", 1); 74 mConnection.setComposingText("test", 1);
75 assertEquals(0, mWrapper.getUpdateSelectionCallCount()); 75 assertEquals(0, mWrapper.getUpdateSelectionCallCount());
76 mConnection.endBatchEdit(); 76 mConnection.endBatchEdit();
77 assertEquals(1, mWrapper.getUpdateSelectionCallCount()); 77 assertEquals(1, mWrapper.getUpdateSelectionCallCount());
78 mWrapper.verifyUpdateSelectionCall(0, 4, 4, 0 ,4); 78 mWrapper.verifyUpdateSelectionCall(0, 4, 4, 0 ,4);
79 } 79 }
80 80
81 @MediumTest
82 @Feature({"TextInput", "Main"})
83 public void testDismissInputMethodWindowAfterFinishingTyping() throws Throwa ble {
84 assertEquals(false, mWrapper.isHidden());
85
86 mConnection.performEditorAction(EditorInfo.IME_ACTION_NEXT);
87 assertEquals(false, mWrapper.isHidden());
88 mWrapper.showSoftInput(null, 0, null);
89
90 mConnection.performEditorAction(EditorInfo.IME_ACTION_SEND);
91 assertEquals(false, mWrapper.isHidden());
92 mWrapper.showSoftInput(null, 0, null);
93
94 mConnection.performEditorAction(EditorInfo.IME_ACTION_GO);
95 assertEquals(true, mWrapper.isHidden());
96 mWrapper.showSoftInput(null, 0, null);
97
98 mConnection.performEditorAction(EditorInfo.IME_ACTION_DONE);
99 assertEquals(true, mWrapper.isHidden());
100 mWrapper.showSoftInput(null, 0, null);
101
102 mConnection.performEditorAction(EditorInfo.IME_ACTION_SEARCH);
103 assertEquals(true, mWrapper.isHidden());
104 mWrapper.showSoftInput(null, 0, null);
105 }
106
107 private static class TestImeAdapter extends ImeAdapter { 81 private static class TestImeAdapter extends ImeAdapter {
108 public TestImeAdapter(InputMethodManagerWrapper wrapper, ImeAdapterDeleg ate embedder) { 82 public TestImeAdapter(InputMethodManagerWrapper wrapper, ImeAdapterDeleg ate embedder) {
109 super(wrapper, embedder); 83 super(wrapper, embedder);
110 } 84 }
111 } 85 }
112 86
113 private static class TestInputMethodManagerWrapper extends InputMethodManage rWrapper { 87 private static class TestInputMethodManagerWrapper extends InputMethodManage rWrapper {
114 private final ArrayList<ImeState> mUpdates = new ArrayList<ImeState>(); 88 private final ArrayList<ImeState> mUpdates = new ArrayList<ImeState>();
115 private boolean hidden = false;
116 89
117 public TestInputMethodManagerWrapper(Context context) { 90 public TestInputMethodManagerWrapper(Context context) {
118 super(context); 91 super(context);
119 } 92 }
120 93
121 @Override 94 @Override
122 public void restartInput(View view) {} 95 public void restartInput(View view) {}
123 96
124 @Override 97 @Override
125 public void showSoftInput(View view, int flags, ResultReceiver resultRec eiver) { 98 public void showSoftInput(View view, int flags, ResultReceiver resultRec eiver) {}
126 hidden = false;
127 }
128 99
129 @Override 100 @Override
130 public boolean isActive(View view) { 101 public boolean isActive(View view) {
131 return true; 102 return true;
132 } 103 }
133 104
134 @Override 105 @Override
135 public boolean hideSoftInputFromWindow(IBinder windowToken, int flags, 106 public boolean hideSoftInputFromWindow(IBinder windowToken, int flags,
136 ResultReceiver resultReceiver) { 107 ResultReceiver resultReceiver) {
137 hidden = true;
138 return true; 108 return true;
139 } 109 }
140 110
141 @Override 111 @Override
142 public void updateSelection(View view, int selStart, int selEnd, 112 public void updateSelection(View view, int selStart, int selEnd,
143 int candidatesStart, int candidatesEnd) { 113 int candidatesStart, int candidatesEnd) {
144 mUpdates.add(new ImeState("", selStart, selEnd, candidatesStart, candi datesEnd)); 114 mUpdates.add(new ImeState("", selStart, selEnd, candidatesStart, candi datesEnd));
145 } 115 }
146 116
147 public int getUpdateSelectionCallCount() { 117 public int getUpdateSelectionCallCount() {
148 return mUpdates.size(); 118 return mUpdates.size();
149 } 119 }
150 120
151 public void verifyUpdateSelectionCall(int index, int selectionStart, int selectionEnd, 121 public void verifyUpdateSelectionCall(int index, int selectionStart, int selectionEnd,
152 int compositionStart, int compositionEnd) { 122 int compositionStart, int compositionEnd) {
153 ImeState state = mUpdates.get(index); 123 ImeState state = mUpdates.get(index);
154 assertEquals("Selection start did not match", selectionStart, state. selectionStart); 124 assertEquals("Selection start did not match", selectionStart, state. selectionStart);
155 assertEquals("Selection end did not match", selectionEnd, state.sele ctionEnd); 125 assertEquals("Selection end did not match", selectionEnd, state.sele ctionEnd);
156 assertEquals("Composition start did not match", compositionStart, 126 assertEquals("Composition start did not match", compositionStart,
157 state.compositionStart); 127 state.compositionStart);
158 assertEquals("Composition end did not match", compositionEnd, state. compositionEnd); 128 assertEquals("Composition end did not match", compositionEnd, state. compositionEnd);
159 } 129 }
160
161 public boolean isHidden() {
162 return hidden;
163 }
164 } 130 }
165 131
166 private static class TestImeAdapterDelegate implements ImeAdapterDelegate { 132 private static class TestImeAdapterDelegate implements ImeAdapterDelegate {
167 @Override 133 @Override
168 public void onImeEvent(boolean isFinish) {} 134 public void onImeEvent(boolean isFinish) {}
169 135
170 @Override 136 @Override
171 public void onSetFieldValue() {} 137 public void onSetFieldValue() {}
172 138
173 @Override 139 @Override
(...skipping 12 matching lines...) Expand all
186 152
187 private static void assertCorrectState(String text, int selectionStart, int selectionEnd, 153 private static void assertCorrectState(String text, int selectionStart, int selectionEnd,
188 int compositionStart, int compositionEnd, ImeState actual) { 154 int compositionStart, int compositionEnd, ImeState actual) {
189 assertEquals("Text did not match", text, actual.text); 155 assertEquals("Text did not match", text, actual.text);
190 assertEquals("Selection start did not match", selectionStart, actual.sel ectionStart); 156 assertEquals("Selection start did not match", selectionStart, actual.sel ectionStart);
191 assertEquals("Selection end did not match", selectionEnd, actual.selecti onEnd); 157 assertEquals("Selection end did not match", selectionEnd, actual.selecti onEnd);
192 assertEquals("Composition start did not match", compositionStart, actual .compositionStart); 158 assertEquals("Composition start did not match", compositionStart, actual .compositionStart);
193 assertEquals("Composition end did not match", compositionEnd, actual.com positionEnd); 159 assertEquals("Composition end did not match", compositionEnd, actual.com positionEnd);
194 } 160 }
195 } 161 }
OLDNEW
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698