From bfea7dec1a4260104b6d4b316f2163368478869c Mon Sep 17 00:00:00 2001
From: Jean Chalard <jchalard@google.com>
Date: Mon, 17 Feb 2014 14:15:57 +0900
Subject: [PATCH] Add a test for Armenian periods.

Bug: 11463389
Change-Id: Ic1a612bd6b2693369a1688e6a2273cff26fbe6d1
---
 .../inputmethod/latin/ShiftModeTests.java     | 30 +++++++------------
 .../latin/utils/CapsModeUtilsTests.java       | 15 ++++++++++
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/tests/src/com/android/inputmethod/latin/ShiftModeTests.java b/tests/src/com/android/inputmethod/latin/ShiftModeTests.java
index a319ffda6e..db3c9baa9c 100644
--- a/tests/src/com/android/inputmethod/latin/ShiftModeTests.java
+++ b/tests/src/com/android/inputmethod/latin/ShiftModeTests.java
@@ -111,24 +111,16 @@ public class ShiftModeTests extends InputTestsBase {
         assertTrue("(Spanish) Auto caps after inverted bang", isCapsModeAutoShifted());
     }
 
-    public void DISABLED_testOtherSentenceSeparators() {
-        // We only run this test on Kitkat+ because previous versions of Android don't
-        // have an Armenian locale. For some reason I don't know, when the requested
-        // locale is not present as a device locale, then the application under test can't
-        // access the resources in that locale -- though it works when the app is actually
-        // running on the device and not under test. If we ever figure out what's going
-        // on, remove this test.
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-            changeLanguage("hy-AM");
-            assertTrue("(Armenian) Auto caps at start", isCapsModeAutoShifted());
-            type("Hey. ");
-            assertFalse("(Armenian) No auto-caps after latin period", isCapsModeAutoShifted());
-            type("Hey\u0589");
-            assertFalse("(Armenian) No auto-caps directly after armenian period",
-                    isCapsModeAutoShifted());
-            type(" ");
-            assertTrue("(Armenian) Auto-caps after armenian period-whitespace",
-                    isCapsModeAutoShifted());
-        }
+    public void testOtherSentenceSeparators() {
+        changeLanguage("hy_AM");
+        assertTrue("(Armenian) Auto caps at start", isCapsModeAutoShifted());
+        type("Hey. ");
+        assertFalse("(Armenian) No auto-caps after latin period", isCapsModeAutoShifted());
+        type("Hey\u0589");
+        assertFalse("(Armenian) No auto-caps directly after armenian period",
+                isCapsModeAutoShifted());
+        type(" ");
+        assertTrue("(Armenian) Auto-caps after armenian period-whitespace",
+                isCapsModeAutoShifted());
     }
 }
diff --git a/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java
index 020d632991..c746c83455 100644
--- a/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java
@@ -22,6 +22,7 @@ import android.test.suitebuilder.annotation.SmallTest;
 import android.text.TextUtils;
 
 import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
+import com.android.inputmethod.latin.utils.LocaleUtils;
 
 import java.util.Locale;
 
@@ -109,5 +110,19 @@ public class CapsModeUtilsTests extends AndroidTestCase {
         allPathsForCaps("Liebe Sara,  \n  ", c | w | s, sp, false);
         allPathsForCaps("Liebe Sara  \n  ", c | w | s, sp, false);
         allPathsForCaps("Liebe Sara.\n  ", c | w | s, sp, false);
+
+        // Test armenian period
+        sp = job.runInLocale(res, LocaleUtils.constructLocaleFromString("hy_AM"));
+        assertTrue("Period is not sentence separator in Armenian",
+                !sp.isSentenceSeparator('.'));
+        assertTrue("Sentence separator is Armenian period in Armenian",
+                sp.isSentenceSeparator(0x589));
+        // No space : capitalize only if MODE_CHARACTERS
+        allPathsForCaps("Word", c, sp, false);
+        allPathsForCaps("Word.", c, sp, false);
+        // Space, but no armenian period : capitalize if MODE_WORDS but not SENTENCES
+        allPathsForCaps("Word. ", c | w, sp, false);
+        // Armenian period : capitalize if MODE_SENTENCES
+        allPathsForCaps("Word\u0589 ", c | w | s, sp, false);
     }
 }
-- 
GitLab