Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5429d67 authored by sqian's avatar sqian Committed by android-build-merger
Browse files

Merge "Tests modification for Telephony System Api changes" into pi-dev

am: d0234544

Change-Id: I6469d2b93ae00c7c6143a51617001d9cab7d9475
parents d8b38658 d0234544
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ public class SmsMessageTest {
        // should return null instead of SmsMessage with null wrappedMessage
        assertEquals(null, SmsMessage.createFromPdu(null, SmsConstants.FORMAT_3GPP2));
        assertEquals(null, SmsMessage.createFromPdu(null, SmsConstants.FORMAT_3GPP));
        assertEquals(null, SmsMessage.createFromPdu(null));
        assertEquals(null, SmsMessage.newFromCMT(null));
    }
}
+32 −2
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.internal.telephony;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import android.telephony.TelephonyManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.internal.telephony.gsm.SmsMessage;
@@ -25,9 +28,24 @@ import com.android.internal.util.HexDump;

import java.util.ArrayList;

public class GsmSmsTest extends AndroidTestCase {
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class GsmSmsTest extends TelephonyTest {

    @Before
    public void setUp() throws Exception {
        super.setUp(this.getClass().getSimpleName());
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }

    @SmallTest
    @Test
    public void testAddressing() throws Exception {
        String pdu = "07914151551512f2040B916105551511f100006060605130308A04D4F29C0E";
        SmsMessage sms = SmsMessage.createFromPdu(HexDump.hexStringToByteArray(pdu));
@@ -48,6 +66,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUdh() throws Exception {
        String pdu = "07914140279510F6440A8111110301003BF56080207130138A8C0B05040B8423F"
                + "000032A02010106276170706C69636174696F6E2F766E642E7761702E6D6D732D"
@@ -86,6 +105,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUcs2() throws Exception {
        String pdu = "07912160130300F4040B914151245584F600087010807121352B1021220"
                + "0A900AE00680065006C006C006F";
@@ -94,6 +114,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testMultipart() throws Exception {
        /*
         * Multi-part text SMS with septet data.
@@ -118,6 +139,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testCPHSVoiceMail() throws Exception {
        // "set MWI flag"

@@ -151,6 +173,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testCingularVoiceMail() throws Exception {
        // "set MWI flag"

@@ -170,6 +193,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testEmailGateway() throws Exception {
        String pdu = "07914151551512f204038105f300007011103164638a28e6f71b50c687db" +
                "7076d9357eb7412f7a794e07cdeb6275794c07bde8e5391d247e93f3";
@@ -201,6 +225,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testExtendedCharacterTable() throws Exception {
        String pdu = "07914151551512f2040B916105551511f100006080615131728A44D4F29C0E2" +
                "AE3E96537B94C068DD16179784C2FCB41F4B0985D06B958ADD00FB0E94536AF9749" +
@@ -239,6 +264,7 @@ public class GsmSmsTest extends AndroidTestCase {
    };

    @SmallTest
    @Test
    public void testFragmentText() throws Exception {
        boolean isGsmPhone = (TelephonyManager.getDefault().getPhoneType() ==
                TelephonyManager.PHONE_TYPE_GSM);
@@ -278,6 +304,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testFragmentTurkishText() throws Exception {
        boolean isGsmPhone = (TelephonyManager.getDefault().getPhoneType() ==
                TelephonyManager.PHONE_TYPE_GSM);
@@ -343,6 +370,7 @@ public class GsmSmsTest extends AndroidTestCase {


    @SmallTest
    @Test
    public void testDecode() throws Exception {
        decodeSingle(0);    // default table
        decodeSingle(1);    // Turkish locking shift table
@@ -418,6 +446,7 @@ public class GsmSmsTest extends AndroidTestCase {
    };

    @SmallTest
    @Test
    public void testDecodeExtended() throws Exception {
        for (int language = 0; language < 3; language++) {
            int[] tableIndex = sExtendedTableIndexes[language];
@@ -468,6 +497,7 @@ public class GsmSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testDecodeExtendedFallback() throws Exception {
        // verify that unmapped characters in extension table fall back to locking shift table
        for (int language = 0; language < 3; language++) {
+19 −7
Original line number Diff line number Diff line
@@ -16,18 +16,18 @@

package com.android.internal.telephony;

import android.telephony.SmsMessage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import android.telephony.TelephonyManager;
import android.telephony.Rlog;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;

import com.android.internal.telephony.SmsConstants;

import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * Test cases to verify selection of the optimal 7 bit encoding tables
@@ -39,7 +39,7 @@ import java.util.Random;
 * Tests both encoding variations: unsupported characters mapped to space,
 * and unsupported characters force entire message to UCS-2.
 */
public class SmsMessageBodyTest extends AndroidTestCase {
public class SmsMessageBodyTest extends TelephonyTest {
    private static final String TAG = "SmsMessageBodyTest";

    // ASCII chars in the GSM 7 bit default alphabet
@@ -256,7 +256,18 @@ public class SmsMessageBodyTest extends AndroidTestCase {
     */
    private static final int UDH_SEPTET_COST_CONCATENATED_MESSAGE = 6;

    @Before
    public void setUp() throws Exception {
        super.setUp(this.getClass().getSimpleName());
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }

    @SmallTest
    @Test
    public void testCalcLengthAscii() throws Exception {
        StringBuilder sb = new StringBuilder(320);
        int[] values = {0, 0, 0, SmsConstants.ENCODING_7BIT, 0, 0};
@@ -289,6 +300,7 @@ public class SmsMessageBodyTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testCalcLengthUnicode() throws Exception {
        StringBuilder sb = new StringBuilder(160);
        int[] values = {0, 0, 0, SmsConstants.ENCODING_16BIT, 0, 0};
+54 −2
Original line number Diff line number Diff line
@@ -16,19 +16,28 @@

package com.android.internal.telephony.cdma.sms;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.telephony.TelephonyManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
import com.android.internal.telephony.SmsHeader;
import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.cdma.SmsMessage;
import com.android.internal.util.HexDump;

import java.util.ArrayList;
import java.util.Arrays;

public class CdmaSmsTest extends AndroidTestCase {
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class CdmaSmsTest extends TelephonyTest {

    // CJK ideographs, Hiragana, Katakana, full width letters, Cyrillic, etc.
    private static final String sUnicodeChars = "\u4e00\u4e01\u4e02\u4e03" +
@@ -43,7 +52,18 @@ public class CdmaSmsTest extends AndroidTestCase {
    // "Hello, world" in Japanese.
    private static final String sHelloWorldJa = "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c";

    @Before
    public void setUp() throws Exception {
        super.setUp(this.getClass().getSimpleName());
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }

    @SmallTest
    @Test
    public void testCdmaSmsAddrParsing() throws Exception {
        CdmaSmsAddress addr = CdmaSmsAddress.parse("6502531000");
        assertEquals(addr.ton, CdmaSmsAddress.TON_UNKNOWN);
@@ -115,6 +135,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserData7bitGsm() throws Exception {
        String pdu = "00031040900112488ea794e074d69e1b7392c270326cde9e98";
        BearerData bearerData = BearerData.decode(HexDump.hexStringToByteArray(pdu));
@@ -122,6 +143,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserData7bitAscii() throws Exception {
        String pdu = "0003100160010610262d5ab500";
        BearerData bearerData = BearerData.decode(HexDump.hexStringToByteArray(pdu));
@@ -129,6 +151,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserData7bitAsciiTwo() throws Exception {
        String pdu = "00031001d00109104539b4d052ebb3d0";
        BearerData bearerData = BearerData.decode(HexDump.hexStringToByteArray(pdu));
@@ -136,6 +159,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserDataIa5() throws Exception {
        String pdu = "00031002100109184539b4d052ebb3d0";
        BearerData bearerData = BearerData.decode(HexDump.hexStringToByteArray(pdu));
@@ -143,6 +167,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserData7bitAsciiFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -173,6 +198,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserData7bitGsmFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -227,6 +253,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserDataUtf16Feedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -263,6 +290,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testMonolithicOne() throws Exception {
        String pdu = "0003200010010410168d2002010503060812011101590501c706069706180000000701c108" +
                "01c00901800a01e00b01030c01c00d01070e05039acc13880f018011020566";
@@ -310,6 +338,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testMonolithicTwo() throws Exception {
        String pdu = "0003200010010410168d200201050306081201110159050192060697061800000007013d0" +
                "801c00901800a01e00b01030c01c00d01070e05039acc13880f018011020566";
@@ -357,6 +386,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserDataHeaderConcatRefFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -390,6 +420,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserDataHeaderIllegalConcatRef() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -427,6 +458,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserDataHeaderMixedFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -469,6 +501,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testReplyOption() throws Exception {
        String pdu1 = "0003104090011648b6a794e0705476bf77bceae934fe5f6d94d87450080a0180";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -501,6 +534,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testReplyOptionFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -543,6 +577,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testNumberOfMessages() throws Exception {
        // Note that the message text below does not properly reflect
        // the message count.  The author of these messages was
@@ -560,6 +595,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testCallbackNum() throws Exception {
        String pdu1 = "00031040900112488ea794e070d436cb638bc5e035ce2f97900e06910431323334";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -572,6 +608,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testCallbackNumDtmf() throws Exception {
        String pdu1 = "00031002300109104539b4d052ebb3d00e07052d4c90a55080";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -584,6 +621,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testCallbackNumFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -621,6 +659,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testPrivacyIndicator() throws Exception {
        String pdu1 = "0003104090010c485f4194dfea34becf61b840090140";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -634,6 +673,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testPrivacyIndicatorFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -656,6 +696,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testMsgDeliveryAlert() throws Exception {
        String pdu1 = "0003104090010d4866a794e07055965b91d040300c0100";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -686,6 +727,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testMiscParams() throws Exception {
        String pdu1 = "00031002400109104539b4d052ebb3d00c0180";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -707,6 +749,7 @@ public class CdmaSmsTest extends AndroidTestCase {
        assertEquals(bd4.userData.payloadStr, "SMS Rulz");
    }
   @SmallTest
   @Test
    public void testMsgDeliveryAlertFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -731,6 +774,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testLanguageIndicator() throws Exception {
        String pdu1 = "0003104090011748bea794e0731436ef3bd7c2e0352eef27a1c263fe58080d0101";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -743,6 +787,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testLanguageIndicatorFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -767,6 +812,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testDisplayMode() throws Exception {
        String pdu1 = "0003104090010c485f4194dfea34becf61b8400f0100";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -780,6 +826,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testDisplayModeFeedback() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -804,6 +851,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testIs91() throws Exception {
        String pdu1 = "000320001001070c2039acc13880";
        BearerData bd1 = BearerData.decode(HexDump.hexStringToByteArray(pdu1));
@@ -814,6 +862,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testUserDataHeaderWithEightCharMsg() throws Exception {
        SmsHeader smsHeader = getConcatUserDataHeader(2, 2);
        encodeDecodeAssertEquals("01234567", smsHeader, -1);
@@ -822,12 +871,14 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testShiftJis() throws Exception {
        encodeDecodeAssertEquals(sHelloWorldJa, null, UserData.ENCODING_UNICODE_16);
        encodeDecodeAssertEquals(sHelloWorldJa, null, UserData.ENCODING_SHIFT_JIS);
    }

    @SmallTest
    @Test
    public void testIgnoreReservedSubparam() throws Exception {
        BearerData bearerData = new BearerData();
        bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
@@ -910,6 +961,7 @@ public class CdmaSmsTest extends AndroidTestCase {
    }

    @SmallTest
    @Test
    public void testFragmentText() throws Exception {
        boolean isCdmaPhone = (TelephonyManager.getDefault().getPhoneType() ==
                TelephonyManager.PHONE_TYPE_CDMA);