Loading src/java/com/android/internal/telephony/DefaultPhoneNotifier.java +1 −2 Original line number Diff line number Diff line Loading @@ -47,8 +47,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier { protected ITelephonyRegistry mRegistry; /*package*/ protected DefaultPhoneNotifier() { public DefaultPhoneNotifier() { mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); } Loading tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java 0 → 100644 +123 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.List; import java.util.ArrayList; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.verify; import org.mockito.ArgumentCaptor; import android.telephony.CellInfo; import android.telephony.SignalStrength; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.telephony.mocks.TelephonyRegistryMock; public class DefaultPhoneNotifierTest extends TelephonyTest { private DefaultPhoneNotifier mDefaultPhoneNotifierUT; @Mock TelephonyRegistryMock mTelephonyRegisteryMock; @Mock SignalStrength mSignalStrength; @Mock CellInfo mCellInfo; @Before public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); mServiceManagerMockedServices.put("telephony.registry", mTelephonyRegisteryMock); doReturn(mTelephonyRegisteryMock).when(mTelephonyRegisteryMock) .queryLocalInterface(anyString()); mDefaultPhoneNotifierUT = new DefaultPhoneNotifier(); } @After public void tearDown() throws Exception { super.tearDown(); } @Test @SmallTest public void testNotifyCallForwarding() throws Exception { mDefaultPhoneNotifierUT.notifyCallForwardingChanged(mPhone); verify(mTelephonyRegisteryMock).notifyCallForwardingChangedForSubscriber(eq(0), eq(false)); doReturn(true).when(mPhone).getCallForwardingIndicator(); doReturn(1).when(mPhone).getSubId(); mDefaultPhoneNotifierUT.notifyCallForwardingChanged(mPhone); verify(mTelephonyRegisteryMock).notifyCallForwardingChangedForSubscriber(eq(1), eq(true)); } @Test @SmallTest public void testNotifyDataActivity() throws Exception { //mock data activity state doReturn(Phone.DataActivityState.NONE).when(mPhone).getDataActivityState(); mDefaultPhoneNotifierUT.notifyDataActivity(mPhone); verify(mTelephonyRegisteryMock).notifyDataActivityForSubscriber(eq(0), eq(TelephonyManager.DATA_ACTIVITY_NONE)); doReturn(1).when(mPhone).getSubId(); doReturn(Phone.DataActivityState.DATAIN).when(mPhone).getDataActivityState(); mDefaultPhoneNotifierUT.notifyDataActivity(mPhone); verify(mTelephonyRegisteryMock).notifyDataActivityForSubscriber(eq(1), eq(TelephonyManager.DATA_ACTIVITY_IN)); } @Test @SmallTest public void testNotifySignalStrength() throws Exception { //mock signal strength value doReturn(99).when(mSignalStrength).getGsmSignalStrength(); doReturn(mSignalStrength).when(mPhone).getSignalStrength(); ArgumentCaptor<SignalStrength> signalStrengthArgumentCaptor = ArgumentCaptor.forClass(SignalStrength.class); mDefaultPhoneNotifierUT.notifySignalStrength(mPhone); verify(mTelephonyRegisteryMock).notifySignalStrengthForSubscriber(eq(0), signalStrengthArgumentCaptor.capture()); assertEquals(99, signalStrengthArgumentCaptor.getValue().getGsmSignalStrength()); doReturn(1).when(mPhone).getSubId(); mDefaultPhoneNotifierUT.notifySignalStrength(mPhone); verify(mTelephonyRegisteryMock).notifySignalStrengthForSubscriber(eq(1), signalStrengthArgumentCaptor.capture()); assertEquals(99, signalStrengthArgumentCaptor.getValue().getGsmSignalStrength()); } @Test @SmallTest public void testNotifyCellInfo() throws Exception { //mock cellinfo List<CellInfo> mCellInfoList = new ArrayList<>(); mCellInfoList.add(mCellInfo); ArgumentCaptor<List> cellInfoArgumentCaptor = ArgumentCaptor.forClass(List.class); mDefaultPhoneNotifierUT.notifyCellInfo(mPhone, mCellInfoList); verify(mTelephonyRegisteryMock).notifyCellInfoForSubscriber(eq(0), cellInfoArgumentCaptor.capture()); assertEquals(mCellInfo, cellInfoArgumentCaptor.getValue().get(0)); } } tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +0 −6 Original line number Diff line number Diff line Loading @@ -34,17 +34,12 @@ import static org.mockito.Mockito.eq; import org.junit.Test; import org.mockito.Mock; import android.os.IBinder; import android.os.ServiceManager; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import java.util.HashMap; public class PhoneSubInfoControllerTest extends TelephonyTest { private PhoneSubInfoController mPhoneSubInfoControllerUT; private HashMap<String, IBinder> mServiceManagerMockedServices = new HashMap<>(); private AppOpsManager mAppOsMgr; @Mock Loading @@ -61,7 +56,6 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Context.TELEPHONY_SERVICE); doReturn(2).when(mTelephonyManager).getPhoneCount(); replaceInstance(ServiceManager.class, "sCache", null, mServiceManagerMockedServices); mServiceManagerMockedServices.put("isub", mSubscriptionController); doReturn(mSubscriptionController).when(mSubscriptionController) .queryLocalInterface(anyString()); Loading tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +0 −13 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ import android.content.Intent; import android.os.AsyncResult; import android.os.Bundle; import android.os.HandlerThread; import android.os.IBinder; import android.os.Parcel; import android.os.ServiceManager; import android.os.UserHandle; import android.telephony.CellInfo; import android.telephony.CellInfoGsm; Loading @@ -37,9 +35,6 @@ import android.test.suitebuilder.annotation.MediumTest; import com.android.internal.telephony.dataconnection.DcTracker; import com.android.internal.telephony.test.SimulatedCommands; import com.android.internal.telephony.uicc.IccCardApplicationStatus; import com.android.internal.telephony.uicc.SIMRecords; import com.android.internal.telephony.uicc.UiccCardApplication; import com.android.internal.telephony.uicc.UiccController; import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; import static org.junit.Assert.*; Loading @@ -58,7 +53,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import java.util.ArrayList; import java.util.HashMap; public class ServiceStateTrackerTest extends TelephonyTest { Loading @@ -66,10 +60,6 @@ public class ServiceStateTrackerTest extends TelephonyTest { private DcTracker mDct; @Mock private ProxyController mProxyController; @Mock HashMap<String, IBinder> mServiceCache; @Mock IBinder mBinder; private ServiceStateTracker sst; private TelephonyManager mTelephonyManager; Loading Loading @@ -98,9 +88,6 @@ public class ServiceStateTrackerTest extends TelephonyTest { mTelephonyManager = (TelephonyManager) mContextFixture.getTestDouble(). getSystemService(Context.TELEPHONY_SERVICE); doReturn(mBinder).when(mServiceCache).get(anyString()); replaceInstance(ServiceManager.class, "sCache", null, mServiceCache); replaceInstance(ProxyController.class, "sProxyController", null, mProxyController); mContextFixture.putStringArrayResource( Loading tests/telephonytests/src/com/android/internal/telephony/Sms7BitEncodingTranslatorTest.java +0 −9 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package com.android.internal.telephony; import android.os.IBinder; import android.os.ServiceManager; import android.telephony.SmsManager; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -28,18 +26,13 @@ import org.junit.Test; import org.mockito.Mock; import java.io.UnsupportedEncodingException; import java.util.HashMap; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doReturn; public class Sms7BitEncodingTranslatorTest extends TelephonyTest { @Mock HashMap<String, IBinder> mServiceCache; @Mock IBinder mBinder; Loading @@ -48,8 +41,6 @@ public class Sms7BitEncodingTranslatorTest extends TelephonyTest { logd("+Setup!"); super.setUp(getClass().getSimpleName()); doReturn(mBinder).when(mServiceCache).get(anyString()); replaceInstance(ServiceManager.class, "sCache", null, mServiceCache); logd("-Setup!"); } Loading Loading
src/java/com/android/internal/telephony/DefaultPhoneNotifier.java +1 −2 Original line number Diff line number Diff line Loading @@ -47,8 +47,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier { protected ITelephonyRegistry mRegistry; /*package*/ protected DefaultPhoneNotifier() { public DefaultPhoneNotifier() { mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); } Loading
tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java 0 → 100644 +123 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.List; import java.util.ArrayList; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.verify; import org.mockito.ArgumentCaptor; import android.telephony.CellInfo; import android.telephony.SignalStrength; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.telephony.mocks.TelephonyRegistryMock; public class DefaultPhoneNotifierTest extends TelephonyTest { private DefaultPhoneNotifier mDefaultPhoneNotifierUT; @Mock TelephonyRegistryMock mTelephonyRegisteryMock; @Mock SignalStrength mSignalStrength; @Mock CellInfo mCellInfo; @Before public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); mServiceManagerMockedServices.put("telephony.registry", mTelephonyRegisteryMock); doReturn(mTelephonyRegisteryMock).when(mTelephonyRegisteryMock) .queryLocalInterface(anyString()); mDefaultPhoneNotifierUT = new DefaultPhoneNotifier(); } @After public void tearDown() throws Exception { super.tearDown(); } @Test @SmallTest public void testNotifyCallForwarding() throws Exception { mDefaultPhoneNotifierUT.notifyCallForwardingChanged(mPhone); verify(mTelephonyRegisteryMock).notifyCallForwardingChangedForSubscriber(eq(0), eq(false)); doReturn(true).when(mPhone).getCallForwardingIndicator(); doReturn(1).when(mPhone).getSubId(); mDefaultPhoneNotifierUT.notifyCallForwardingChanged(mPhone); verify(mTelephonyRegisteryMock).notifyCallForwardingChangedForSubscriber(eq(1), eq(true)); } @Test @SmallTest public void testNotifyDataActivity() throws Exception { //mock data activity state doReturn(Phone.DataActivityState.NONE).when(mPhone).getDataActivityState(); mDefaultPhoneNotifierUT.notifyDataActivity(mPhone); verify(mTelephonyRegisteryMock).notifyDataActivityForSubscriber(eq(0), eq(TelephonyManager.DATA_ACTIVITY_NONE)); doReturn(1).when(mPhone).getSubId(); doReturn(Phone.DataActivityState.DATAIN).when(mPhone).getDataActivityState(); mDefaultPhoneNotifierUT.notifyDataActivity(mPhone); verify(mTelephonyRegisteryMock).notifyDataActivityForSubscriber(eq(1), eq(TelephonyManager.DATA_ACTIVITY_IN)); } @Test @SmallTest public void testNotifySignalStrength() throws Exception { //mock signal strength value doReturn(99).when(mSignalStrength).getGsmSignalStrength(); doReturn(mSignalStrength).when(mPhone).getSignalStrength(); ArgumentCaptor<SignalStrength> signalStrengthArgumentCaptor = ArgumentCaptor.forClass(SignalStrength.class); mDefaultPhoneNotifierUT.notifySignalStrength(mPhone); verify(mTelephonyRegisteryMock).notifySignalStrengthForSubscriber(eq(0), signalStrengthArgumentCaptor.capture()); assertEquals(99, signalStrengthArgumentCaptor.getValue().getGsmSignalStrength()); doReturn(1).when(mPhone).getSubId(); mDefaultPhoneNotifierUT.notifySignalStrength(mPhone); verify(mTelephonyRegisteryMock).notifySignalStrengthForSubscriber(eq(1), signalStrengthArgumentCaptor.capture()); assertEquals(99, signalStrengthArgumentCaptor.getValue().getGsmSignalStrength()); } @Test @SmallTest public void testNotifyCellInfo() throws Exception { //mock cellinfo List<CellInfo> mCellInfoList = new ArrayList<>(); mCellInfoList.add(mCellInfo); ArgumentCaptor<List> cellInfoArgumentCaptor = ArgumentCaptor.forClass(List.class); mDefaultPhoneNotifierUT.notifyCellInfo(mPhone, mCellInfoList); verify(mTelephonyRegisteryMock).notifyCellInfoForSubscriber(eq(0), cellInfoArgumentCaptor.capture()); assertEquals(mCellInfo, cellInfoArgumentCaptor.getValue().get(0)); } }
tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +0 −6 Original line number Diff line number Diff line Loading @@ -34,17 +34,12 @@ import static org.mockito.Mockito.eq; import org.junit.Test; import org.mockito.Mock; import android.os.IBinder; import android.os.ServiceManager; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import java.util.HashMap; public class PhoneSubInfoControllerTest extends TelephonyTest { private PhoneSubInfoController mPhoneSubInfoControllerUT; private HashMap<String, IBinder> mServiceManagerMockedServices = new HashMap<>(); private AppOpsManager mAppOsMgr; @Mock Loading @@ -61,7 +56,6 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Context.TELEPHONY_SERVICE); doReturn(2).when(mTelephonyManager).getPhoneCount(); replaceInstance(ServiceManager.class, "sCache", null, mServiceManagerMockedServices); mServiceManagerMockedServices.put("isub", mSubscriptionController); doReturn(mSubscriptionController).when(mSubscriptionController) .queryLocalInterface(anyString()); Loading
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +0 −13 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ import android.content.Intent; import android.os.AsyncResult; import android.os.Bundle; import android.os.HandlerThread; import android.os.IBinder; import android.os.Parcel; import android.os.ServiceManager; import android.os.UserHandle; import android.telephony.CellInfo; import android.telephony.CellInfoGsm; Loading @@ -37,9 +35,6 @@ import android.test.suitebuilder.annotation.MediumTest; import com.android.internal.telephony.dataconnection.DcTracker; import com.android.internal.telephony.test.SimulatedCommands; import com.android.internal.telephony.uicc.IccCardApplicationStatus; import com.android.internal.telephony.uicc.SIMRecords; import com.android.internal.telephony.uicc.UiccCardApplication; import com.android.internal.telephony.uicc.UiccController; import static com.android.internal.telephony.TelephonyTestUtils.waitForMs; import static org.junit.Assert.*; Loading @@ -58,7 +53,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import java.util.ArrayList; import java.util.HashMap; public class ServiceStateTrackerTest extends TelephonyTest { Loading @@ -66,10 +60,6 @@ public class ServiceStateTrackerTest extends TelephonyTest { private DcTracker mDct; @Mock private ProxyController mProxyController; @Mock HashMap<String, IBinder> mServiceCache; @Mock IBinder mBinder; private ServiceStateTracker sst; private TelephonyManager mTelephonyManager; Loading Loading @@ -98,9 +88,6 @@ public class ServiceStateTrackerTest extends TelephonyTest { mTelephonyManager = (TelephonyManager) mContextFixture.getTestDouble(). getSystemService(Context.TELEPHONY_SERVICE); doReturn(mBinder).when(mServiceCache).get(anyString()); replaceInstance(ServiceManager.class, "sCache", null, mServiceCache); replaceInstance(ProxyController.class, "sProxyController", null, mProxyController); mContextFixture.putStringArrayResource( Loading
tests/telephonytests/src/com/android/internal/telephony/Sms7BitEncodingTranslatorTest.java +0 −9 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ package com.android.internal.telephony; import android.os.IBinder; import android.os.ServiceManager; import android.telephony.SmsManager; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -28,18 +26,13 @@ import org.junit.Test; import org.mockito.Mock; import java.io.UnsupportedEncodingException; import java.util.HashMap; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doReturn; public class Sms7BitEncodingTranslatorTest extends TelephonyTest { @Mock HashMap<String, IBinder> mServiceCache; @Mock IBinder mBinder; Loading @@ -48,8 +41,6 @@ public class Sms7BitEncodingTranslatorTest extends TelephonyTest { logd("+Setup!"); super.setUp(getClass().getSimpleName()); doReturn(mBinder).when(mServiceCache).get(anyString()); replaceInstance(ServiceManager.class, "sCache", null, mServiceCache); logd("-Setup!"); } Loading