1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.inputmethod.latin.touchinputconsumer;
18 
19 import static org.junit.Assert.assertFalse;
20 import static org.junit.Assert.assertSame;
21 
22 import androidx.test.filters.SmallTest;
23 import androidx.test.runner.AndroidJUnit4;
24 
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 
28 /**
29  * Tests for GestureConsumer.NULL_GESTURE_CONSUMER.
30  */
31 @SmallTest
32 @RunWith(AndroidJUnit4.class)
33 public class NullGestureConsumerTests {
34     /**
35      * Tests that GestureConsumer.NULL_GESTURE_CONSUMER indicates that it won't consume gesture data
36      * and that its methods don't raise exceptions even for invalid data.
37      */
38     @Test
testNullGestureConsumer()39     public void testNullGestureConsumer() {
40         assertFalse(GestureConsumer.NULL_GESTURE_CONSUMER.willConsume());
41         GestureConsumer.NULL_GESTURE_CONSUMER.onInit(null, null);
42         GestureConsumer.NULL_GESTURE_CONSUMER.onGestureStarted(null, null);
43         GestureConsumer.NULL_GESTURE_CONSUMER.onGestureCanceled();
44         GestureConsumer.NULL_GESTURE_CONSUMER.onGestureCompleted(null);
45         GestureConsumer.NULL_GESTURE_CONSUMER.onImeSuggestionsProcessed(null, -1, -1, null);
46     }
47 
48     /**
49      * Tests that newInstance returns NULL_GESTURE_CONSUMER for invalid input.
50      */
51     @Test
testNewInstanceGivesNullGestureConsumerForInvalidInputs()52     public void testNewInstanceGivesNullGestureConsumerForInvalidInputs() {
53         assertSame(GestureConsumer.NULL_GESTURE_CONSUMER,
54                 GestureConsumer.newInstance(null, null, null, null));
55     }
56 }
57