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