Loading tests/telephonytests/src/com/android/internal/telephony/ImsSmsDispatcherTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,18 @@ public class ImsSmsDispatcherTest extends TelephonyTest { super.tearDown(); } /** * Send Memory Availability Notification and verify that the token is correct. */ @Test @SmallTest public void testOnMemoryAvailable() throws Exception { int token = mImsSmsDispatcher.mNextToken.get(); //Send SMMA mImsSmsDispatcher.onMemoryAvailable(); assertEquals(token + 1, mImsSmsDispatcher.mNextToken.get()); verify(mImsManager).onMemoryAvailable(eq(token + 1)); } /** * Send an SMS and verify that the token and PDU is correct. */ Loading tests/telephonytests/src/com/android/internal/telephony/SmsDispatchersControllerTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.internal.telephony; import static com.android.internal.telephony.SmsResponse.NO_ERROR_CODE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; Loading @@ -33,6 +34,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.os.AsyncResult; import android.os.Message; import android.provider.Telephony.Sms.Intents; import android.telephony.PhoneNumberUtils; Loading Loading @@ -96,6 +98,30 @@ public class SmsDispatchersControllerTest extends TelephonyTest { assertTrue(mSmsDispatchersController.isIms()); } @Test @SmallTest public void testReportSmsMemoryStatus() throws Exception { int eventReportMemoryStatusDone = 3; SmsStorageMonitor smsStorageMonnitor = new SmsStorageMonitor(mPhone); Message result = smsStorageMonnitor.obtainMessage(eventReportMemoryStatusDone); ImsSmsDispatcher mImsSmsDispatcher = Mockito.mock(ImsSmsDispatcher.class); mSmsDispatchersController.setImsSmsDispatcher(mImsSmsDispatcher); mSmsDispatchersController.reportSmsMemoryStatus(result); AsyncResult ar = (AsyncResult) result.obj; verify(mImsSmsDispatcher).onMemoryAvailable(); assertNull(ar.exception); } @Test @SmallTest public void testReportSmsMemoryStatusFailure() throws Exception { int eventReportMemoryStatusDone = 3; SmsStorageMonitor smsStorageMonnitor = new SmsStorageMonitor(mPhone); Message result = smsStorageMonnitor.obtainMessage(eventReportMemoryStatusDone); mSmsDispatchersController.setImsSmsDispatcher(null); mSmsDispatchersController.reportSmsMemoryStatus(result); AsyncResult ar = (AsyncResult) result.obj; assertNotNull(ar.exception); } @Test @SmallTest @FlakyTest public void testSendImsGmsTest() throws Exception { switchImsSmsFormat(PhoneConstants.PHONE_TYPE_GSM); Loading tests/telephonytests/src/com/android/internal/telephony/SmsStorageMonitorTest.java +40 −0 Original line number Diff line number Diff line Loading @@ -20,8 +20,11 @@ import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; import static org.junit.Assert.*; import static org.mockito.Mockito.*; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import android.content.Intent; import android.content.res.Resources; import android.os.Message; import android.provider.Telephony; import android.test.suitebuilder.annotation.MediumTest; Loading @@ -34,6 +37,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper Loading Loading @@ -137,6 +142,41 @@ public class SmsStorageMonitorTest extends TelephonyTest { .reportSmsMemoryStatus(eq(false), any(Message.class)); } @Test @SmallTest public void testReportSmsMemoryStatusToIms() { Resources mockResources = Mockito.mock(Resources.class); doReturn(mockResources).when(mContext).getResources(); doReturn(true).when(mockResources).getBoolean(anyInt()); doReturn(true).when(mIccSmsInterfaceManager.mDispatchersController).isIms(); mSimulatedCommands.notifyRadioOn(); processAllMessages(); verify(mSimulatedCommandsVerifier, never()).reportSmsMemoryStatus(anyBoolean(), any(Message.class)); // Send DEVICE_STORAGE_FULL mContextFixture.getTestDouble().sendBroadcast( new Intent(Intent.ACTION_DEVICE_STORAGE_FULL)); processAllMessages(); verify(mSimulatedCommandsVerifier).reportSmsMemoryStatus(eq(false), any(Message.class)); assertFalse(mSmsStorageMonitor.isStorageAvailable()); mSimulatedCommands.notifyRadioOn(); processAllMessages(); verify(mSimulatedCommandsVerifier).reportSmsMemoryStatus(eq(false), any(Message.class)); // Send DEVICE_STORAGE_NOT_FULL mContextFixture.getTestDouble().sendBroadcast( new Intent(Intent.ACTION_DEVICE_STORAGE_NOT_FULL)); processAllMessages(); verify(mIccSmsInterfaceManager.mDispatchersController) .reportSmsMemoryStatus(any(Message.class)); } @Test @SmallTest public void testReportSmsMemoryStatusDuringRetry() { mSimulatedCommands.setReportSmsMemoryStatusFailResponse(true); Loading Loading
tests/telephonytests/src/com/android/internal/telephony/ImsSmsDispatcherTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,18 @@ public class ImsSmsDispatcherTest extends TelephonyTest { super.tearDown(); } /** * Send Memory Availability Notification and verify that the token is correct. */ @Test @SmallTest public void testOnMemoryAvailable() throws Exception { int token = mImsSmsDispatcher.mNextToken.get(); //Send SMMA mImsSmsDispatcher.onMemoryAvailable(); assertEquals(token + 1, mImsSmsDispatcher.mNextToken.get()); verify(mImsManager).onMemoryAvailable(eq(token + 1)); } /** * Send an SMS and verify that the token and PDU is correct. */ Loading
tests/telephonytests/src/com/android/internal/telephony/SmsDispatchersControllerTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.internal.telephony; import static com.android.internal.telephony.SmsResponse.NO_ERROR_CODE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; Loading @@ -33,6 +34,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.os.AsyncResult; import android.os.Message; import android.provider.Telephony.Sms.Intents; import android.telephony.PhoneNumberUtils; Loading Loading @@ -96,6 +98,30 @@ public class SmsDispatchersControllerTest extends TelephonyTest { assertTrue(mSmsDispatchersController.isIms()); } @Test @SmallTest public void testReportSmsMemoryStatus() throws Exception { int eventReportMemoryStatusDone = 3; SmsStorageMonitor smsStorageMonnitor = new SmsStorageMonitor(mPhone); Message result = smsStorageMonnitor.obtainMessage(eventReportMemoryStatusDone); ImsSmsDispatcher mImsSmsDispatcher = Mockito.mock(ImsSmsDispatcher.class); mSmsDispatchersController.setImsSmsDispatcher(mImsSmsDispatcher); mSmsDispatchersController.reportSmsMemoryStatus(result); AsyncResult ar = (AsyncResult) result.obj; verify(mImsSmsDispatcher).onMemoryAvailable(); assertNull(ar.exception); } @Test @SmallTest public void testReportSmsMemoryStatusFailure() throws Exception { int eventReportMemoryStatusDone = 3; SmsStorageMonitor smsStorageMonnitor = new SmsStorageMonitor(mPhone); Message result = smsStorageMonnitor.obtainMessage(eventReportMemoryStatusDone); mSmsDispatchersController.setImsSmsDispatcher(null); mSmsDispatchersController.reportSmsMemoryStatus(result); AsyncResult ar = (AsyncResult) result.obj; assertNotNull(ar.exception); } @Test @SmallTest @FlakyTest public void testSendImsGmsTest() throws Exception { switchImsSmsFormat(PhoneConstants.PHONE_TYPE_GSM); Loading
tests/telephonytests/src/com/android/internal/telephony/SmsStorageMonitorTest.java +40 −0 Original line number Diff line number Diff line Loading @@ -20,8 +20,11 @@ import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; import static org.junit.Assert.*; import static org.mockito.Mockito.*; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import android.content.Intent; import android.content.res.Resources; import android.os.Message; import android.provider.Telephony; import android.test.suitebuilder.annotation.MediumTest; Loading @@ -34,6 +37,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper Loading Loading @@ -137,6 +142,41 @@ public class SmsStorageMonitorTest extends TelephonyTest { .reportSmsMemoryStatus(eq(false), any(Message.class)); } @Test @SmallTest public void testReportSmsMemoryStatusToIms() { Resources mockResources = Mockito.mock(Resources.class); doReturn(mockResources).when(mContext).getResources(); doReturn(true).when(mockResources).getBoolean(anyInt()); doReturn(true).when(mIccSmsInterfaceManager.mDispatchersController).isIms(); mSimulatedCommands.notifyRadioOn(); processAllMessages(); verify(mSimulatedCommandsVerifier, never()).reportSmsMemoryStatus(anyBoolean(), any(Message.class)); // Send DEVICE_STORAGE_FULL mContextFixture.getTestDouble().sendBroadcast( new Intent(Intent.ACTION_DEVICE_STORAGE_FULL)); processAllMessages(); verify(mSimulatedCommandsVerifier).reportSmsMemoryStatus(eq(false), any(Message.class)); assertFalse(mSmsStorageMonitor.isStorageAvailable()); mSimulatedCommands.notifyRadioOn(); processAllMessages(); verify(mSimulatedCommandsVerifier).reportSmsMemoryStatus(eq(false), any(Message.class)); // Send DEVICE_STORAGE_NOT_FULL mContextFixture.getTestDouble().sendBroadcast( new Intent(Intent.ACTION_DEVICE_STORAGE_NOT_FULL)); processAllMessages(); verify(mIccSmsInterfaceManager.mDispatchersController) .reportSmsMemoryStatus(any(Message.class)); } @Test @SmallTest public void testReportSmsMemoryStatusDuringRetry() { mSimulatedCommands.setReportSmsMemoryStatusFailResponse(true); Loading