1/* 2 * Copyright (C) 2006 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 17package com.android.internal.telephony; 18 19import android.os.ServiceManager; 20import android.test.suitebuilder.annotation.MediumTest; 21import android.test.suitebuilder.annotation.Suppress; 22 23import java.util.List; 24 25import junit.framework.TestCase; 26 27public class SimSmsTest extends TestCase { 28 29 @MediumTest 30 @Suppress // TODO: suppress this test for now since it doesn't work on the emulator 31 public void testBasic() throws Exception { 32 33 ISms sms = ISms.Stub.asInterface(ServiceManager.getService("isms")); 34 assertNotNull(sms); 35 36 List<SmsRawData> records = sms.getAllMessagesFromIccEf(); 37 assertNotNull(records); 38 assertTrue(records.size() >= 0); 39 40 int firstNullIndex = -1; 41 int firstValidIndex = -1; 42 byte[] pdu = null; 43 for (int i = 0; i < records.size(); i++) { 44 SmsRawData data = records.get(i); 45 if (data != null && firstValidIndex == -1) { 46 firstValidIndex = i; 47 pdu = data.getBytes(); 48 } 49 if (data == null && firstNullIndex == -1) { 50 firstNullIndex = i; 51 } 52 if (firstNullIndex != -1 && firstValidIndex != -1) { 53 break; 54 } 55 } 56 if (firstNullIndex == -1 || firstValidIndex == -1) 57 return; 58 assertNotNull(pdu); 59 } 60} 61