diff options
5 files changed, 71 insertions, 124 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java index 4eab95c51..29d0d12a6 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -20,12 +20,11 @@ import static android.hardware.wifi.V1_0.NanDataPathChannelCfg.REQUEST_CHANNEL_S import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyShort; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyShort; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -35,11 +34,8 @@ import static org.mockito.Mockito.when; import android.app.test.TestAlarmManager; import android.content.Context; import android.net.ConnectivityManager; -import android.net.LinkProperties; import android.net.NetworkCapabilities; import android.net.NetworkFactory; -import android.net.NetworkInfo; -import android.net.NetworkMisc; import android.net.NetworkRequest; import android.net.wifi.aware.AttachCallback; import android.net.wifi.aware.ConfigRequest; @@ -56,7 +52,6 @@ import android.net.wifi.aware.SubscribeDiscoverySession; import android.net.wifi.aware.WifiAwareManager; import android.net.wifi.aware.WifiAwareSession; import android.os.Handler; -import android.os.IBinder; import android.os.INetworkManagementService; import android.os.Message; import android.os.Messenger; @@ -65,7 +60,6 @@ import android.test.suitebuilder.annotation.SmallTest; import android.util.Pair; import com.android.internal.util.AsyncChannel; -import com.android.server.wifi.DisabledForUpdateToAnyMatcher; import libcore.util.HexEncoding; @@ -127,29 +121,27 @@ public class WifiAwareDataPathStateManagerTest { mDut.startLate(); when(mMockNative.getCapabilities(anyShort())).thenReturn(true); - when(mMockNative.enableAndConfigure(anyShort(), any(ConfigRequest.class), anyBoolean(), + when(mMockNative.enableAndConfigure(anyShort(), any(), anyBoolean(), anyBoolean())).thenReturn(true); when(mMockNative.disable(anyShort())).thenReturn(true); - when(mMockNative.publish(anyShort(), anyInt(), any(PublishConfig.class))).thenReturn(true); - when(mMockNative.subscribe(anyShort(), anyInt(), any(SubscribeConfig.class))) + when(mMockNative.publish(anyShort(), anyInt(), any())).thenReturn(true); + when(mMockNative.subscribe(anyShort(), anyInt(), any())) .thenReturn(true); - when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(byte[].class), - any(byte[].class), anyInt())).thenReturn(true); + when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(), + any(), anyInt())).thenReturn(true); when(mMockNative.stopPublish(anyShort(), anyInt())).thenReturn(true); when(mMockNative.stopSubscribe(anyShort(), anyInt())).thenReturn(true); - when(mMockNative.createAwareNetworkInterface(anyShort(), anyString())).thenReturn(true); - when(mMockNative.deleteAwareNetworkInterface(anyShort(), anyString())).thenReturn(true); + when(mMockNative.createAwareNetworkInterface(anyShort(), any())).thenReturn(true); + when(mMockNative.deleteAwareNetworkInterface(anyShort(), any())).thenReturn(true); when(mMockNative.initiateDataPath(anyShort(), anyInt(), anyInt(), anyInt(), - any(byte[].class), anyString(), any(byte[].class), anyString(), - any(Capabilities.class))).thenReturn(true); - when(mMockNative.respondToDataPathRequest(anyShort(), anyBoolean(), anyInt(), anyString(), - any(byte[].class), anyString(), any(Capabilities.class))).thenReturn(true); + any(), any(), any(), any(), + any())).thenReturn(true); + when(mMockNative.respondToDataPathRequest(anyShort(), anyBoolean(), anyInt(), any(), + any(), any(), any())).thenReturn(true); when(mMockNative.endDataPath(anyShort(), anyInt())).thenReturn(true); - when(mMockNetworkInterface.configureAgentProperties( - any(WifiAwareDataPathStateManager.AwareNetworkRequestInformation.class), - anyString(), anyInt(), any(NetworkInfo.class), any(NetworkCapabilities.class), - any(LinkProperties.class))).thenReturn(true); + when(mMockNetworkInterface.configureAgentProperties(any(), any(), anyInt(), any(), any(), + any())).thenReturn(true); installDataPathStateManagerMocks(); } @@ -242,7 +234,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Initiator: using session network specifier with a non-null * token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathInitiatorMacTokenSuccess() throws Exception { testDataPathInitiatorUtility(false, true, true, true, false); @@ -252,7 +243,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the fail flow of the Initiator: using session network specifier with a 0 * peer ID. */ - @DisabledForUpdateToAnyMatcher @Test(expected = IllegalArgumentException.class) public void testDataPathInitiatorNoMacFail() throws Exception { testDataPathInitiatorUtility(false, false, true, true, false); @@ -262,7 +252,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Initiator: using a direct network specifier with a non-null * peer mac and non-null token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathInitiatorDirectMacTokenSuccess() throws Exception { testDataPathInitiatorUtility(true, true, true, true, false); @@ -272,7 +261,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the fail flow of the Initiator: using a direct network specifier with a null peer * mac and non-null token. */ - @DisabledForUpdateToAnyMatcher @Test(expected = IllegalArgumentException.class) public void testDataPathInitiatorDirectNoMacTokenFail() throws Exception { testDataPathInitiatorUtility(true, false, true, true, false); @@ -282,7 +270,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the fail flow of the Initiator: using a direct network specifier with a null peer * mac and null token. */ - @DisabledForUpdateToAnyMatcher @Test(expected = IllegalArgumentException.class) public void testDataPathInitiatorDirectNoMacNoTokenFail() throws Exception { testDataPathInitiatorUtility(true, false, false, true, false); @@ -292,7 +279,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the fail flow of the Initiator: use a session network specifier with a non-null * token, but don't get a confirmation. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathInitiatorNoConfirmationTimeoutFail() throws Exception { testDataPathInitiatorUtility(false, true, true, false, false); @@ -302,7 +288,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the fail flow of the Initiator: use a session network specifier with a non-null * token, but get an immediate failure */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathInitiatorNoConfirmationHalFail() throws Exception { testDataPathInitiatorUtility(false, true, true, true, true); @@ -311,7 +296,6 @@ public class WifiAwareDataPathStateManagerTest { /** * Validate the fail flow of a mis-configured request: Publisher as Initiator */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathInitiatorOnPublisherError() throws Exception { testDataPathInitiatorResponderMismatchUtility(true); @@ -325,7 +309,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using session network specifier with a non-null * token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderMacTokenSuccess() throws Exception { testDataPathResponderUtility(false, true, true, true); @@ -335,7 +318,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using session network specifier with a null * token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderMacNoTokenSuccess() throws Exception { testDataPathResponderUtility(false, true, false, true); @@ -345,7 +327,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using session network specifier with a * token and no peer ID (i.e. 0). */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderMacTokenNoPeerIdSuccess() throws Exception { testDataPathResponderUtility(false, false, true, true); @@ -355,7 +336,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using session network specifier with a null * token and no peer ID (i.e. 0). */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderMacTokenNoPeerIdNoTokenSuccess() throws Exception { testDataPathResponderUtility(false, false, false, true); @@ -365,7 +345,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using a direct network specifier with a non-null * peer mac and non-null token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderDirectMacTokenSuccess() throws Exception { testDataPathResponderUtility(true, true, true, true); @@ -375,7 +354,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using a direct network specifier with a non-null * peer mac and null token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderDirectMacNoTokenSuccess() throws Exception { testDataPathResponderUtility(true, true, false, true); @@ -385,7 +363,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using a direct network specifier with a null peer * mac and non-null token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderDirectNoMacTokenSuccess() throws Exception { testDataPathResponderUtility(true, false, true, true); @@ -395,7 +372,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the success flow of the Responder: using a direct network specifier with a null peer * mac and null token. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResonderDirectNoMacNoTokenSuccess() throws Exception { testDataPathResponderUtility(true, false, false, true); @@ -405,7 +381,6 @@ public class WifiAwareDataPathStateManagerTest { * Validate the fail flow of the Responder: use a session network specifier with a non-null * token, but don't get a confirmation. */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResponderNoConfirmationTimeoutFail() throws Exception { testDataPathResponderUtility(false, true, true, false); @@ -414,7 +389,6 @@ public class WifiAwareDataPathStateManagerTest { /** * Validate the fail flow of a mis-configured request: Subscriber as Responder */ - @DisabledForUpdateToAnyMatcher @Test public void testDataPathResponderOnSubscriberError() throws Exception { testDataPathInitiatorResponderMismatchUtility(false); @@ -463,7 +437,7 @@ public class WifiAwareDataPathStateManagerTest { mDut.onDataPathRequestNotification(pubSubId, peerDiscoveryMac, ndpId); mMockLooper.dispatchAll(); inOrder.verify(mMockNative).respondToDataPathRequest(anyShort(), eq(false), - eq(ndpId), eq(""), eq(null), eq(null), any(Capabilities.class)); + eq(ndpId), eq(""), eq(null), eq(null), any()); } verifyNoMoreInteractions(mMockNative, mMockCm); @@ -486,9 +460,8 @@ public class WifiAwareDataPathStateManagerTest { InOrder inOrder = inOrder(mMockNative, mMockCm, mMockCallback, mMockSessionCallback); if (immediateHalFailure) { - when(mMockNative.initiateDataPath(anyShort(), anyInt(), anyInt(), anyInt(), - any(byte[].class), anyString(), any(byte[].class), anyString(), - any(Capabilities.class))).thenReturn(false); + when(mMockNative.initiateDataPath(anyShort(), anyInt(), anyInt(), anyInt(), any(), + any(), any(), any(), any())).thenReturn(false); } @@ -516,7 +489,7 @@ public class WifiAwareDataPathStateManagerTest { inOrder.verify(mMockNative).initiateDataPath(transactionId.capture(), eq(useDirect ? 0 : peerHandle.peerId), eq(REQUEST_CHANNEL_SETUP), eq(2437), eq(peerDiscoveryMac), - eq(sAwareInterfacePrefix + "0"), eq(pmk), eq(null), any(Capabilities.class)); + eq(sAwareInterfacePrefix + "0"), eq(pmk), eq(null), any()); if (immediateHalFailure) { // short-circuit the rest of this test verifyNoMoreInteractions(mMockNative, mMockCm); @@ -531,10 +504,8 @@ public class WifiAwareDataPathStateManagerTest { mDut.onDataPathConfirmNotification(ndpId, peerDataPathMac, true, 0, peerToken.getBytes()); mMockLooper.dispatchAll(); - inOrder.verify(mMockCm).registerNetworkAgent(messengerCaptor.capture(), - any(NetworkInfo.class), any(LinkProperties.class), - any(NetworkCapabilities.class), - anyInt(), any(NetworkMisc.class)); + inOrder.verify(mMockCm).registerNetworkAgent(messengerCaptor.capture(), any(), any(), + any(), anyInt(), any()); } else { assertTrue(mAlarmManager.dispatch( WifiAwareStateManager.HAL_DATA_PATH_CONFIRM_TIMEOUT_TAG)); @@ -606,7 +577,7 @@ public class WifiAwareDataPathStateManagerTest { mMockLooper.dispatchAll(); inOrder.verify(mMockNative).respondToDataPathRequest(transactionId.capture(), eq(true), eq(ndpId), eq(sAwareInterfacePrefix + "0"), eq(providePmk ? pmk : null), eq(null), - any(Capabilities.class)); + any()); mDut.onRespondToDataPathSetupRequestResponse(transactionId.getValue(), true, 0); mMockLooper.dispatchAll(); @@ -615,10 +586,8 @@ public class WifiAwareDataPathStateManagerTest { mDut.onDataPathConfirmNotification(ndpId, peerDataPathMac, true, 0, peerToken.getBytes()); mMockLooper.dispatchAll(); - inOrder.verify(mMockCm).registerNetworkAgent(messengerCaptor.capture(), - any(NetworkInfo.class), any(LinkProperties.class), - any(NetworkCapabilities.class), - anyInt(), any(NetworkMisc.class)); + inOrder.verify(mMockCm).registerNetworkAgent(messengerCaptor.capture(), any(), any(), + any(), anyInt(), any()); } else { assertTrue(mAlarmManager.dispatch( WifiAwareStateManager.HAL_DATA_PATH_CONFIRM_TIMEOUT_TAG)); @@ -684,7 +653,7 @@ public class WifiAwareDataPathStateManagerTest { DiscoverySessionCallback.class); mgr.attach(mMockLooperHandler, configRequest, mockCallback, null); - verify(mMockAwareService).connect(any(IBinder.class), anyString(), + verify(mMockAwareService).connect(any(), any(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); @@ -743,7 +712,7 @@ public class WifiAwareDataPathStateManagerTest { AttachCallback mockCallback = mock(AttachCallback.class); mgr.attach(mMockLooperHandler, configRequest, mockCallback, null); - verify(mMockAwareService).connect(any(IBinder.class), anyString(), + verify(mMockAwareService).connect(any(), any(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java index e60cc9e49..50a2e0d4d 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareNativeManagerTest.java @@ -18,20 +18,17 @@ package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsNull.nullValue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import android.hardware.wifi.V1_0.IWifiNanIface; -import android.hardware.wifi.V1_0.IWifiNanIfaceEventCallback; import android.hardware.wifi.V1_0.IfaceType; import android.hardware.wifi.V1_0.WifiStatus; import android.hardware.wifi.V1_0.WifiStatusCode; -import android.os.Looper; -import com.android.server.wifi.DisabledForUpdateToAnyMatcher; import com.android.server.wifi.HalDeviceManager; import org.junit.Before; @@ -72,8 +69,7 @@ public class WifiAwareNativeManagerTest { mStatusOk = new WifiStatus(); mStatusOk.code = WifiStatusCode.SUCCESS; - when(mWifiNanIfaceMock.registerEventCallback( - any(IWifiNanIfaceEventCallback.class))).thenReturn(mStatusOk); + when(mWifiNanIfaceMock.registerEventCallback(any())).thenReturn(mStatusOk); mDut = new WifiAwareNativeManager(mWifiAwareStateManagerMock, mHalDeviceManager, mWifiAwareNativeCallback); @@ -93,7 +89,6 @@ public class WifiAwareNativeManagerTest { * 8. onDestroyed -> disableUsage * 9. onStatusChange (!started) */ - @DisabledForUpdateToAnyMatcher @Test public void testControlFlow() { // configure HalDeviceManager as ready/wifi started @@ -102,34 +97,28 @@ public class WifiAwareNativeManagerTest { // validate (and capture) that register manage status callback mInOrder.verify(mHalDeviceManager).registerStatusListener( - mManagerStatusListenerCaptor.capture(), any(Looper.class)); + mManagerStatusListenerCaptor.capture(), any()); // 1 & 2 onStatusChange (ready/started): validate that trying to get a NAN interface // (make sure gets a NULL) - when(mHalDeviceManager.createNanIface( - any(HalDeviceManager.InterfaceDestroyedListener.class), - any(Looper.class))) - .thenReturn(null); + when(mHalDeviceManager.createNanIface(any(), any())).thenReturn(null); mManagerStatusListenerCaptor.getValue().onStatusChanged(); mInOrder.verify(mHalDeviceManager).registerInterfaceAvailableForRequestListener( - eq(IfaceType.NAN), mAvailListenerCaptor.capture(), any(Looper.class)); + eq(IfaceType.NAN), mAvailListenerCaptor.capture(), any()); mAvailListenerCaptor.getValue().onAvailableForRequest(); mInOrder.verify(mHalDeviceManager).createNanIface( - mDestroyedListenerCaptor.capture(), any(Looper.class)); + mDestroyedListenerCaptor.capture(), any()); collector.checkThat("null interface", mDut.getWifiNanIface(), nullValue()); // 3 & 4 onAvailableForRequest + non-null return value: validate that enables usage - when(mHalDeviceManager.createNanIface( - any(HalDeviceManager.InterfaceDestroyedListener.class), - any(Looper.class))) - .thenReturn(mWifiNanIfaceMock); + when(mHalDeviceManager.createNanIface(any(), any())).thenReturn(mWifiNanIfaceMock); mAvailListenerCaptor.getValue().onAvailableForRequest(); mInOrder.verify(mHalDeviceManager).createNanIface( - mDestroyedListenerCaptor.capture(), any(Looper.class)); + mDestroyedListenerCaptor.capture(), any()); mInOrder.verify(mWifiAwareStateManagerMock).enableUsage(); collector.checkThat("non-null interface", mDut.getWifiNanIface(), equalTo(mWifiNanIfaceMock)); @@ -147,11 +136,11 @@ public class WifiAwareNativeManagerTest { mManagerStatusListenerCaptor.getValue().onStatusChanged(); mInOrder.verify(mHalDeviceManager).registerInterfaceAvailableForRequestListener( - eq(IfaceType.NAN), mAvailListenerCaptor.capture(), any(Looper.class)); + eq(IfaceType.NAN), mAvailListenerCaptor.capture(), any()); mAvailListenerCaptor.getValue().onAvailableForRequest(); mInOrder.verify(mHalDeviceManager).createNanIface( - mDestroyedListenerCaptor.capture(), any(Looper.class)); + mDestroyedListenerCaptor.capture(), any()); mInOrder.verify(mWifiAwareStateManagerMock).enableUsage(); collector.checkThat("non-null interface", mDut.getWifiNanIface(), equalTo(mWifiNanIfaceMock)); diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareRttStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareRttStateManagerTest.java index ebc7935a6..616e68c0c 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareRttStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareRttStateManagerTest.java @@ -18,7 +18,7 @@ package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsNull.nullValue; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyNoMoreInteractions; diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java index 97b8ab378..91fe87510 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java @@ -19,10 +19,9 @@ package com.android.server.wifi.aware; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -39,13 +38,10 @@ import android.net.wifi.aware.PublishConfig; import android.net.wifi.aware.SubscribeConfig; import android.os.HandlerThread; import android.os.IBinder; -import android.os.Looper; import android.test.suitebuilder.annotation.SmallTest; import android.util.SparseArray; import android.util.SparseIntArray; -import com.android.server.wifi.DisabledForUpdateToAnyMatcher; - import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -58,7 +54,6 @@ import java.lang.reflect.Field; /** * Unit test harness for WifiAwareStateManager. */ -@DisabledForUpdateToAnyMatcher @SmallTest public class WifiAwareServiceImplTest { private static final int MAX_LENGTH = 255; @@ -120,7 +115,7 @@ public class WifiAwareServiceImplTest { mDut = new WifiAwareServiceImplSpy(mContextMock); mDut.fakeUid = mDefaultUid; mDut.start(mHandlerThreadMock, mAwareStateManagerMock); - verify(mAwareStateManagerMock).start(eq(mContextMock), any(Looper.class)); + verify(mAwareStateManagerMock).start(eq(mContextMock), any()); } /** @@ -260,7 +255,7 @@ public class WifiAwareServiceImplTest { for (int i = 0; i < loopCount; ++i) { mDut.connect(mBinderMock, "", mCallbackMock, null, false); inOrder.verify(mAwareStateManagerMock).connect(clientIdCaptor.capture(), anyInt(), - anyInt(), anyString(), eq(mCallbackMock), any(ConfigRequest.class), eq(false)); + anyInt(), any(), eq(mCallbackMock), any(), eq(false)); int id = clientIdCaptor.getValue(); if (i != 0) { assertTrue("Client ID incrementing", id > prevId); diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java index 0109bf77c..13870c03b 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java @@ -21,13 +21,12 @@ import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyShort; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyShort; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -58,8 +57,6 @@ import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; import android.util.SparseArray; -import com.android.server.wifi.DisabledForUpdateToAnyMatcher; - import libcore.util.HexEncoding; import org.junit.Before; @@ -120,9 +117,9 @@ public class WifiAwareStateManagerTest { when(mMockContext.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED); when(mMockAppOpsManager.noteOp(eq(AppOpsManager.OP_FINE_LOCATION), anyInt(), - anyString())).thenReturn(AppOpsManager.MODE_ERRORED); + any())).thenReturn(AppOpsManager.MODE_ERRORED); when(mMockAppOpsManager.noteOp(eq(AppOpsManager.OP_COARSE_LOCATION), anyInt(), - anyString())).thenReturn(AppOpsManager.MODE_ERRORED); + any())).thenReturn(AppOpsManager.MODE_ERRORED); mMockLooper = new TestLooper(); @@ -131,14 +128,14 @@ public class WifiAwareStateManagerTest { mDut.start(mMockContext, mMockLooper.getLooper()); installMocksInStateManager(mDut, mMockAwareRttStateManager, mMockAwareDataPathStatemanager); - when(mMockNative.enableAndConfigure(anyShort(), any(ConfigRequest.class), anyBoolean(), + when(mMockNative.enableAndConfigure(anyShort(), any(), anyBoolean(), anyBoolean())).thenReturn(true); when(mMockNative.disable(anyShort())).thenReturn(true); - when(mMockNative.publish(anyShort(), anyInt(), any(PublishConfig.class))).thenReturn(true); - when(mMockNative.subscribe(anyShort(), anyInt(), any(SubscribeConfig.class))) + when(mMockNative.publish(anyShort(), anyInt(), any())).thenReturn(true); + when(mMockNative.subscribe(anyShort(), anyInt(), any())) .thenReturn(true); - when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(byte[].class), - any(byte[].class), anyInt())).thenReturn(true); + when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(), + any(), anyInt())).thenReturn(true); when(mMockNative.stopPublish(anyShort(), anyInt())).thenReturn(true); when(mMockNative.stopSubscribe(anyShort(), anyInt())).thenReturn(true); when(mMockNative.getCapabilities(anyShort())).thenReturn(true); @@ -300,7 +297,7 @@ public class WifiAwareStateManagerTest { ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mMockContext, mMockNative, mockCallback); - when(mMockNative.enableAndConfigure(anyShort(), any(ConfigRequest.class), anyBoolean(), + when(mMockNative.enableAndConfigure(anyShort(), any(), anyBoolean(), anyBoolean())).thenReturn(false); // (1) check initial state @@ -397,7 +394,7 @@ public class WifiAwareStateManagerTest { when(mMockContext.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); when(mMockAppOpsManager.noteOp(eq(AppOpsManager.OP_COARSE_LOCATION), anyInt(), - anyString())).thenReturn(AppOpsManager.MODE_ALLOWED); + any())).thenReturn(AppOpsManager.MODE_ALLOWED); mDut.onInterfaceAddressChangeNotification(someMac); mMockLooper.dispatchAll(); @@ -517,7 +514,7 @@ public class WifiAwareStateManagerTest { validateInternalNoSessions(clientId); // (3) publish and get immediate failure (i.e. HAL failed) - when(mMockNative.publish(anyShort(), anyInt(), any(PublishConfig.class))).thenReturn(false); + when(mMockNative.publish(anyShort(), anyInt(), any())).thenReturn(false); mDut.publish(clientId, publishConfig, mockSessionCallback); mMockLooper.dispatchAll(); @@ -676,7 +673,7 @@ public class WifiAwareStateManagerTest { inOrder.verify(mockSessionCallback).onSessionConfigSuccess(); // (7) another update + immediate failure - when(mMockNative.publish(anyShort(), anyInt(), any(PublishConfig.class))).thenReturn(false); + when(mMockNative.publish(anyShort(), anyInt(), any())).thenReturn(false); mDut.updatePublish(clientId, sessionId.getValue(), publishConfig); mMockLooper.dispatchAll(); @@ -795,7 +792,7 @@ public class WifiAwareStateManagerTest { validateInternalNoSessions(clientId); // (3) subscribe and get immediate failure (i.e. HAL failed) - when(mMockNative.subscribe(anyShort(), anyInt(), any(SubscribeConfig.class))) + when(mMockNative.subscribe(anyShort(), anyInt(), any())) .thenReturn(false); mDut.subscribe(clientId, subscribeConfig, mockSessionCallback); @@ -954,7 +951,7 @@ public class WifiAwareStateManagerTest { inOrder.verify(mockSessionCallback).onSessionConfigSuccess(); // (7) another update + immediate failure - when(mMockNative.subscribe(anyShort(), anyInt(), any(SubscribeConfig.class))) + when(mMockNative.subscribe(anyShort(), anyInt(), any())) .thenReturn(false); mDut.updateSubscribe(clientId, sessionId.getValue(), subscribeConfig); @@ -1472,8 +1469,8 @@ public class WifiAwareStateManagerTest { validateInternalSendMessageQueuesCleanedUp(messageId + 2); // (5) send a message and get an immediate failure (configure first) - when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(byte[].class), - any(byte[].class), anyInt())).thenReturn(false); + when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(), + any(), anyInt())).thenReturn(false); mDut.sendMessage(clientId, sessionId.getValue(), requestorId, ssi.getBytes(), messageId + 3, 0); @@ -1681,7 +1678,6 @@ public class WifiAwareStateManagerTest { * Validate that the host-side message queue functions. Tests the perfect case of queue always * succeeds and all messages are received on first attempt. */ - @DisabledForUpdateToAnyMatcher @Test public void testSendMessageQueueSequence() throws Exception { final int clientId = 1005; @@ -1739,8 +1735,8 @@ public class WifiAwareStateManagerTest { // (3) transmit messages SendMessageQueueModelAnswer answerObj = new SendMessageQueueModelAnswer(queueDepth, null, null, null); - when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(byte[].class), - any(byte[].class), anyInt())).thenAnswer(answerObj); + when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(), + any(), anyInt())).thenAnswer(answerObj); int remainingMessages = numberOfMessages; for (int i = 0; i < numberOfMessages; ++i) { @@ -1777,7 +1773,6 @@ public class WifiAwareStateManagerTest { * - Failure to transmit: OTA (which will be retried) * - Failure to transmit: other */ - @DisabledForUpdateToAnyMatcher @Test public void testSendMessageQueueSequenceImperfect() throws Exception { final int clientId = 1005; @@ -1880,8 +1875,8 @@ public class WifiAwareStateManagerTest { SendMessageQueueModelAnswer answerObj = new SendMessageQueueModelAnswer(queueDepth, failQueueCommandImmediately, failQueueCommandLater, numberOfRetries); - when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(byte[].class), - any(byte[].class), anyInt())).thenAnswer(answerObj); + when(mMockNative.sendMessage(anyShort(), anyInt(), anyInt(), any(), + any(), anyInt())).thenAnswer(answerObj); for (int i = 0; i < numberOfMessages; ++i) { mDut.sendMessage(clientId, sessionId.getValue(), requestorId, null, messageIdBase + i, @@ -1906,7 +1901,6 @@ public class WifiAwareStateManagerTest { /** * Validate that can send empty message successfully: null, byte[0], "" */ - @DisabledForUpdateToAnyMatcher @Test public void testSendEmptyMessages() throws Exception { final int clientId = 1005; |