Home | History | Annotate | Download | only in util
      1 /*
      2  * Copyright (C) 2011 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.mms.util;
     18 
     19 import android.content.Context;
     20 import android.provider.Telephony.Threads;
     21 import android.test.AndroidTestCase;
     22 import android.test.suitebuilder.annotation.SmallTest;
     23 
     24 import com.android.mms.data.Conversation;
     25 
     26 /**
     27  * This is a series of unit tests for Conversation's verifyRecipients function.
     28  *
     29  * To run just this test:
     30  *       runtest --test-class=com.android.mms.util.VerifyRecipientUnitTests mms
     31  */
     32 @SmallTest
     33 public class VerifyRecipientUnitTests extends AndroidTestCase {
     34     private long mThreadId1;
     35     private long mThreadId2;
     36     private long mThreadId3;
     37 
     38     @Override
     39     protected void setUp() throws Exception {
     40         super.setUp();
     41 
     42         Context context = getContext();
     43         mThreadId1 = Threads.getOrCreateThreadId(context, "232-4567");
     44         mThreadId2 = Threads.getOrCreateThreadId(context, "flintstone_fred (at) goofball.org");
     45         mThreadId3 = Threads.getOrCreateThreadId(context, "(801) 123-4567");
     46     }
     47 
     48     /**
     49      * Test of verifyRecipients.
     50      */
     51     public void testVerifyRecipients() {
     52         assertEquals("Numbers aren't equal",
     53                 Conversation.verifySingleRecipient(getContext(), mThreadId1, "(415) 232-4567"),
     54                 "(415) 232-4567");
     55 
     56         assertEquals("Numbers aren't equal",
     57                 Conversation.verifySingleRecipient(getContext(), mThreadId1, " 232-4567"),
     58                 "232-4567");
     59     }
     60 }
     61