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

Side by Side Diff: content/public/android/junit/src/org/chromium/content/browser/input/TextInputStateTest.java

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed ImeTest#testDoesNotHang_rendererCrashes which does not test anything Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.content.browser.input;
6
7 import static org.junit.Assert.assertEquals;
8
9 import org.chromium.base.test.util.Feature;
10 import org.junit.Test;
11 import org.junit.runner.RunWith;
12 import org.junit.runners.BlockJUnit4ClassRunner;
13
14 /**
15 * Unit tests for {@TextInputState}.
16 */
17 @RunWith(BlockJUnit4ClassRunner.class)
18 public class TextInputStateTest {
19 @Test
20 @Feature({"TextInput"})
21 public void testEmptySelection() {
22 TextInputState state =
23 new TextInputState("hello", new Range(3, 3), new Range(-1, -1), false, true);
24 assertEquals("lo", state.getTextAfterSelection(3));
25 assertEquals("lo", state.getTextAfterSelection(2));
26 assertEquals("", state.getTextAfterSelection(0));
27 assertEquals("hel", state.getTextBeforeSelection(3));
28 assertEquals("el", state.getTextBeforeSelection(2));
29 assertEquals("", state.getTextBeforeSelection(0));
30 assertEquals("", state.getSelectedText());
31 }
32
33 @Test
34 @Feature({"TextInput"})
35 public void testNonEmptySelection() {
36 TextInputState state =
37 new TextInputState("hello", new Range(3, 4), new Range(3, 4), fa lse, true);
38 assertEquals("hel", state.getTextBeforeSelection(4));
39 assertEquals("hel", state.getTextBeforeSelection(3));
40 assertEquals("", state.getTextBeforeSelection(0));
41 assertEquals("o", state.getTextAfterSelection(2));
42 assertEquals("o", state.getTextAfterSelection(1));
43 assertEquals("", state.getTextAfterSelection(0));
44 assertEquals("l", state.getSelectedText());
45 }
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698