blob: 984eede5568431661a4eaf1c9de867ea58a14df5 [file] [log] [blame]
Jan Althaus0aacdb62018-02-19 11:44:37 +01001/*
2 * Copyright (C) 2017 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
17package android.view.textclassifier;
18
19import static org.junit.Assert.assertEquals;
20
21import android.support.test.filters.SmallTest;
22import android.support.test.runner.AndroidJUnit4;
23
24import org.junit.Test;
25import org.junit.runner.RunWith;
26
27@SmallTest
28@RunWith(AndroidJUnit4.class)
29public class TextClassifierConstantsTest {
30
31 @Test
32 public void testEntityListParsing() {
33 final TextClassifierConstants constants = TextClassifierConstants.loadFromString(
34 "entity_list_default=phone,"
35 + "entity_list_not_editable=address:flight,"
36 + "entity_list_editable=date:datetime");
37 assertEquals(1, constants.getEntityListDefault().size());
38 assertEquals("phone", constants.getEntityListDefault().get(0));
39 assertEquals(2, constants.getEntityListNotEditable().size());
40 assertEquals("address", constants.getEntityListNotEditable().get(0));
41 assertEquals("flight", constants.getEntityListNotEditable().get(1));
42 assertEquals(2, constants.getEntityListEditable().size());
43 assertEquals("date", constants.getEntityListEditable().get(0));
44 assertEquals("datetime", constants.getEntityListEditable().get(1));
45 }
46}