1 /* 2 * Copyright (C) 2009 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.contacts; 18 19 import android.content.Intent; 20 import android.provider.ContactsContract.CommonDataKinds.Phone; 21 import android.test.AndroidTestCase; 22 import android.test.suitebuilder.annotation.SmallTest; 23 24 import com.android.contacts.common.MoreContactUtils; 25 26 /** 27 * Tests for {@link ContactsUtils}. 28 */ 29 @SmallTest 30 public class ContactsUtilsTests extends AndroidTestCase { 31 32 public void testIsGraphicNull() throws Exception { 33 assertFalse(ContactsUtils.isGraphic(null)); 34 } 35 36 public void testIsGraphicEmpty() throws Exception { 37 assertFalse(ContactsUtils.isGraphic("")); 38 } 39 40 public void testIsGraphicSpaces() throws Exception { 41 assertFalse(ContactsUtils.isGraphic(" ")); 42 } 43 44 public void testIsGraphicPunctuation() throws Exception { 45 assertTrue(ContactsUtils.isGraphic(".")); 46 } 47 48 public void testAreObjectsEqual() throws Exception { 49 assertTrue("null:null", ContactsUtils.areObjectsEqual(null, null)); 50 assertTrue("1:1", ContactsUtils.areObjectsEqual(1, 1)); 51 52 assertFalse("null:1", ContactsUtils.areObjectsEqual(null, 1)); 53 assertFalse("1:null", ContactsUtils.areObjectsEqual(1, null)); 54 assertFalse("1:2", ContactsUtils.areObjectsEqual(1, 2)); 55 } 56 57 public void testAreIntentActionEqual() throws Exception { 58 assertTrue("1", ContactsUtils.areIntentActionEqual(null, null)); 59 assertTrue("1", ContactsUtils.areIntentActionEqual(new Intent("a"), new Intent("a"))); 60 61 assertFalse("11", ContactsUtils.areIntentActionEqual(new Intent("a"), null)); 62 assertFalse("12", ContactsUtils.areIntentActionEqual(null, new Intent("a"))); 63 64 assertFalse("21", ContactsUtils.areIntentActionEqual(new Intent("a"), new Intent())); 65 assertFalse("22", ContactsUtils.areIntentActionEqual(new Intent(), new Intent("b"))); 66 assertFalse("23", ContactsUtils.areIntentActionEqual(new Intent("a"), new Intent("b"))); 67 } 68 } 69