Chromium Code Reviews| OLD | NEW |
|---|---|
| (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.chromium.testing.local.LocalRobolectricTestRunner; | |
| 11 import org.junit.Test; | |
| 12 import org.junit.runner.RunWith; | |
| 13 import org.robolectric.annotation.Config; | |
| 14 | |
| 15 /** | |
| 16 * Unit tests for {@TextInputState}. | |
| 17 */ | |
| 18 @RunWith(LocalRobolectricTestRunner.class) | |
| 19 @Config(manifest = Config.NONE) | |
| 20 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.
| |
| 21 | |
| 22 @Test | |
| 23 @Feature({"TextInput"}) | |
| 24 public void testEmptySelection() { | |
| 25 TextInputState state = | |
| 26 new TextInputState("hello", new Range(3, 3), new Range(-1, -1), false, true); | |
| 27 assertEquals("lo", state.getTextAfterSelection(3)); | |
| 28 assertEquals("lo", state.getTextAfterSelection(2)); | |
| 29 assertEquals("", state.getTextAfterSelection(0)); | |
| 30 assertEquals("hel", state.getTextBeforeSelection(3)); | |
| 31 assertEquals("el", state.getTextBeforeSelection(2)); | |
| 32 assertEquals("", state.getTextBeforeSelection(0)); | |
| 33 assertEquals("", state.getSelectedText()); | |
| 34 } | |
| 35 | |
| 36 @Test | |
| 37 @Feature({"TextInput"}) | |
| 38 public void testNonEmptySelection() { | |
| 39 TextInputState state = | |
| 40 new TextInputState("hello", new Range(3, 4), new Range(3, 4), fa lse, true); | |
| 41 assertEquals("hel", state.getTextBeforeSelection(4)); | |
| 42 assertEquals("hel", state.getTextBeforeSelection(3)); | |
| 43 assertEquals("", state.getTextBeforeSelection(0)); | |
| 44 assertEquals("o", state.getTextAfterSelection(2)); | |
| 45 assertEquals("o", state.getTextAfterSelection(1)); | |
| 46 assertEquals("", state.getTextAfterSelection(0)); | |
| 47 assertEquals("l", state.getSelectedText()); | |
| 48 } | |
| 49 } | |
| OLD | NEW |