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..30cd54642e0692f35bbac0f32f1b7a93c394c324 |
--- /dev/null |
+++ b/content/public/android/junit/src/org/chromium/content/browser/input/TextInputStateTest.java |
@@ -0,0 +1,49 @@ |
+// 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.chromium.testing.local.LocalRobolectricTestRunner; |
+import org.junit.Test; |
+import org.junit.runner.RunWith; |
+import org.robolectric.annotation.Config; |
+ |
+/** |
+ * Unit tests for {@TextInputState}. |
+ */ |
+@RunWith(LocalRobolectricTestRunner.class) |
+@Config(manifest = Config.NONE) |
+public class TextInputStateTest { |
Ted C
2016/02/02 23:14:43
same comment about vanilla junit
Changwan Ryu
2016/02/11 16:21:08
Done.
|
+ |
+ @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()); |
+ } |
+} |