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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/junit/src/org/chromium/content/browser/input/TextInputStateTest.java
diff --git a/content/public/android/junit/src/org/chromium/content/browser/input/TextInputStateTest.java b/content/public/android/junit/src/org/chromium/content/browser/input/TextInputStateTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..e90de3cfccf11b11cf87d59495c40554bf17ba44
--- /dev/null
+++ b/content/public/android/junit/src/org/chromium/content/browser/input/TextInputStateTest.java
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser.input;
+
+import static org.junit.Assert.assertEquals;
+
+import org.chromium.base.test.util.Feature;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+/**
+ * Unit tests for {@TextInputState}.
+ */
+@RunWith(BlockJUnit4ClassRunner.class)
+public class TextInputStateTest {
+ @Test
+ @Feature({"TextInput"})
+ public void testEmptySelection() {
+ TextInputState state =
+ new TextInputState("hello", new Range(3, 3), new Range(-1, -1), false, true);
+ assertEquals("lo", state.getTextAfterSelection(3));
+ assertEquals("lo", state.getTextAfterSelection(2));
+ assertEquals("", state.getTextAfterSelection(0));
+ assertEquals("hel", state.getTextBeforeSelection(3));
+ assertEquals("el", state.getTextBeforeSelection(2));
+ assertEquals("", state.getTextBeforeSelection(0));
+ assertEquals("", state.getSelectedText());
+ }
+
+ @Test
+ @Feature({"TextInput"})
+ public void testNonEmptySelection() {
+ TextInputState state =
+ new TextInputState("hello", new Range(3, 4), new Range(3, 4), false, true);
+ assertEquals("hel", state.getTextBeforeSelection(4));
+ assertEquals("hel", state.getTextBeforeSelection(3));
+ assertEquals("", state.getTextBeforeSelection(0));
+ assertEquals("o", state.getTextAfterSelection(2));
+ assertEquals("o", state.getTextAfterSelection(1));
+ assertEquals("", state.getTextAfterSelection(0));
+ assertEquals("l", state.getSelectedText());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698