blob: 2d29c7b77759bb35c4ed3361228e405b7621ae07 [file] [log] [blame]
Tony Mak1d07be32019-01-02 15:14:32 +00001/**
2 * Copyright (C) 2018 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 */
16package android.ext.services.notification;
17
18import static com.google.common.truth.Truth.assertThat;
19
20import android.support.test.runner.AndroidJUnit4;
21import android.view.textclassifier.TextClassifier;
22
23import org.junit.Before;
24import org.junit.Test;
25import org.junit.runner.RunWith;
26
27@RunWith(AndroidJUnit4.class)
28public class EntityTypeCounterTest {
29 private EntityTypeCounter mCounter;
30
31 @Before
32 public void setup() {
33 mCounter = new EntityTypeCounter();
34 }
35
36 @Test
37 public void testIncrementAndGetCount() {
38 mCounter.increment(TextClassifier.TYPE_URL);
39 mCounter.increment(TextClassifier.TYPE_URL);
40 mCounter.increment(TextClassifier.TYPE_URL);
41
42 mCounter.increment(TextClassifier.TYPE_PHONE);
43 mCounter.increment(TextClassifier.TYPE_PHONE);
44
45 assertThat(mCounter.getCount(TextClassifier.TYPE_URL)).isEqualTo(3);
46 assertThat(mCounter.getCount(TextClassifier.TYPE_PHONE)).isEqualTo(2);
47 assertThat(mCounter.getCount(TextClassifier.TYPE_DATE_TIME)).isEqualTo(0);
48 }
49
50 @Test
51 public void testIncrementAndGetCount_typeDateAndDateTime() {
52 mCounter.increment(TextClassifier.TYPE_DATE_TIME);
53 mCounter.increment(TextClassifier.TYPE_DATE);
54
55 assertThat(mCounter.getCount(TextClassifier.TYPE_DATE_TIME)).isEqualTo(2);
56 assertThat(mCounter.getCount(TextClassifier.TYPE_DATE)).isEqualTo(2);
57 }
58}