• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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 android.provider.cts.contacts;
18 
19 import android.content.Context;
20 import android.provider.Contacts.Phones;
21 import android.test.AndroidTestCase;
22 
23 public class Contacts_PhonesTest extends AndroidTestCase {
testGetDisplayLabel()24     public void testGetDisplayLabel() {
25         CharSequence label = "label";
26         String display = Phones.getDisplayLabel(getContext(),
27                 Phones.TYPE_CUSTOM, label).toString();
28         assertEquals(label, display);
29     }
30 
testGetDisplayLabelCharSequenceArray()31     public void testGetDisplayLabelCharSequenceArray() {
32         CharSequence label = "label";
33         CharSequence[] labelArray = new CharSequence[] {
34                 "1 home",
35                 "2 mobile",
36                 "3 work",
37                 "4 fax work",
38                 "5 fax home",
39                 "6 pager",
40                 "7 other"};
41 
42         String display = Phones.getDisplayLabel(getContext(),
43                 Phones.TYPE_CUSTOM, label, labelArray).toString();
44         assertEquals(label, display);
45 
46         display = Phones.getDisplayLabel(getContext(),
47                 Phones.TYPE_HOME, label, labelArray).toString();
48         assertEquals(labelArray[Phones.TYPE_HOME - 1], display);
49 
50         display = Phones.getDisplayLabel(getContext(),
51                 Phones.TYPE_MOBILE, label, labelArray).toString();
52         assertEquals(labelArray[Phones.TYPE_MOBILE - 1], display);
53 
54         display = Phones.getDisplayLabel(getContext(),
55                 Phones.TYPE_WORK, label, labelArray).toString();
56         assertEquals(labelArray[Phones.TYPE_WORK - 1], display);
57 
58         display = Phones.getDisplayLabel(getContext(),
59                 Phones.TYPE_FAX_WORK, label, labelArray).toString();
60         assertEquals(labelArray[Phones.TYPE_FAX_WORK - 1], display);
61 
62         display = Phones.getDisplayLabel(getContext(),
63                 Phones.TYPE_FAX_HOME, label, labelArray).toString();
64         assertEquals(labelArray[Phones.TYPE_FAX_HOME - 1], display);
65 
66         display = Phones.getDisplayLabel(getContext(),
67                 Phones.TYPE_PAGER, label, labelArray).toString();
68         assertEquals(labelArray[Phones.TYPE_PAGER - 1], display);
69 
70         display = Phones.getDisplayLabel(getContext(),
71                 Phones.TYPE_OTHER, label, labelArray).toString();
72         assertEquals(labelArray[Phones.TYPE_OTHER - 1], display);
73     }
74 }
75