Merge "Add tests for HandwritingGestures" into udc-dev
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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 android.view.inputmethod;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import android.graphics.RectF;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.compatibility.common.util.ApiTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@ApiTest(apis = {"android.view.inputmethod.DeleteRangeGesture.Builder#setGranularity",
|
||||
"android.view.inputmethod.DeleteRangeGesture.Builder#setDeletionStartArea",
|
||||
"android.view.inputmethod.DeleteRangeGesture.Builder#setDeletionEndArea",
|
||||
"android.view.inputmethod.DeleteRangeGesture.Builder#setFallbackText",
|
||||
"android.view.inputmethod.DeleteRangeGesture.Builder#build"})
|
||||
public class DeleteRangeGestureTest {
|
||||
private static final RectF DELETION_START_RECTANGLE = new RectF(1, 2, 3, 4);
|
||||
private static final RectF DELETION_END_RECTANGLE = new RectF(0, 2, 3, 4);
|
||||
private static final String FALLBACK_TEXT = "fallback_test";
|
||||
|
||||
@Test
|
||||
public void testBuilder() {
|
||||
DeleteRangeGesture.Builder builder = new DeleteRangeGesture.Builder();
|
||||
DeleteRangeGesture gesture = builder.setGranularity(HandwritingGesture.GRANULARITY_WORD)
|
||||
.setDeletionStartArea(DELETION_START_RECTANGLE)
|
||||
.setDeletionEndArea(DELETION_END_RECTANGLE)
|
||||
.setFallbackText(FALLBACK_TEXT).build();
|
||||
assertNotNull(gesture);
|
||||
assertEquals(HandwritingGesture.GRANULARITY_WORD, gesture.getGranularity());
|
||||
assertEquals(DELETION_START_RECTANGLE, gesture.getDeletionStartArea());
|
||||
assertEquals(DELETION_END_RECTANGLE, gesture.getDeletionEndArea());
|
||||
assertEquals(FALLBACK_TEXT, gesture.getFallbackText());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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 android.view.inputmethod;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.compatibility.common.util.ApiTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@ApiTest(apis = {"android.view.inputmethod.InsertGesture.Builder#setInsertionPoint",
|
||||
"android.view.inputmethod.InsertGesture.Builder#setTextToInsert",
|
||||
"android.view.inputmethod.InsertGesture.Builder#setFallbackText",
|
||||
"android.view.inputmethod.InsertGesture.Builder#build"})
|
||||
public class InsertGestureTest {
|
||||
private static final PointF INSERTION_POINT = new PointF(1, 2);
|
||||
private static final String FALLBACK_TEXT = "fallback_text";
|
||||
private static final String TEXT_TO_INSERT = "text";
|
||||
|
||||
@Test
|
||||
public void testBuilder() {
|
||||
InsertGesture.Builder builder = new InsertGesture.Builder();
|
||||
InsertGesture gesture = builder.setInsertionPoint(INSERTION_POINT)
|
||||
.setTextToInsert(TEXT_TO_INSERT)
|
||||
.setFallbackText(FALLBACK_TEXT).build();
|
||||
assertNotNull(gesture);
|
||||
assertEquals(INSERTION_POINT, gesture.getInsertionPoint());
|
||||
assertEquals(FALLBACK_TEXT, gesture.getFallbackText());
|
||||
assertEquals(TEXT_TO_INSERT, gesture.getTextToInsert());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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 android.view.inputmethod;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.os.CancellationSignal;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.compatibility.common.util.ApiTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@ApiTest(apis = {"android.view.inputmethod.InsertModeGesture.Builder#setInsertionPoint",
|
||||
"android.view.inputmethod.InsertModeGesture.Builder#setCancellationSignal",
|
||||
"android.view.inputmethod.InsertModeGesture.Builder#setFallbackText",
|
||||
"android.view.inputmethod.InsertModeGesture.Builder#build"})
|
||||
public class InsertModeGestureTest {
|
||||
private static final PointF INSERTION_POINT = new PointF(1, 2);
|
||||
private static final String FALLBACK_TEXT = "fallback_text";
|
||||
private static final CancellationSignal CANCELLATION_SIGNAL = new CancellationSignal();
|
||||
|
||||
@Test
|
||||
public void testBuilder() {
|
||||
InsertModeGesture.Builder builder = new InsertModeGesture.Builder();
|
||||
InsertModeGesture gesture = builder.setInsertionPoint(INSERTION_POINT)
|
||||
.setCancellationSignal(CANCELLATION_SIGNAL)
|
||||
.setFallbackText(FALLBACK_TEXT).build();
|
||||
assertNotNull(gesture);
|
||||
assertEquals(INSERTION_POINT, gesture.getInsertionPoint());
|
||||
assertEquals(FALLBACK_TEXT, gesture.getFallbackText());
|
||||
assertEquals(CANCELLATION_SIGNAL, gesture.getCancellationSignal());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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 android.view.inputmethod;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import android.graphics.RectF;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.compatibility.common.util.ApiTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@ApiTest(apis = {"android.view.inputmethod.SelectGesture.Builder#setGranularity",
|
||||
"android.view.inputmethod.SelectGesture.Builder#setSelectionArea",
|
||||
"android.view.inputmethod.SelectGesture.Builder#setFallbackText",
|
||||
"android.view.inputmethod.SelectGesture.Builder#build"})
|
||||
public class SelectGestureTest {
|
||||
private static final RectF SELECTION_RECTANGLE = new RectF(1, 2, 3, 4);
|
||||
private static final String FALLBACK_TEXT = "fallback_text";
|
||||
|
||||
@Test
|
||||
public void testBuilder() {
|
||||
SelectGesture.Builder builder = new SelectGesture.Builder();
|
||||
SelectGesture gesture = builder.setGranularity(HandwritingGesture.GRANULARITY_WORD)
|
||||
.setSelectionArea(SELECTION_RECTANGLE)
|
||||
.setFallbackText(FALLBACK_TEXT).build();
|
||||
assertNotNull(gesture);
|
||||
assertEquals(HandwritingGesture.GRANULARITY_WORD, gesture.getGranularity());
|
||||
assertEquals(SELECTION_RECTANGLE, gesture.getSelectionArea());
|
||||
assertEquals(FALLBACK_TEXT, gesture.getFallbackText());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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 android.view.inputmethod;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import android.graphics.RectF;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.compatibility.common.util.ApiTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@ApiTest(apis = {"android.view.inputmethod.SelectRangeGesture.Builder#setGranularity",
|
||||
"android.view.inputmethod.SelectRangeGesture.Builder#setSelectionStartArea",
|
||||
"android.view.inputmethod.SelectRangeGesture.Builder#setSelectionEndArea",
|
||||
"android.view.inputmethod.SelectRangeGesture.Builder#setFallbackText",
|
||||
"android.view.inputmethod.SelectRangeGesture.Builder#build"})
|
||||
public class SelectRangeGestureTest {
|
||||
private static final RectF SELECTION_START_RECTANGLE = new RectF(1, 2, 3, 4);
|
||||
private static final RectF SELECTION_END_RECTANGLE = new RectF(0, 2, 3, 4);
|
||||
private static final String FALLBACK_TEXT = "fallback_text";
|
||||
|
||||
@Test
|
||||
public void testBuilder() {
|
||||
SelectRangeGesture.Builder builder = new SelectRangeGesture.Builder();
|
||||
SelectRangeGesture gesture = builder.setGranularity(HandwritingGesture.GRANULARITY_WORD)
|
||||
.setSelectionStartArea(SELECTION_START_RECTANGLE)
|
||||
.setSelectionEndArea(SELECTION_END_RECTANGLE)
|
||||
.setFallbackText(FALLBACK_TEXT).build();
|
||||
assertNotNull(gesture);
|
||||
assertEquals(HandwritingGesture.GRANULARITY_WORD, gesture.getGranularity());
|
||||
assertEquals(SELECTION_START_RECTANGLE, gesture.getSelectionStartArea());
|
||||
assertEquals(SELECTION_END_RECTANGLE, gesture.getSelectionEndArea());
|
||||
assertEquals(FALLBACK_TEXT, gesture.getFallbackText());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user