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

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

Issue 501383002: Adding Select Action Bar Unit test case for input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added utility function to reuse in future test cases. Created 6 years, 3 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
« no previous file with comments | « no previous file | 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.app.Activity; 7 import android.app.Activity;
8 import android.content.ClipData; 8 import android.content.ClipData;
9 import android.content.ClipboardManager; 9 import android.content.ClipboardManager;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 DOMUtils.focusNode(mContentViewCore, "input_radio"); 167 DOMUtils.focusNode(mContentViewCore, "input_radio");
168 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); 168 DOMUtils.longPressNode(this, mContentViewCore, "input_text");
169 assertWaitForKeyboardStatus(false); 169 assertWaitForKeyboardStatus(false);
170 commitText(mConnection, "Sample Text", 1); 170 commitText(mConnection, "Sample Text", 1);
171 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); 171 DOMUtils.longPressNode(this, mContentViewCore, "input_text");
172 assertWaitForKeyboardStatus(true); 172 assertWaitForKeyboardStatus(true);
173 } 173 }
174 174
175 @SmallTest 175 @SmallTest
176 @Feature({"TextInput"}) 176 @Feature({"TextInput"})
177 public void testSelectActionBarShownOnLongPressingInput() throws Exception {
178 DOMUtils.longPressNode(this, mContentViewCore, "input_text");
179 assertWaitForSelectActionBarStatus(false);
180 commitText(mConnection, "Sample Text", 1);
181 DOMUtils.longPressNode(this, mContentViewCore, "input_text");
182 assertWaitForSelectActionBarStatus(true);
183 }
184
185 @SmallTest
186 @Feature({"TextInput"})
177 public void testImeCut() throws Exception { 187 public void testImeCut() throws Exception {
178 commitText(mConnection, "snarful", 1); 188 commitText(mConnection, "snarful", 1);
179 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1); 189 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1);
180 190
181 setSelection(mConnection, 1, 5); 191 setSelection(mConnection, 1, 5);
182 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1); 192 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1);
183 193
184 cut(mImeAdapter); 194 cut(mImeAdapter);
185 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "sul", 1, 1, -1, -1); 195 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "sul", 1, 1, -1, -1);
186 196
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 private void assertWaitForKeyboardStatus(final boolean show) throws Interrup tedException { 565 private void assertWaitForKeyboardStatus(final boolean show) throws Interrup tedException {
556 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { 566 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
557 @Override 567 @Override
558 public boolean isSatisfied() { 568 public boolean isSatisfied() {
559 return show == getImeAdapter().mIsShowWithoutHideOutstanding && 569 return show == getImeAdapter().mIsShowWithoutHideOutstanding &&
560 (!show || getAdapterInputConnection() != null); 570 (!show || getAdapterInputConnection() != null);
561 } 571 }
562 })); 572 }));
563 } 573 }
564 574
575 private void assertWaitForSelectActionBarStatus(
576 final boolean show) throws InterruptedException {
577 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
578 @Override
579 public boolean isSatisfied() {
580 return show == mContentViewCore.isSelectActionBarShowing();
581 }
582 }));
583 }
584
565 private void waitAndVerifyEditableCallback(final ArrayList<TestImeState> sta tes, 585 private void waitAndVerifyEditableCallback(final ArrayList<TestImeState> sta tes,
566 final int index, String text, int selectionStart, int selectionEnd, 586 final int index, String text, int selectionStart, int selectionEnd,
567 int compositionStart, int compositionEnd) throws InterruptedExceptio n { 587 int compositionStart, int compositionEnd) throws InterruptedExceptio n {
568 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { 588 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
569 @Override 589 @Override
570 public boolean isSatisfied() { 590 public boolean isSatisfied() {
571 return states.size() > index; 591 return states.size() > index;
572 } 592 }
573 })); 593 }));
574 states.get(index).assertEqualState( 594 states.get(index).assertEqualState(
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 public void assertEqualState(String text, int selectionStart, int select ionEnd, 790 public void assertEqualState(String text, int selectionStart, int select ionEnd,
771 int compositionStart, int compositionEnd) { 791 int compositionStart, int compositionEnd) {
772 assertEquals("Text did not match", text, mText); 792 assertEquals("Text did not match", text, mText);
773 assertEquals("Selection start did not match", selectionStart, mSelec tionStart); 793 assertEquals("Selection start did not match", selectionStart, mSelec tionStart);
774 assertEquals("Selection end did not match", selectionEnd, mSelection End); 794 assertEquals("Selection end did not match", selectionEnd, mSelection End);
775 assertEquals("Composition start did not match", compositionStart, mC ompositionStart); 795 assertEquals("Composition start did not match", compositionStart, mC ompositionStart);
776 assertEquals("Composition end did not match", compositionEnd, mCompo sitionEnd); 796 assertEquals("Composition end did not match", compositionEnd, mCompo sitionEnd);
777 } 797 }
778 } 798 }
779 } 799 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698