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.dialer.util; 18 19 import com.android.dialer.calllog.PhoneCallDetailsHelper; 20 import com.google.common.collect.Lists; 21 22 import android.content.Context; 23 import android.content.res.Resources; 24 import android.test.AndroidTestCase; 25 import android.test.suitebuilder.annotation.SmallTest; 26 27 import java.util.ArrayList; 28 29 /** 30 * Performs tests of the DialerUtils class. 31 */ 32 @SmallTest 33 public class DialerUtilsTest extends AndroidTestCase { 34 35 private Resources mResources; 36 37 /** 38 * List of items to be concatenated together for CharSequence join tests. 39 */ 40 private ArrayList<CharSequence> mItems = Lists.newArrayList(); 41 42 @Override 43 protected void setUp() throws Exception { 44 super.setUp(); 45 Context context = getContext(); 46 mResources = context.getResources(); 47 } 48 49 /** 50 * Tests joining an empty list of {@link CharSequence}. 51 */ 52 public void testJoinEmpty() { 53 mItems.clear(); 54 CharSequence joined = DialerUtils.join(mResources, mItems); 55 assertEquals("", joined); 56 } 57 58 /** 59 * Tests joining a list of {@link CharSequence} with a single entry. 60 */ 61 public void testJoinOne() { 62 mItems.clear(); 63 mItems.add("Hello"); 64 CharSequence joined = DialerUtils.join(mResources, mItems); 65 assertEquals("Hello", joined); 66 } 67 68 /** 69 * Tests joining a list of {@link CharSequence} with a multiple entries. 70 */ 71 public void testJoinTwo() { 72 mItems.clear(); 73 mItems.add("Hello"); 74 mItems.add("there"); 75 CharSequence joined = DialerUtils.join(mResources, mItems); 76 assertEquals("Hello, there", joined); 77 } 78 } 79