summaryrefslogtreecommitdiff
path: root/core/src/test/java/android/text
diff options
context:
space:
mode:
authororionlee <orionlee@yahoo.com>2018-05-18 13:21:36 -0700
committerorionlee <orionlee@yahoo.com>2018-05-18 13:21:36 -0700
commit46ae3e0b00a3b3ec8ef7ba01efad8bcfb1a79398 (patch)
tree9467bb3db44be725d2fc56092f98f602d2face42 /core/src/test/java/android/text
parentf05c7e23efce568b830d000df773209640028d7c (diff)
downloadAntennaPod-46ae3e0b00a3b3ec8ef7ba01efad8bcfb1a79398.zip
core tests: Convert tests that are effectively unit tests to be one
(standard android junit tests). Provides implementations for android platform utils needed (in unit test environment): 1. android.util.Log, 2. android.text.TextUtils.isEmpty()
Diffstat (limited to 'core/src/test/java/android/text')
-rw-r--r--core/src/test/java/android/text/TextUtils.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/src/test/java/android/text/TextUtils.java b/core/src/test/java/android/text/TextUtils.java
new file mode 100644
index 000000000..c31234171
--- /dev/null
+++ b/core/src/test/java/android/text/TextUtils.java
@@ -0,0 +1,32 @@
+package android.text;
+
+/**
+ * A slim-down version of standard {@link android.text.TextUtils} to be used in unit tests.
+ */
+public class TextUtils {
+
+ /**
+ * Returns true if a and b are equal, including if they are both null.
+ * <p><i>Note: In platform versions 1.1 and earlier, this method only worked well if
+ * both the arguments were instances of String.</i></p>
+ * @param a first CharSequence to check
+ * @param b second CharSequence to check
+ * @return true if a and b are equal
+ */
+ public static boolean equals(CharSequence a, CharSequence b) {
+ if (a == b) return true;
+ int length;
+ if (a != null && b != null && (length = a.length()) == b.length()) {
+ if (a instanceof String && b instanceof String) {
+ return a.equals(b);
+ } else {
+ for (int i = 0; i < length; i++) {
+ if (a.charAt(i) != b.charAt(i)) return false;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+}