diff options
Diffstat (limited to 'tests/src/com/android/inputmethod/latin')
6 files changed, 743 insertions, 45 deletions
diff --git a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java index 199922491..f9d72269e 100644 --- a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java +++ b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java @@ -215,18 +215,23 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { "abc 'def", mSpacingAndPunctuations, 2), PrevWordsInfo.EMPTY_PREV_WORDS_INFO); } - /** - * Test logic in getting the word range at the cursor. - */ - private static final int[] SPACE = { Constants.CODE_SPACE }; - static final int[] TAB = { Constants.CODE_TAB }; - private static final int[] SPACE_TAB = StringUtils.toSortedCodePointArray(" \t"); - // A character that needs surrogate pair to represent its code point (U+2008A). - private static final String SUPPLEMENTARY_CHAR = "\uD840\uDC8A"; - private static final String HIRAGANA_WORD = "\u3042\u3044\u3046\u3048\u304A"; // あいうえお - private static final String GREEK_WORD = "\u03BA\u03B1\u03B9"; // και - public void testGetWordRangeAtCursor() { + /** + * Test logic in getting the word range at the cursor. + */ + final SpacingAndPunctuations SPACE = new SpacingAndPunctuations( + mSpacingAndPunctuations, new int[] { Constants.CODE_SPACE }); + final SpacingAndPunctuations TAB = new SpacingAndPunctuations( + mSpacingAndPunctuations, new int[] { Constants.CODE_TAB }); + final int[] SPACE_TAB = StringUtils.toSortedCodePointArray(" \t"); + // A character that needs surrogate pair to represent its code point (U+2008A). + final String SUPPLEMENTARY_CHAR_STRING = "\uD840\uDC8A"; + final SpacingAndPunctuations SUPPLEMENTARY_CHAR = new SpacingAndPunctuations( + mSpacingAndPunctuations, StringUtils.toSortedCodePointArray( + SUPPLEMENTARY_CHAR_STRING)); + final String HIRAGANA_WORD = "\u3042\u3044\u3046\u3048\u304A"; // あいうえお + final String GREEK_WORD = "\u03BA\u03B1\u03B9"; // και + ExtractedText et = new ExtractedText(); final MockInputMethodService mockInputMethodService = new MockInputMethodService(); final RichInputConnection ic = new RichInputConnection(mockInputMethodService); @@ -249,10 +254,9 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { // splitting on supplementary character mockInputMethodService.setInputConnection( - new MockConnection("one word" + SUPPLEMENTARY_CHAR + "wo", "rd", et)); + new MockConnection("one word" + SUPPLEMENTARY_CHAR_STRING + "wo", "rd", et)); ic.beginBatchEdit(); - r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR), - ScriptUtils.SCRIPT_LATIN); + r = ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR, ScriptUtils.SCRIPT_LATIN); ic.endBatchEdit(); assertTrue(TextUtils.equals("word", r.mWord)); @@ -260,8 +264,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { mockInputMethodService.setInputConnection( new MockConnection(HIRAGANA_WORD + "wo", "rd" + GREEK_WORD, et)); ic.beginBatchEdit(); - r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR), - ScriptUtils.SCRIPT_LATIN); + r = ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR, ScriptUtils.SCRIPT_LATIN); ic.endBatchEdit(); assertTrue(TextUtils.equals("word", r.mWord)); @@ -269,8 +272,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { mockInputMethodService.setInputConnection( new MockConnection("text" + GREEK_WORD, "text", et)); ic.beginBatchEdit(); - r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR), - ScriptUtils.SCRIPT_GREEK); + r = ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR, ScriptUtils.SCRIPT_GREEK); ic.endBatchEdit(); assertTrue(TextUtils.equals(GREEK_WORD, r.mWord)); } @@ -286,6 +288,8 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { } private void helpTestGetSuggestionSpansAtWord(final int cursorPos) { + final SpacingAndPunctuations SPACE = new SpacingAndPunctuations( + mSpacingAndPunctuations, new int[] { Constants.CODE_SPACE }); final MockInputMethodService mockInputMethodService = new MockInputMethodService(); final RichInputConnection ic = new RichInputConnection(mockInputMethodService); diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java index 66b4a9c71..869c550e0 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java @@ -23,24 +23,50 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import java.util.ArrayList; import java.util.Locale; -import java.util.Random; @SmallTest public class SuggestedWordsTests extends AndroidTestCase { + + /** + * Helper method to create a dummy {@link SuggestedWordInfo} with specifying + * {@link SuggestedWordInfo#KIND_TYPED}. + * + * @param word the word to be used to create {@link SuggestedWordInfo}. + * @return a new instance of {@link SuggestedWordInfo}. + */ + private static SuggestedWordInfo createTypedWordInfo(final String word) { + // Use 100 as the frequency because the numerical value does not matter as + // long as it's > 1 and < INT_MAX. + return new SuggestedWordInfo(word, 100 /* score */, + SuggestedWordInfo.KIND_TYPED, + null /* sourceDict */, + SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, + 1 /* autoCommitFirstWordConfidence */); + } + + /** + * Helper method to create a dummy {@link SuggestedWordInfo} with specifying + * {@link SuggestedWordInfo#KIND_CORRECTION}. + * + * @param word the word to be used to create {@link SuggestedWordInfo}. + * @return a new instance of {@link SuggestedWordInfo}. + */ + private static SuggestedWordInfo createCorrectionWordInfo(final String word) { + return new SuggestedWordInfo(word, 1 /* score */, + SuggestedWordInfo.KIND_CORRECTION, + null /* sourceDict */, + SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, + SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */); + } + public void testGetSuggestedWordsExcludingTypedWord() { final String TYPED_WORD = "typed"; - final int TYPED_WORD_FREQ = 5; final int NUMBER_OF_ADDED_SUGGESTIONS = 5; + final int KIND_OF_SECOND_CORRECTION = SuggestedWordInfo.KIND_CORRECTION; final ArrayList<SuggestedWordInfo> list = new ArrayList<>(); - list.add(new SuggestedWordInfo(TYPED_WORD, TYPED_WORD_FREQ, - SuggestedWordInfo.KIND_TYPED, null /* sourceDict */, - SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, - SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */)); + list.add(createTypedWordInfo(TYPED_WORD)); for (int i = 0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) { - list.add(new SuggestedWordInfo("" + i, 1, SuggestedWordInfo.KIND_CORRECTION, - null /* sourceDict */, - SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, - SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */)); + list.add(createCorrectionWordInfo(Integer.toString(i))); } final SuggestedWords words = new SuggestedWords( @@ -48,35 +74,29 @@ public class SuggestedWordsTests extends AndroidTestCase { false /* typedWordValid */, false /* willAutoCorrect */, false /* isObsoleteSuggestions */, - false /* isPrediction*/); + SuggestedWords.INPUT_STYLE_NONE); assertEquals(NUMBER_OF_ADDED_SUGGESTIONS + 1, words.size()); assertEquals("typed", words.getWord(0)); assertTrue(words.getInfo(0).isKindOf(SuggestedWordInfo.KIND_TYPED)); assertEquals("0", words.getWord(1)); - assertTrue(words.getInfo(1).isKindOf(SuggestedWordInfo.KIND_CORRECTION)); + assertTrue(words.getInfo(1).isKindOf(KIND_OF_SECOND_CORRECTION)); assertEquals("4", words.getWord(5)); - assertTrue(words.getInfo(5).isKindOf(SuggestedWordInfo.KIND_CORRECTION)); + assertTrue(words.getInfo(5).isKindOf(KIND_OF_SECOND_CORRECTION)); - final SuggestedWords wordsWithoutTyped = words.getSuggestedWordsExcludingTypedWord(); + final SuggestedWords wordsWithoutTyped = + words.getSuggestedWordsExcludingTypedWordForRecorrection(); + // Make sure that the typed word has indeed been excluded, by testing the size of the + // suggested words, the string and the kind of the top suggestion, which should match + // the string and kind of what we inserted after the typed word. assertEquals(words.size() - 1, wordsWithoutTyped.size()); assertEquals("0", wordsWithoutTyped.getWord(0)); - assertTrue(wordsWithoutTyped.getInfo(0).isKindOf(SuggestedWordInfo.KIND_CORRECTION)); - } - - // Helper for testGetTransformedWordInfo - private SuggestedWordInfo createWordInfo(final String s) { - // Use 100 as the frequency because the numerical value does not matter as - // long as it's > 1 and < INT_MAX. - return new SuggestedWordInfo(s, 100, - SuggestedWordInfo.KIND_TYPED, null /* sourceDict */, - SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, - new Random().nextInt(1000000) /* autoCommitFirstWordConfidence */); + assertTrue(wordsWithoutTyped.getInfo(0).isKindOf(KIND_OF_SECOND_CORRECTION)); } // Helper for testGetTransformedWordInfo private SuggestedWordInfo transformWordInfo(final String info, final int trailingSingleQuotesCount) { - final SuggestedWordInfo suggestedWordInfo = createWordInfo(info); + final SuggestedWordInfo suggestedWordInfo = createTypedWordInfo(info); final SuggestedWordInfo returnedWordInfo = Suggest.getTransformedSuggestedWordInfo(suggestedWordInfo, Locale.ENGLISH, false /* isAllUpperCase */, false /* isFirstCharCapitalized */, @@ -100,4 +120,43 @@ public class SuggestedWordsTests extends AndroidTestCase { result = transformWordInfo("didn't", 3); assertEquals(result.mWord, "didn't''"); } + + public void testGetTypedWordInfoOrNull() { + final String TYPED_WORD = "typed"; + final int NUMBER_OF_ADDED_SUGGESTIONS = 5; + final ArrayList<SuggestedWordInfo> list = new ArrayList<>(); + list.add(createTypedWordInfo(TYPED_WORD)); + for (int i = 0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) { + list.add(createCorrectionWordInfo(Integer.toString(i))); + } + + // Make sure getTypedWordInfoOrNull() returns non-null object. + final SuggestedWords wordsWithTypedWord = new SuggestedWords( + list, null /* rawSuggestions */, + false /* typedWordValid */, + false /* willAutoCorrect */, + false /* isObsoleteSuggestions */, + SuggestedWords.INPUT_STYLE_NONE); + final SuggestedWordInfo typedWord = wordsWithTypedWord.getTypedWordInfoOrNull(); + assertNotNull(typedWord); + assertEquals(TYPED_WORD, typedWord.mWord); + + // Make sure getTypedWordInfoOrNull() returns null. + final SuggestedWords wordsWithoutTypedWord = + wordsWithTypedWord.getSuggestedWordsExcludingTypedWordForRecorrection(); + assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull()); + + // Make sure getTypedWordInfoOrNull() returns null. + assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull()); + + final SuggestedWords emptySuggestedWords = new SuggestedWords( + new ArrayList<SuggestedWordInfo>(), null /* rawSuggestions */, + false /* typedWordValid */, + false /* willAutoCorrect */, + false /* isObsoleteSuggestions */, + SuggestedWords.INPUT_STYLE_NONE); + assertNull(emptySuggestedWords.getTypedWordInfoOrNull()); + + assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull()); + } } diff --git a/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java b/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java index 2cc22fae4..eb76032b1 100644 --- a/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java +++ b/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java @@ -429,7 +429,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase { assertFalse("willAutoCorrect", suggestedWords.mWillAutoCorrect); assertTrue("isPunctuationSuggestions", suggestedWords.isPunctuationSuggestions()); assertFalse("isObsoleteSuggestions", suggestedWords.mIsObsoleteSuggestions); - assertFalse("isPrediction", suggestedWords.mIsPrediction); + assertFalse("isPrediction", suggestedWords.isPrediction()); assertEquals("size", punctuationLabels.length, suggestedWords.size()); for (int index = 0; index < suggestedWords.size(); index++) { assertEquals("punctuation label at " + index, diff --git a/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java b/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java new file mode 100644 index 000000000..f3273a2d1 --- /dev/null +++ b/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.suggestions; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +import com.android.inputmethod.latin.SuggestedWords; + +@SmallTest +public class SuggestionStripLayoutHelperTests extends AndroidTestCase { + private static void confirmShowTypedWord(final String message, final int inputType) { + assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord( + inputType, + false /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord( + inputType, + true /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord( + inputType, + false /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord( + inputType, + true /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + } + + public void testShouldShowTypedWord() { + confirmShowTypedWord("no input style", + SuggestedWords.INPUT_STYLE_NONE); + confirmShowTypedWord("application specifed", + SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED); + confirmShowTypedWord("recorrection", + SuggestedWords.INPUT_STYLE_RECORRECTION); + } + + public void testshouldOmitTypedWordWhileTyping() { + assertFalse("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TYPING, + false /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertFalse("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TYPING, + true /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertTrue("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TYPING, + false /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + assertTrue("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TYPING, + true /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + } + + public void testshouldOmitTypedWordWhileGesturing() { + assertFalse("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_UPDATE_BATCH, + false /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertFalse("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_UPDATE_BATCH, + true /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertFalse("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_UPDATE_BATCH, + false /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + assertTrue("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_UPDATE_BATCH, + true /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + } + + public void testshouldOmitTypedWordWhenGestured() { + assertFalse("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TAIL_BATCH, + false /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertFalse("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TAIL_BATCH, + true /* gestureFloatingPreviewTextEnabled */, + false /* shouldShowUiToAcceptTypedWord */)); + assertTrue("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TAIL_BATCH, + false /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + assertTrue("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord( + SuggestedWords.INPUT_STYLE_TAIL_BATCH, + true /* gestureFloatingPreviewTextEnabled */, + true /* shouldShowUiToAcceptTypedWord */)); + } + + // Note that this unit test assumes that the number of suggested words in the suggestion strip + // is 3. + private static final int POSITION_OMIT = -1; + private static final int POSITION_LEFT = 0; + private static final int POSITION_CENTER = 1; + private static final int POSITION_RIGHT = 2; + + public void testGetPositionInSuggestionStrip() { + assertEquals("1st word without auto correction", POSITION_CENTER, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */, + false /* willAutoCorrect */, + false /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("2nd word without auto correction", POSITION_LEFT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */, + false /* willAutoCorrect */, + false /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("3rd word without auto correction", POSITION_RIGHT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + 2 /* indexInSuggestedWords */, + false /* willAutoCorrect */, + false /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + + assertEquals("typed word with auto correction", POSITION_LEFT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */, + true /* willAutoCorrect */, + false /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("2nd word with auto correction", POSITION_CENTER, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */, + true /* willAutoCorrect */, + false /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("3rd word with auto correction", POSITION_RIGHT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + 2 /* indexInSuggestedWords */, + true /* willAutoCorrect */, + false /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + + assertEquals("1st word without auto correction", POSITION_OMIT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */, + false /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("2nd word without auto correction", POSITION_CENTER, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */, + false /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("3rd word without auto correction", POSITION_LEFT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + 2 /* indexInSuggestedWords */, + false /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("4th word without auto correction", POSITION_RIGHT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + 3 /* indexInSuggestedWords */, + false /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + + assertEquals("typed word with auto correction", POSITION_OMIT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */, + true /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("2nd word with auto correction", POSITION_CENTER, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */, + true /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("3rd word with auto correction", POSITION_LEFT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + 2 /* indexInSuggestedWords */, + true /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + assertEquals("4th word with auto correction", POSITION_RIGHT, + SuggestionStripLayoutHelper.getPositionInSuggestionStrip( + 3 /* indexInSuggestedWords */, + true /* willAutoCorrect */, + true /* omitTypedWord */, + POSITION_CENTER /* centerPositionInStrip */, + POSITION_LEFT /* typedWordPositionWhenAutoCorrect */)); + } +} diff --git a/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java new file mode 100644 index 000000000..819d76328 --- /dev/null +++ b/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.utils; + +import static com.android.inputmethod.latin.utils.ImportantNoticeUtils.KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE; +import static com.android.inputmethod.latin.utils.ImportantNoticeUtils.KEY_IMPORTANT_NOTICE_VERSION; + +import android.content.Context; +import android.content.SharedPreferences; +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import android.text.TextUtils; + +import java.util.concurrent.TimeUnit; + +@SmallTest +public class ImportantNoticeUtilsTests extends AndroidTestCase { + // This should be aligned with R.integer.config_important_notice_version. + private static final int CURRENT_IMPORTANT_NOTICE_VERSION = 1; + + private ImportantNoticePreferences mImportantNoticePreferences; + + private static class ImportantNoticePreferences { + private final SharedPreferences mPref; + + private Integer mVersion; + private Long mLastTime; + + public ImportantNoticePreferences(final Context context) { + mPref = ImportantNoticeUtils.getImportantNoticePreferences(context); + } + + private Integer getInt(final String key) { + if (mPref.contains(key)) { + return mPref.getInt(key, 0); + } + return null; + } + + public Long getLong(final String key) { + if (mPref.contains(key)) { + return mPref.getLong(key, 0); + } + return null; + } + + private void putInt(final String key, final Integer value) { + if (value == null) { + removePreference(key); + } else { + mPref.edit().putInt(key, value).apply(); + } + } + + private void putLong(final String key, final Long value) { + if (value == null) { + removePreference(key); + } else { + mPref.edit().putLong(key, value).apply(); + } + } + + private void removePreference(final String key) { + mPref.edit().remove(key).apply(); + } + + public void save() { + mVersion = getInt(KEY_IMPORTANT_NOTICE_VERSION); + mLastTime = getLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE); + } + + public void restore() { + putInt(KEY_IMPORTANT_NOTICE_VERSION, mVersion); + putLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE, mLastTime); + } + + public void clear() { + removePreference(KEY_IMPORTANT_NOTICE_VERSION); + removePreference(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE); + } + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + mImportantNoticePreferences = new ImportantNoticePreferences(getContext()); + mImportantNoticePreferences.save(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + mImportantNoticePreferences.restore(); + } + + public void testCurrentVersion() { + assertEquals("Current version", CURRENT_IMPORTANT_NOTICE_VERSION, + ImportantNoticeUtils.getCurrentImportantNoticeVersion(getContext())); + } + + public void testUpdateVersion() { + mImportantNoticePreferences.clear(); + + assertEquals("Current boolean before update", true, + ImportantNoticeUtils.shouldShowImportantNotice(getContext())); + assertEquals("Last version before update", 0, + ImportantNoticeUtils.getLastImportantNoticeVersion(getContext())); + assertEquals("Next version before update ", 1, + ImportantNoticeUtils.getNextImportantNoticeVersion(getContext())); + assertEquals("Current title before update", false, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeTitle(getContext()))); + assertEquals("Current contents before update", false, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeContents(getContext()))); + + ImportantNoticeUtils.updateLastImportantNoticeVersion(getContext()); + + assertEquals("Current boolean after update", false, + ImportantNoticeUtils.shouldShowImportantNotice(getContext())); + assertEquals("Last version after update", 1, + ImportantNoticeUtils.getLastImportantNoticeVersion(getContext())); + assertEquals("Next version after update", 2, + ImportantNoticeUtils.getNextImportantNoticeVersion(getContext())); + assertEquals("Current title after update", true, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeTitle(getContext()))); + assertEquals("Current contents after update", true, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeContents(getContext()))); + } + + private static void sleep(final long millseconds) { + try { Thread.sleep(millseconds); } catch (final Exception e) { /* ignore */ } + } + + public void testTimeout() { + final long lastTime = System.currentTimeMillis() + - ImportantNoticeUtils.TIMEOUT_OF_IMPORTANT_NOTICE + + TimeUnit.MILLISECONDS.toMillis(1000); + mImportantNoticePreferences.clear(); + assertEquals("Before set last time", null, + mImportantNoticePreferences.getLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE)); + assertEquals("Set last time", false, + ImportantNoticeUtils.hasTimeoutPassed(getContext(), lastTime)); + assertEquals("After set last time", (Long)lastTime, + mImportantNoticePreferences.getLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE)); + + // Call {@link ImportantNoticeUtils#shouldShowImportantNotice(Context)} before timeout. + assertEquals("Current boolean before timeout 1", true, + ImportantNoticeUtils.shouldShowImportantNotice(getContext())); + assertEquals("Last version before timeout 1", 0, + ImportantNoticeUtils.getLastImportantNoticeVersion(getContext())); + assertEquals("Next version before timeout 1", 1, + ImportantNoticeUtils.getNextImportantNoticeVersion(getContext())); + assertEquals("Last time before timeout 1", (Long)lastTime, + mImportantNoticePreferences.getLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE)); + assertEquals("Current title before timeout 1", false, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeTitle(getContext()))); + assertEquals("Current contents before timeout 1", false, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeContents(getContext()))); + + sleep(TimeUnit.MILLISECONDS.toMillis(600)); + + // Call {@link ImportantNoticeUtils#shouldShowImportantNotice(Context)} before timeout + // again. + assertEquals("Current boolean before timeout 2", true, + ImportantNoticeUtils.shouldShowImportantNotice(getContext())); + assertEquals("Last version before timeout 2", 0, + ImportantNoticeUtils.getLastImportantNoticeVersion(getContext())); + assertEquals("Next version before timeout 2", 1, + ImportantNoticeUtils.getNextImportantNoticeVersion(getContext())); + assertEquals("Last time before timeout 2", (Long)lastTime, + mImportantNoticePreferences.getLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE)); + assertEquals("Current title before timeout 2", false, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeTitle(getContext()))); + assertEquals("Current contents before timeout 2", false, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeContents(getContext()))); + + sleep(TimeUnit.MILLISECONDS.toMillis(600)); + + // Call {@link ImportantNoticeUtils#shouldShowImportantNotice(Context)} after timeout. + assertEquals("Current boolean after timeout 1", false, + ImportantNoticeUtils.shouldShowImportantNotice(getContext())); + assertEquals("Last version after timeout 1", 1, + ImportantNoticeUtils.getLastImportantNoticeVersion(getContext())); + assertEquals("Next version after timeout 1", 2, + ImportantNoticeUtils.getNextImportantNoticeVersion(getContext())); + assertEquals("Last time aflter timeout 1", null, + mImportantNoticePreferences.getLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE)); + assertEquals("Current title after timeout 1", true, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeTitle(getContext()))); + assertEquals("Current contents after timeout 1", true, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeContents(getContext()))); + + sleep(TimeUnit.MILLISECONDS.toMillis(600)); + + // Call {@link ImportantNoticeUtils#shouldShowImportantNotice(Context)} after timeout again. + assertEquals("Current boolean after timeout 2", false, + ImportantNoticeUtils.shouldShowImportantNotice(getContext())); + assertEquals("Last version after timeout 2", 1, + ImportantNoticeUtils.getLastImportantNoticeVersion(getContext())); + assertEquals("Next version after timeout 2", 2, + ImportantNoticeUtils.getNextImportantNoticeVersion(getContext())); + assertEquals("Last time aflter timeout 2", null, + mImportantNoticePreferences.getLong(KEY_TIMESTAMP_OF_FIRST_IMPORTANT_NOTICE)); + assertEquals("Current title after timeout 2", true, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeTitle(getContext()))); + assertEquals("Current contents after timeout 2", true, TextUtils.isEmpty( + ImportantNoticeUtils.getNextImportantNoticeContents(getContext()))); + } +} diff --git a/tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java new file mode 100644 index 000000000..ba2e99802 --- /dev/null +++ b/tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.utils; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +import com.android.inputmethod.latin.Constants; +import com.android.inputmethod.latin.utils.StringUtils; + +import java.util.Locale; + +@SmallTest +public class StringUtilsTests extends AndroidTestCase { + private static final Locale US = Locale.US; + private static final Locale GERMAN = Locale.GERMAN; + private static final Locale TURKEY = new Locale("tr", "TR"); + private static final Locale GREECE = new Locale("el", "GR"); + + private static void assert_toUpperCaseOfStringForLocale(final Locale locale, + final String lowerCase, final String expected) { + assertEquals(lowerCase + " in " + locale, expected, + StringUtils.toUpperCaseOfStringForLocale( + lowerCase, true /* needsToUpperCase */, locale)); + } + + public void test_toUpperCaseOfStringForLocale() { + assert_toUpperCaseOfStringForLocale(US, null, null); + assert_toUpperCaseOfStringForLocale(US, "", ""); + assert_toUpperCaseOfStringForLocale(US, "aeiou", "AEIOU"); + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+00C0: "À" LATIN CAPITAL LETTER A WITH GRAVE + // U+00C8: "È" LATIN CAPITAL LETTER E WITH GRAVE + // U+00CE: "Î" LATIN CAPITAL LETTER I WITH CIRCUMFLEX + // U+00D6: "Ö" LATIN CAPITAL LETTER O WITH DIAERESIS + // U+016A: "Ū" LATIN CAPITAL LETTER U WITH MACRON + // U+00D1: "Ñ" LATIN CAPITAL LETTER N WITH TILDE + // U+00C7: "Ç" LATIN CAPITAL LETTER C WITH CEDILLA + assert_toUpperCaseOfStringForLocale(US, + "\u00E0\u00E8\u00EE\u00F6\u016B\u00F1\u00E7", + "\u00C0\u00C8\u00CE\u00D6\u016A\u00D1\u00C7"); + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+015A: "Ś" LATIN CAPITAL LETTER S WITH ACUTE + // U+0160: "Š" LATIN CAPITAL LETTER S WITH CARONZ + assert_toUpperCaseOfStringForLocale(GERMAN, + "\u00DF\u015B\u0161", + "SS\u015A\u0160"); + // U+0259: "ə" LATIN SMALL LETTER SCHWA + // U+0069: "i" LATIN SMALL LETTER I + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + // U+018F: "Ə" LATIN SMALL LETTER SCHWA + // U+0130: "İ" LATIN SMALL LETTER I WITH DOT ABOVE + // U+0049: "I" LATIN SMALL LETTER I + assert_toUpperCaseOfStringForLocale(TURKEY, + "\u0259\u0069\u0131", + "\u018F\u0130\u0049"); + // U+03C3: "σ" GREEK SMALL LETTER SIGMA + // U+03C2: "ς" GREEK SMALL LETTER FINAL SIGMA + // U+03A3: "Σ" GREEK CAPITAL LETTER SIGMA + assert_toUpperCaseOfStringForLocale(GREECE, + "\u03C3\u03C2", + "\u03A3\u03A3"); + // U+03AC: "ά" GREEK SMALL LETTER ALPHA WITH TONOS + // U+03AD: "έ" GREEK SMALL LETTER EPSILON WITH TONOS + // U+03AE: "ή" GREEK SMALL LETTER ETA WITH TONOS + // U+03AF: "ί" GREEK SMALL LETTER IOTA WITH TONOS + // U+03CC: "ό" GREEK SMALL LETTER OMICRON WITH TONOS + // U+03CD: "ύ" GREEK SMALL LETTER UPSILON WITH TONOS + // U+03CE: "ώ" GREEK SMALL LETTER OMEGA WITH TONOS + // U+0386: "Ά" GREEK CAPITAL LETTER ALPHA WITH TONOS + // U+0388: "Έ" GREEK CAPITAL LETTER EPSILON WITH TONOS + // U+0389: "Ή" GREEK CAPITAL LETTER ETA WITH TONOS + // U+038A: "Ί" GREEK CAPITAL LETTER IOTA WITH TONOS + // U+038C: "Ό" GREEK CAPITAL LETTER OMICRON WITH TONOS + // U+038E: "Ύ" GREEK CAPITAL LETTER UPSILON WITH TONOS + // U+038F: "Ώ" GREEK CAPITAL LETTER OMEGA WITH TONOS + assert_toUpperCaseOfStringForLocale(GREECE, + "\u03AC\u03AD\u03AE\u03AF\u03CC\u03CD\u03CE", + "\u0386\u0388\u0389\u038A\u038C\u038E\u038F"); + // U+03CA: "ϊ" GREEK SMALL LETTER IOTA WITH DIALYTIKA + // U+03CB: "ϋ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA + // U+0390: "ΐ" GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS + // U+03B0: "ΰ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS + // U+03AA: "Ϊ" GREEK CAPITAL LETTER IOTA WITH DIALYTIKA + // U+03AB: "Ϋ" GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA + // U+0399: "Ι" GREEK CAPITAL LETTER IOTA + // U+03A5: "Υ" GREEK CAPITAL LETTER UPSILON + // U+0308: COMBINING DIAERESIS + // U+0301: COMBINING GRAVE ACCENT + assert_toUpperCaseOfStringForLocale(GREECE, + "\u03CA\u03CB\u0390\u03B0", + "\u03AA\u03AB\u0399\u0308\u0301\u03A5\u0308\u0301"); + } + + private static void assert_toUpperCaseOfCodeForLocale(final Locale locale, final int lowerCase, + final int expected) { + assertEquals(lowerCase + " in " + locale, expected, + StringUtils.toUpperCaseOfCodeForLocale( + lowerCase, true /* needsToUpperCase */, locale)); + } + + public void test_toUpperCaseOfCodeForLocale() { + assert_toUpperCaseOfCodeForLocale(US, Constants.CODE_ENTER, Constants.CODE_ENTER); + assert_toUpperCaseOfCodeForLocale(US, Constants.CODE_SPACE, Constants.CODE_SPACE); + assert_toUpperCaseOfCodeForLocale(US, Constants.CODE_COMMA, Constants.CODE_COMMA); + // U+0069: "i" LATIN SMALL LETTER I + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + // U+0130: "İ" LATIN SMALL LETTER I WITH DOT ABOVE + // U+0049: "I" LATIN SMALL LETTER I + assert_toUpperCaseOfCodeForLocale(US, 0x0069, 0x0049); // i -> I + assert_toUpperCaseOfCodeForLocale(US, 0x0131, 0x0049); // ı -> I + assert_toUpperCaseOfCodeForLocale(TURKEY, 0x0069, 0x0130); // i -> İ + assert_toUpperCaseOfCodeForLocale(TURKEY, 0x0131, 0x0049); // ı -> I + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // The title case of "ß" is "SS". + assert_toUpperCaseOfCodeForLocale(US, 0x00DF, Constants.CODE_UNSPECIFIED); + // U+03AC: "ά" GREEK SMALL LETTER ALPHA WITH TONOS + // U+0386: "Ά" GREEK CAPITAL LETTER ALPHA WITH TONOS + assert_toUpperCaseOfCodeForLocale(GREECE, 0x03AC, 0x0386); + // U+03CA: "ϊ" GREEK SMALL LETTER IOTA WITH DIALYTIKA + // U+03AA: "Ϊ" GREEK CAPITAL LETTER IOTA WITH DIALYTIKA + assert_toUpperCaseOfCodeForLocale(GREECE, 0x03CA, 0x03AA); + // U+03B0: "ΰ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS + // The title case of "ΰ" is "\u03A5\u0308\u0301". + assert_toUpperCaseOfCodeForLocale(GREECE, 0x03B0, Constants.CODE_UNSPECIFIED); + } + + private static void assert_capitalizeFirstCodePoint(final Locale locale, final String text, + final String expected) { + assertEquals(text + " in " + locale, expected, + StringUtils.capitalizeFirstCodePoint(text, locale)); + } + + public void test_capitalizeFirstCodePoint() { + assert_capitalizeFirstCodePoint(US, "", ""); + assert_capitalizeFirstCodePoint(US, "a", "A"); + assert_capitalizeFirstCodePoint(US, "à", "À"); + assert_capitalizeFirstCodePoint(US, "ß", "SS"); + assert_capitalizeFirstCodePoint(US, "text", "Text"); + assert_capitalizeFirstCodePoint(US, "iGoogle", "IGoogle"); + assert_capitalizeFirstCodePoint(TURKEY, "iyi", "İyi"); + assert_capitalizeFirstCodePoint(TURKEY, "ısırdı", "Isırdı"); + assert_capitalizeFirstCodePoint(GREECE, "ά", "Ά"); + assert_capitalizeFirstCodePoint(GREECE, "άνεση", "Άνεση"); + } + + private static void assert_capitalizeFirstAndDowncaseRest(final Locale locale, + final String text, final String expected) { + assertEquals(text + " in " + locale, expected, + StringUtils.capitalizeFirstAndDowncaseRest(text, locale)); + } + + public void test_capitalizeFirstAndDowncaseRest() { + assert_capitalizeFirstAndDowncaseRest(US, "", ""); + assert_capitalizeFirstAndDowncaseRest(US, "a", "A"); + assert_capitalizeFirstAndDowncaseRest(US, "à", "À"); + assert_capitalizeFirstAndDowncaseRest(US, "ß", "SS"); + assert_capitalizeFirstAndDowncaseRest(US, "text", "Text"); + assert_capitalizeFirstAndDowncaseRest(US, "iGoogle", "Igoogle"); + assert_capitalizeFirstAndDowncaseRest(US, "invite", "Invite"); + assert_capitalizeFirstAndDowncaseRest(US, "INVITE", "Invite"); + assert_capitalizeFirstAndDowncaseRest(TURKEY, "iyi", "İyi"); + assert_capitalizeFirstAndDowncaseRest(TURKEY, "İYİ", "İyi"); + assert_capitalizeFirstAndDowncaseRest(TURKEY, "ısırdı", "Isırdı"); + assert_capitalizeFirstAndDowncaseRest(TURKEY, "ISIRDI", "Isırdı"); + assert_capitalizeFirstAndDowncaseRest(GREECE, "ά", "Ά"); + assert_capitalizeFirstAndDowncaseRest(GREECE, "άνεση", "Άνεση"); + assert_capitalizeFirstAndDowncaseRest(GREECE, "ΆΝΕΣΗ", "Άνεση"); + } +} |