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

Unified Diff: content/public/android/junit/src/org/chromium/content/browser/input/RangeTest.java

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handles render crash and navigation Created 4 years, 11 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/RangeTest.java
diff --git a/content/public/android/junit/src/org/chromium/content/browser/input/RangeTest.java b/content/public/android/junit/src/org/chromium/content/browser/input/RangeTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..060843e9d5f70ac3f86428f0362380513f5444fb
--- /dev/null
+++ b/content/public/android/junit/src/org/chromium/content/browser/input/RangeTest.java
@@ -0,0 +1,53 @@
+// 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 static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+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 {@Range}.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
Ted C 2016/02/02 23:14:43 Can this just be a simple junit test instead of ne
Changwan Ryu 2016/02/11 16:21:08 Done.
+public class RangeTest {
+
+ @Test
+ @Feature({"TextInput"})
+ public void test_clamp() {
+ // Overlap case #1
+ Range range = new Range(1, 4);
+ range.clamp(2, 5);
+ assertEquals(new Range(2, 4), range);
+ // Overlap case #2
+ range.set(1, 4);
+ range.clamp(0, 2);
+ assertEquals(new Range(1, 2), range);
+ // Clamp on both ends
+ range.set(1, 4);
+ range.clamp(2, 3);
+ assertEquals(new Range(2, 3), range);
+ // No-op
+ range.set(1, 4);
+ range.clamp(0, 5);
+ assertEquals(new Range(1, 4), range);
+ }
+
+ @Test
+ @Feature({"TextInput"})
+ public void test_equals() {
+ assertTrue(new Range(1, 3).equals(new Range(1, 3)));
+ assertFalse(new Range(1, 2).equals(new Range(1, 3)));
+ Range range = new Range(1, 4);
+ assertTrue(range.equals(range));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698