blob: ada61d0488c9fcb802fa407ccc15a02fac1b226f [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
Tony Mak1d07be32019-01-02 15:14:32 +000020import android.view.textclassifier.TextClassifier;
21
Brett Chabot84151d92019-02-27 15:37:59 -080022import androidx.test.runner.AndroidJUnit4;
23
Tony Mak1d07be32019-01-02 15:14:32 +000024import org.junit.Before;
25import org.junit.Test;
26import org.junit.runner.RunWith;
27
28@RunWith(AndroidJUnit4.class)
29public class EntityTypeCounterTest {
30 private EntityTypeCounter mCounter;
31
32 @Before
33 public void setup() {
34 mCounter = new EntityTypeCounter();
35 }
36
37 @Test
38 public void testIncrementAndGetCount() {
39 mCounter.increment(TextClassifier.TYPE_URL);
40 mCounter.increment(TextClassifier.TYPE_URL);
41 mCounter.increment(TextClassifier.TYPE_URL);
42
43 mCounter.increment(TextClassifier.TYPE_PHONE);
44 mCounter.increment(TextClassifier.TYPE_PHONE);
45
46 assertThat(mCounter.getCount(TextClassifier.TYPE_URL)).isEqualTo(3);
47 assertThat(mCounter.getCount(TextClassifier.TYPE_PHONE)).isEqualTo(2);
48 assertThat(mCounter.getCount(TextClassifier.TYPE_DATE_TIME)).isEqualTo(0);
49 }
50
51 @Test
52 public void testIncrementAndGetCount_typeDateAndDateTime() {
53 mCounter.increment(TextClassifier.TYPE_DATE_TIME);
54 mCounter.increment(TextClassifier.TYPE_DATE);
55
56 assertThat(mCounter.getCount(TextClassifier.TYPE_DATE_TIME)).isEqualTo(2);
57 assertThat(mCounter.getCount(TextClassifier.TYPE_DATE)).isEqualTo(2);
58 }
59}