SmsManagerPermissionTestpublic class SmsManagerPermissionTest extends android.test.AndroidTestCase Verify that SmsManager apis cannot be called without required permissions. |
Fields Summary |
---|
private static final String | MSG_CONTENTS | private static final short | DEST_PORT | private static final String | DEST_NUMBER | private static final String | SRC_NUMBER |
Methods Summary |
---|
public void | testSendDataMessage()Verify that SmsManager.sendDataMessage requires permissions.
Tests Permission:
{@link android.Manifest.permission#SEND_SMS}.
try {
SmsManager.getDefault().sendDataMessage(SRC_NUMBER, DEST_NUMBER, DEST_PORT,
MSG_CONTENTS.getBytes(), null, null);
fail("SmsManager.sendDataMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
| public void | testSendMultipartMessage()Verify that SmsManager.sendMultipartMessage requires permissions.
Tests Permission:
{@link android.Manifest.permission#SEND_MMS}.
try {
ArrayList<String> msgParts = new ArrayList<String>(2);
msgParts.add(MSG_CONTENTS);
msgParts.add("foo");
SmsManager.getDefault().sendMultipartTextMessage(SRC_NUMBER, DEST_NUMBER, msgParts,
null, null);
fail("SmsManager.sendMultipartTextMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
| public void | testSendTextMessage()Verify that SmsManager.sendTextMessage requires permissions.
Tests Permission:
{@link android.Manifest.permission#SEND_SMS}.
try {
SmsManager.getDefault().sendTextMessage(SRC_NUMBER, DEST_NUMBER, MSG_CONTENTS, null,
null);
fail("SmsManager.sendTextMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
|
|