Home | History | Annotate | Download | only in mms
      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;
     18 
     19 import android.os.Bundle;
     20 import android.test.InstrumentationTestRunner;
     21 import android.test.InstrumentationTestSuite;
     22 
     23 import com.android.mms.ui.MultiPartSmsTests;
     24 import com.android.mms.ui.SmsStressTest;
     25 
     26 import junit.framework.TestSuite;
     27 
     28 /**
     29  * TestRunner for Sms tests
     30  * To run the test type command
     31  * adb shell am instrument -e recipient 6509339530 -e messages 10
     32  * -e messagefile words -e recipientfile recipients -e receivetimer 180
     33  * -e sendinterval 10 -w com.android.mms.tests/com.android.mms.SmsTestRunner
     34  */
     35 public class SmsTestRunner extends InstrumentationTestRunner{
     36     // a single recipient, default is the local number
     37     public String mRecipient = null;
     38     // number of messages to send
     39     public int mNumberMessages = 0;
     40     // file used to store a message (under /data/data/com.android.mms/files/)
     41     public String mMessageFileName = null;
     42     // file to store recipients separated by comma (/data/data/com.android.mms/files/)
     43     public String mRecipientFileName = null;
     44     // timer (in ms) to wait before checking receiving message
     45     public long mReceiveTimer = 0;
     46     // time interval (in ms) between two consecutive messages
     47     public long mSendInterval = 0;
     48 
     49     @Override
     50     public TestSuite getAllTests() {
     51         TestSuite suite = new InstrumentationTestSuite(this);
     52         // create a test suite
     53         suite.addTestSuite(MultiPartSmsTests.class);
     54         suite.addTestSuite(SmsStressTest.class);
     55         return suite;
     56     }
     57 
     58     @Override
     59     public ClassLoader getLoader() {
     60         return SmsTestRunner.class.getClassLoader();
     61     }
     62 
     63     @Override
     64     public void onCreate(Bundle icicle) {
     65         super.onCreate(icicle);
     66 
     67         // parse all input arguments
     68         String recipientPhoneNumber = (String) icicle.get("recipient");
     69         if (recipientPhoneNumber != null) {
     70             mRecipient = recipientPhoneNumber;
     71         }
     72         String numMsgStr = (String) icicle.get("messages");
     73         if (numMsgStr != null) {
     74             mNumberMessages = Integer.parseInt(numMsgStr);
     75         }
     76         String msgFileNameStr = (String) icicle.get("messagefile");
     77         if (msgFileNameStr != null) {
     78             mMessageFileName = msgFileNameStr;
     79         }
     80         String recpFileNameStr = (String) icicle.get("recipientfile");
     81         if (recpFileNameStr != null) {
     82             mRecipientFileName = recpFileNameStr;
     83         }
     84         // user input is by seconds, convert to ms
     85         String receiveTimerStr = (String) icicle.get("receivetimer");
     86         if (receiveTimerStr != null) {
     87             mReceiveTimer = (long)1000 * Integer.parseInt(receiveTimerStr);
     88         }
     89         // user input is by seconds, convert to ms
     90         String sendIntervalStr = (String) icicle.get("sendinterval");
     91         if (sendIntervalStr != null) {
     92             mSendInterval = (long)1000 * Integer.parseInt(sendIntervalStr);
     93         }
     94     }
     95 }
     96