diff options
author | Roshan Pius <rpius@google.com> | 2017-07-28 02:51:52 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-07-28 02:51:52 +0000 |
commit | 78f769ee241ce5d4a0e592ef9fb0ec63054592bc (patch) | |
tree | a2fb85f0a81ae561e639ebce1b332cc31999bf50 /tests | |
parent | 31a9e140105fe0c763fc72dd075d7bd876f17989 (diff) | |
parent | 3673d53dea03d18e5b28ce248b9911f81e3f8638 (diff) |
Merge "wifi(framework): Modify the SAR power levels interface" into oc-dr1-dev
am: 3673d53dea
Change-Id: I30fde20315fbdacdf64bce45d159db70ac932da8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 84 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java | 51 |
2 files changed, 96 insertions, 39 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 8d578b3d9..9fc9429a6 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -1904,7 +1904,7 @@ public class WifiStateMachineTest { * setting/resetting Tx power limit. */ @Test - public void testVoiceCallSar_disabledTxPowerLimit_WifiOn() throws Exception { + public void testVoiceCallSar_disabledTxPowerScenario_WifiOn() throws Exception { loadComponentsInStaMode(); mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest()); @@ -1917,7 +1917,7 @@ public class WifiStateMachineTest { * setting/resetting Tx power limit. */ @Test - public void testVoiceCallSar_enabledTxPowerLimit_WifiOn() throws Exception { + public void testVoiceCallSar_enabledTxPowerScenario_WifiOn() throws Exception { mResources.setBoolean( R.bool.config_wifi_framework_enable_voice_call_sar_tx_power_limit, true); initializeWsm(); @@ -1935,16 +1935,13 @@ public class WifiStateMachineTest { * {@link TelephonyManager#CALL_STATE_OFFHOOK}. */ @Test - public void testVoiceCallSar_enabledTxPowerLimitCallStateOffHook_WhenWifiTurnedOn() + public void testVoiceCallSar_enabledTxPowerScenarioCallStateOffHook_WhenWifiTurnedOn() throws Exception { - int powerLevelInDbm = -45; - mResources.setInteger( - R.integer.config_wifi_framework_voice_call_sar_tx_power_limit_in_dbm, - powerLevelInDbm); mResources.setBoolean( R.bool.config_wifi_framework_enable_voice_call_sar_tx_power_limit, true); initializeWsm(); + when(mWifiNative.selectTxPowerScenario(anyInt())).thenReturn(true); when(mTelephonyManager.isOffhook()).thenReturn(true); loadComponentsInStaMode(); @@ -1952,7 +1949,7 @@ public class WifiStateMachineTest { assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest()); assertEquals("DisconnectedState", getCurrentState().getName()); assertNotNull(mPhoneStateListener); - verify(mWifiNative).setTxPowerLimit(eq(powerLevelInDbm)); + verify(mWifiNative).selectTxPowerScenario(eq(WifiNative.TX_POWER_SCENARIO_VOICE_CALL)); } /** @@ -1961,12 +1958,13 @@ public class WifiStateMachineTest { * {@link TelephonyManager#CALL_STATE_IDLE}. */ @Test - public void testVoiceCallSar_enabledTxPowerLimitCallStateIdle_WhenWifiTurnedOn() + public void testVoiceCallSar_enabledTxPowerScenarioCallStateIdle_WhenWifiTurnedOn() throws Exception { mResources.setBoolean( R.bool.config_wifi_framework_enable_voice_call_sar_tx_power_limit, true); initializeWsm(); + when(mWifiNative.selectTxPowerScenario(anyInt())).thenReturn(true); when(mTelephonyManager.isIdle()).thenReturn(true); loadComponentsInStaMode(); @@ -1974,7 +1972,30 @@ public class WifiStateMachineTest { assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest()); assertEquals("DisconnectedState", getCurrentState().getName()); assertNotNull(mPhoneStateListener); - verify(mWifiNative).resetTxPowerLimit(); + } + + /** + * Test that we do register the telephony call state listener on devices which do support + * setting/resetting Tx power limit and set the tx power level if we're in state + * {@link TelephonyManager#CALL_STATE_OFFHOOK}. This test checks if the + * {@link WifiNative#selectTxPowerScenario(int)} failure is handled correctly. + */ + @Test + public void testVoiceCallSar_enabledTxPowerScenarioCallStateOffHook_WhenWifiTurnedOn_Fails() + throws Exception { + mResources.setBoolean( + R.bool.config_wifi_framework_enable_voice_call_sar_tx_power_limit, true); + initializeWsm(); + + when(mWifiNative.selectTxPowerScenario(anyInt())).thenReturn(false); + when(mTelephonyManager.isOffhook()).thenReturn(true); + + loadComponentsInStaMode(); + mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); + assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest()); + assertEquals("DisconnectedState", getCurrentState().getName()); + assertNotNull(mPhoneStateListener); + verify(mWifiNative).selectTxPowerScenario(eq(WifiNative.TX_POWER_SCENARIO_VOICE_CALL)); } /** @@ -1983,16 +2004,14 @@ public class WifiStateMachineTest { * {@link TelephonyManager#CALL_STATE_OFFHOOK}. */ @Test - public void testVoiceCallSar_enabledTxPowerLimitCallStateOffHook_WhenWifiOn() throws Exception { - int powerLevelInDbm = -45; - mResources.setInteger( - R.integer.config_wifi_framework_voice_call_sar_tx_power_limit_in_dbm, - powerLevelInDbm); - testVoiceCallSar_enabledTxPowerLimit_WifiOn(); + public void testVoiceCallSar_enabledTxPowerScenarioCallStateOffHook_WhenWifiOn() + throws Exception { + when(mWifiNative.selectTxPowerScenario(anyInt())).thenReturn(true); + testVoiceCallSar_enabledTxPowerScenario_WifiOn(); mPhoneStateListener.onCallStateChanged(TelephonyManager.CALL_STATE_OFFHOOK, ""); mLooper.dispatchAll(); - verify(mWifiNative).setTxPowerLimit(eq(powerLevelInDbm)); + verify(mWifiNative).selectTxPowerScenario(eq(WifiNative.TX_POWER_SCENARIO_VOICE_CALL)); } /** @@ -2001,12 +2020,31 @@ public class WifiStateMachineTest { * {@link TelephonyManager#CALL_STATE_IDLE}. */ @Test - public void testVoiceCallSar_enabledTxPowerLimitCallStateIdle_WhenWifiOn() throws Exception { - testVoiceCallSar_enabledTxPowerLimit_WifiOn(); + public void testVoiceCallSar_enabledTxPowerScenarioCallStateIdle_WhenWifiOn() throws Exception { + when(mWifiNative.selectTxPowerScenario(anyInt())).thenReturn(true); + testVoiceCallSar_enabledTxPowerScenario_WifiOn(); mPhoneStateListener.onCallStateChanged(TelephonyManager.CALL_STATE_IDLE, ""); mLooper.dispatchAll(); - verify(mWifiNative).resetTxPowerLimit(); + verify(mWifiNative, atLeastOnce()) + .selectTxPowerScenario(eq(WifiNative.TX_POWER_SCENARIO_NORMAL)); + } + + /** + * Test that we invoke the corresponding WifiNative method when + * {@link PhoneStateListener#onCallStateChanged(int, String)} is invoked with state + * {@link TelephonyManager#CALL_STATE_OFFHOOK}. This test checks if the + * {@link WifiNative#selectTxPowerScenario(int)} failure is handled correctly. + */ + @Test + public void testVoiceCallSar_enabledTxPowerScenarioCallStateOffHook_WhenWifiOn_Fails() + throws Exception { + when(mWifiNative.selectTxPowerScenario(anyInt())).thenReturn(false); + testVoiceCallSar_enabledTxPowerScenario_WifiOn(); + + mPhoneStateListener.onCallStateChanged(TelephonyManager.CALL_STATE_OFFHOOK, ""); + mLooper.dispatchAll(); + verify(mWifiNative).selectTxPowerScenario(eq(WifiNative.TX_POWER_SCENARIO_VOICE_CALL)); } /** @@ -2016,18 +2054,18 @@ public class WifiStateMachineTest { * wifi is off (state machine is not in SupplicantStarted state). */ @Test - public void testVoiceCallSar_enabledTxPowerLimitCallState_WhenWifiOff() throws Exception { + public void testVoiceCallSar_enabledTxPowerScenarioCallState_WhenWifiOff() throws Exception { mResources.setBoolean( R.bool.config_wifi_framework_enable_voice_call_sar_tx_power_limit, true); initializeWsm(); mPhoneStateListener.onCallStateChanged(TelephonyManager.CALL_STATE_OFFHOOK, ""); mLooper.dispatchAll(); - verify(mWifiNative, never()).setTxPowerLimit(anyInt()); + verify(mWifiNative, never()).selectTxPowerScenario(anyInt()); mPhoneStateListener.onCallStateChanged(TelephonyManager.CALL_STATE_IDLE, ""); mLooper.dispatchAll(); - verify(mWifiNative, never()).resetTxPowerLimit(); + verify(mWifiNative, never()).selectTxPowerScenario(anyInt()); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java index 3f2f389c5..84de9d227 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java @@ -1844,48 +1844,67 @@ public class WifiVendorHalTest { } /** - * Test the new setTxPowerLimit HIDL method invocation. This should return failure if the + * Test the new selectTxPowerScenario HIDL method invocation. This should return failure if the * HAL service is exposing the 1.0 interface. */ @Test - public void testSetTxPowerLimit() throws RemoteException { - int powerLevelInDbm = -45; - + public void testSelectTxPowerScenario() throws RemoteException { assertTrue(mWifiVendorHal.startVendorHal(true)); // Should fail because we exposed the 1.0 IWifiChip. - assertFalse(mWifiVendorHal.setTxPowerLimit(powerLevelInDbm)); - verify(mIWifiChipV11, never()).setTxPowerLimit(eq(powerLevelInDbm)); + assertFalse( + mWifiVendorHal.selectTxPowerScenario(WifiNative.TX_POWER_SCENARIO_VOICE_CALL)); + verify(mIWifiChipV11, never()).selectTxPowerScenario(anyInt()); mWifiVendorHal.stopVendorHal(); // Now expose the 1.1 IWifiChip. mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper()); - when(mIWifiChipV11.setTxPowerLimit(anyInt())).thenReturn(mWifiStatusSuccess); + when(mIWifiChipV11.selectTxPowerScenario(anyInt())).thenReturn(mWifiStatusSuccess); assertTrue(mWifiVendorHal.startVendorHal(true)); - assertTrue(mWifiVendorHal.setTxPowerLimit(powerLevelInDbm)); - verify(mIWifiChipV11).setTxPowerLimit(eq(powerLevelInDbm)); + assertTrue( + mWifiVendorHal.selectTxPowerScenario(WifiNative.TX_POWER_SCENARIO_VOICE_CALL)); + verify(mIWifiChipV11).selectTxPowerScenario( + eq(android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL)); + verify(mIWifiChipV11, never()).resetTxPowerScenario(); mWifiVendorHal.stopVendorHal(); } /** - * Test the new setTxPowerLimit HIDL method invocation. This should return failure if the + * Test the new resetTxPowerScenario HIDL method invocation. This should return failure if the * HAL service is exposing the 1.0 interface. */ @Test - public void testResetTxPowerLimit() throws RemoteException { + public void testResetTxPowerScenario() throws RemoteException { assertTrue(mWifiVendorHal.startVendorHal(true)); // Should fail because we exposed the 1.0 IWifiChip. - assertFalse(mWifiVendorHal.resetTxPowerLimit()); - verify(mIWifiChipV11, never()).resetTxPowerLimit(); + assertFalse(mWifiVendorHal.selectTxPowerScenario(WifiNative.TX_POWER_SCENARIO_NORMAL)); + verify(mIWifiChipV11, never()).resetTxPowerScenario(); mWifiVendorHal.stopVendorHal(); // Now expose the 1.1 IWifiChip. mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper()); - when(mIWifiChipV11.resetTxPowerLimit()).thenReturn(mWifiStatusSuccess); + when(mIWifiChipV11.resetTxPowerScenario()).thenReturn(mWifiStatusSuccess); + + assertTrue(mWifiVendorHal.startVendorHal(true)); + assertTrue(mWifiVendorHal.selectTxPowerScenario(WifiNative.TX_POWER_SCENARIO_NORMAL)); + verify(mIWifiChipV11).resetTxPowerScenario(); + verify(mIWifiChipV11, never()).selectTxPowerScenario(anyInt()); + mWifiVendorHal.stopVendorHal(); + } + + /** + * Test the new selectTxPowerScenario HIDL method invocation with a bad scenario index. + */ + @Test + public void testInvalidSelectTxPowerScenario() throws RemoteException { + // Expose the 1.1 IWifiChip. + mWifiVendorHal = new WifiVendorHalSpyV1_1(mHalDeviceManager, mLooper.getLooper()); + when(mIWifiChipV11.selectTxPowerScenario(anyInt())).thenReturn(mWifiStatusSuccess); assertTrue(mWifiVendorHal.startVendorHal(true)); - assertTrue(mWifiVendorHal.resetTxPowerLimit()); - verify(mIWifiChipV11).resetTxPowerLimit(); + assertFalse(mWifiVendorHal.selectTxPowerScenario(-6)); + verify(mIWifiChipV11, never()).selectTxPowerScenario(anyInt()); + verify(mIWifiChipV11, never()).resetTxPowerScenario(); mWifiVendorHal.stopVendorHal(); } |