diff options
author | 2024-12-16 21:45:41 -0500 | |
---|---|---|
committer | 2025-01-11 14:17:35 -0500 | |
commit | e9a0e66716dab4dd3184d009d8920de1961efdfa (patch) | |
tree | 02dcc096643d74645bf28459c2834c3d4a2ad7f2 /tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java | |
parent | fb3b9360d70596d7e921de8bf7d3ca99564a077e (diff) | |
download | latinime-e9a0e66716dab4dd3184d009d8920de1961efdfa.tar.gz latinime-e9a0e66716dab4dd3184d009d8920de1961efdfa.tar.xz latinime-e9a0e66716dab4dd3184d009d8920de1961efdfa.zip |
Rename to Kelar Keyboard (org.kelar.inputmethod.latin)
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java | 235 |
1 files changed, 0 insertions, 235 deletions
diff --git a/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java b/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java deleted file mode 100644 index 3706574ef..000000000 --- a/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * 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 static junit.framework.TestCase.assertEquals; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import com.android.inputmethod.latin.SuggestedWords; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@SmallTest -@RunWith(AndroidJUnit4.class) -public class SuggestionStripLayoutHelperTests { - 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 */)); - } - - @Test - 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); - } - - @Test - 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 */)); - } - - @Test - 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 */)); - } - - @Test - 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; - - @Test - 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 */)); - } -} |