summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2016-09-20 17:23:46 -0700
committerEtan Cohen <etancohen@google.com>2016-09-21 18:10:27 -0700
commitf7237ad859aa94bbb0ed4f5cb94ee4b9bfed4045 (patch)
treee026214333c227f6bcb95557c6a74139293b4654 /tests
parent215daae519cda269bf999b6e83a20be9aa86d1e2 (diff)
[NAN] Separate ATTACH from IDENTITY_CHANGE callbacks.
Provide separate mechanism to attach with a request for identity change listener. (cherry-pick of commit 2023a4a9f8b3621d972c85969c609e5dc96728f1) Bug: 31470256 Test: unit tests & integration (sl4a) tests. Change-Id: Idf8fcb8029ce7e81596b378416a8483074ecaadc
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java16
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java56
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java140
5 files changed, 89 insertions, 142 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java
index 8b96ef1ed..32b66dc0f 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java
@@ -46,8 +46,8 @@ import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.IWifiNanManager;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.net.wifi.nan.WifiNanManager;
import android.net.wifi.nan.WifiNanPublishDiscoverySession;
import android.net.wifi.nan.WifiNanSession;
@@ -607,13 +607,13 @@ public class WifiNanDataPathStateManagerTest {
ArgumentCaptor<WifiNanPublishDiscoverySession> publishSession = ArgumentCaptor
.forClass(WifiNanPublishDiscoverySession.class);
- WifiNanEventCallback mockCallback = mock(WifiNanEventCallback.class);
+ WifiNanAttachCallback mockCallback = mock(WifiNanAttachCallback.class);
WifiNanDiscoverySessionCallback mockSessionCallback = mock(
WifiNanDiscoverySessionCallback.class);
- mgr.attach(mMockLooperHandler, configRequest, mockCallback);
+ mgr.attach(mMockLooperHandler, configRequest, mockCallback, null);
verify(mMockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -650,11 +650,11 @@ public class WifiNanDataPathStateManagerTest {
ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor
.forClass(IWifiNanEventCallback.class);
- WifiNanEventCallback mockCallback = mock(WifiNanEventCallback.class);
+ WifiNanAttachCallback mockCallback = mock(WifiNanAttachCallback.class);
- mgr.attach(mMockLooperHandler, configRequest, mockCallback);
+ mgr.attach(mMockLooperHandler, configRequest, mockCallback, null);
verify(mMockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -715,7 +715,7 @@ public class WifiNanDataPathStateManagerTest {
mMockLooper.dispatchAll();
// (3) create client & session & rx message
- mDut.connect(clientId, uid, pid, callingPackage, mMockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mMockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
index 2a607691e..d073d4dae 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
@@ -26,8 +26,8 @@ import android.net.wifi.nan.ConfigRequest;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
import android.net.wifi.nan.TlvBufferUtils;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.os.Bundle;
import android.test.suitebuilder.annotation.SmallTest;
@@ -379,7 +379,7 @@ public class WifiNanHalTest {
HalMockUtils.convertBundleToJson(args).toString());
verify(mNanStateManager).onConfigFailedResponse(transactionId,
- WifiNanEventCallback.REASON_INVALID_ARGS);
+ WifiNanAttachCallback.REASON_INVALID_ARGS);
verifyNoMoreInteractions(mNanStateManager);
}
@@ -768,7 +768,7 @@ public class WifiNanHalTest {
WifiNanHalMock.callDisabled(HalMockUtils.convertBundleToJson(args).toString());
- verify(mNanStateManager).onNanDownNotification(WifiNanEventCallback.REASON_OTHER);
+ verify(mNanStateManager).onNanDownNotification(WifiNanAttachCallback.REASON_OTHER);
verifyNoMoreInteractions(mNanStateManager);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
index 4a633760f..4bebfb7f1 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
@@ -36,8 +36,8 @@ import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.IWifiNanManager;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.net.wifi.nan.WifiNanManager;
import android.net.wifi.nan.WifiNanPublishDiscoverySession;
import android.net.wifi.nan.WifiNanSession;
@@ -77,7 +77,7 @@ public class WifiNanManagerTest {
public Context mockContext;
@Mock
- public WifiNanEventCallback mockCallback;
+ public WifiNanAttachCallback mockCallback;
@Mock
public WifiNanDiscoverySessionCallback mockSessionCallback;
@@ -159,7 +159,7 @@ public class WifiNanManagerTest {
// (1) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(binder.capture(), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -181,7 +181,7 @@ public class WifiNanManagerTest {
// (5) connect
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(binder.capture(), anyString(),
- any(IWifiNanEventCallback.class), (ConfigRequest) isNull());
+ any(IWifiNanEventCallback.class), (ConfigRequest) isNull(), eq(false));
verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService);
}
@@ -192,7 +192,7 @@ public class WifiNanManagerTest {
@Test
public void testConnectFailure() throws Exception {
final int clientId = 4565;
- final int reason = WifiNanEventCallback.REASON_OTHER;
+ final int reason = WifiNanAttachCallback.REASON_OTHER;
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService);
ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass(
@@ -203,7 +203,7 @@ public class WifiNanManagerTest {
// (1) connect + failure
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectFail(reason);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttachFailed(reason);
@@ -211,7 +211,7 @@ public class WifiNanManagerTest {
// (2) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -241,7 +241,7 @@ public class WifiNanManagerTest {
// (1) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(any(WifiNanSession.class));
@@ -249,7 +249,7 @@ public class WifiNanManagerTest {
// (2) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId + 1);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(any(WifiNanSession.class));
@@ -291,9 +291,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanPublishDiscoverySession.class);
// (0) connect + success
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -370,9 +370,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanPublishDiscoverySession.class);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -425,9 +425,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanSubscribeDiscoverySession.class);
// (0) connect + success
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -504,9 +504,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanSubscribeDiscoverySession.class);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -544,8 +544,6 @@ public class WifiNanManagerTest {
collector.checkThat("mMasterPreference", 0,
equalTo(configRequest.mMasterPreference));
collector.checkThat("mSupport5gBand", false, equalTo(configRequest.mSupport5gBand));
- collector.checkThat("mEnableIdentityChangeCallback", false,
- equalTo(configRequest.mEnableIdentityChangeCallback));
}
@Test
@@ -554,20 +552,17 @@ public class WifiNanManagerTest {
final int clusterLow = 5;
final int masterPreference = 55;
final boolean supportBand5g = true;
- final boolean enableIdentityChangeCallback = true;
ConfigRequest configRequest = new ConfigRequest.Builder().setClusterHigh(clusterHigh)
.setClusterLow(clusterLow).setMasterPreference(masterPreference)
.setSupport5gBand(supportBand5g)
- .setEnableIdentityChangeCallback(enableIdentityChangeCallback).build();
+ .build();
collector.checkThat("mClusterHigh", clusterHigh, equalTo(configRequest.mClusterHigh));
collector.checkThat("mClusterLow", clusterLow, equalTo(configRequest.mClusterLow));
collector.checkThat("mMasterPreference", masterPreference,
equalTo(configRequest.mMasterPreference));
collector.checkThat("mSupport5gBand", supportBand5g, equalTo(configRequest.mSupport5gBand));
- collector.checkThat("mEnableIdentityChangeCallback", enableIdentityChangeCallback,
- equalTo(configRequest.mEnableIdentityChangeCallback));
}
@Test(expected = IllegalArgumentException.class)
@@ -622,12 +617,11 @@ public class WifiNanManagerTest {
final int clusterLow = 25;
final int masterPreference = 177;
final boolean supportBand5g = true;
- final boolean enableIdentityChangeCallback = true;
ConfigRequest configRequest = new ConfigRequest.Builder().setClusterHigh(clusterHigh)
.setClusterLow(clusterLow).setMasterPreference(masterPreference)
.setSupport5gBand(supportBand5g)
- .setEnableIdentityChangeCallback(enableIdentityChangeCallback).build();
+ .build();
Parcel parcelW = Parcel.obtain();
configRequest.writeToParcel(parcelW, 0);
@@ -880,9 +874,9 @@ public class WifiNanManagerTest {
.forClass(RttManager.RttResult[].class);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -954,9 +948,9 @@ public class WifiNanManagerTest {
mockPublishSession, mockRttListener);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -1014,9 +1008,9 @@ public class WifiNanManagerTest {
mockPublishSession, mockRttListener);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java
index f7077afd7..13912e9b6 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java
@@ -171,10 +171,10 @@ public class WifiNanServiceImplTest {
String callingPackage = "com.google.somePackage";
mDut.connect(mBinderMock, callingPackage, mCallbackMock,
- configRequest);
+ configRequest, false);
verify(mNanStateManagerMock).connect(anyInt(), anyInt(), anyInt(),
- eq(callingPackage), eq(mCallbackMock), eq(configRequest));
+ eq(callingPackage), eq(mCallbackMock), eq(configRequest), eq(false));
}
/**
@@ -278,9 +278,9 @@ public class WifiNanServiceImplTest {
int prevId = 0;
for (int i = 0; i < loopCount; ++i) {
- mDut.connect(mBinderMock, "", mCallbackMock, null);
+ mDut.connect(mBinderMock, "", mCallbackMock, null, false);
inOrder.verify(mNanStateManagerMock).connect(clientIdCaptor.capture(), anyInt(),
- anyInt(), anyString(), eq(mCallbackMock), any(ConfigRequest.class));
+ anyInt(), anyString(), eq(mCallbackMock), any(ConfigRequest.class), eq(false));
int id = clientIdCaptor.getValue();
if (i != 0) {
assertTrue("Client ID incrementing", id > prevId);
@@ -495,11 +495,12 @@ public class WifiNanServiceImplTest {
private int doConnect() {
String callingPackage = "com.google.somePackage";
- mDut.connect(mBinderMock, callingPackage, mCallbackMock, null);
+ mDut.connect(mBinderMock, callingPackage, mCallbackMock, null, false);
ArgumentCaptor<Integer> clientId = ArgumentCaptor.forClass(Integer.class);
verify(mNanStateManagerMock).connect(clientId.capture(), anyInt(), anyInt(),
- eq(callingPackage), eq(mCallbackMock), eq(new ConfigRequest.Builder().build()));
+ eq(callingPackage), eq(mCallbackMock), eq(new ConfigRequest.Builder().build()),
+ eq(false));
return clientId.getValue();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
index cb78f7232..94a969b3d 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
@@ -47,8 +47,8 @@ import android.net.wifi.nan.IWifiNanDiscoverySessionCallback;
import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.net.wifi.nan.WifiNanManager;
import android.os.Message;
import android.os.UserHandle;
@@ -207,7 +207,7 @@ public class WifiNanStateManagerTest {
// (3) try connecting and validate that get nothing (app should be aware of non-availability
// through state change broadcast and/or query API)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
verifyNoMoreInteractions(mMockNative, mockCallback);
@@ -242,7 +242,7 @@ public class WifiNanStateManagerTest {
collector.checkThat("usage enabled", mDut.isUsageEnabled(), equalTo(true));
// (2) connect (successfully)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -260,7 +260,7 @@ public class WifiNanStateManagerTest {
validateInternalClientInfoCleanedUp(clientId);
// (4) try connecting again and validate that just get an onNanDown
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
// (5) disable usage again and validate that not much happens
@@ -276,7 +276,7 @@ public class WifiNanStateManagerTest {
validateCorrectNanStatusChangeBroadcast(inOrder, true);
// (7) connect (should be successful)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -301,17 +301,13 @@ public class WifiNanStateManagerTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
- final int reason = WifiNanEventCallback.REASON_OTHER;
+ final int reason = WifiNanAttachCallback.REASON_OTHER;
final byte[] someMac = HexEncoding.decode("000102030405".toCharArray(), false);
final byte[] someMac2 = HexEncoding.decode("060708090A0B".toCharArray(), false);
- ConfigRequest configRequest1 = new ConfigRequest.Builder().setClusterLow(clusterLow)
- .setClusterHigh(clusterHigh).setMasterPreference(masterPref)
- .setEnableIdentityChangeCallback(false).build();
-
- ConfigRequest configRequest2 = new ConfigRequest.Builder().setClusterLow(clusterLow)
+ ConfigRequest configRequest = new ConfigRequest.Builder().setClusterLow(clusterLow)
.setClusterHigh(clusterHigh).setMasterPreference(masterPref)
- .setEnableIdentityChangeCallback(true).build();
+ .build();
IWifiNanEventCallback mockCallback1 = mock(IWifiNanEventCallback.class);
IWifiNanEventCallback mockCallback2 = mock(IWifiNanEventCallback.class);
@@ -326,44 +322,36 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect 1st and 2nd clients
- mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest1);
- mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2);
+ mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest, false);
+ mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest, true);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionIdCapture.capture(),
- eq(configRequest1), eq(true));
+ eq(configRequest), eq(true));
short transactionId = transactionIdCapture.getValue();
mDut.onConfigSuccessResponse(transactionId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback1).onConnectSuccess(clientId1);
-
- // (2) finish connection of 2nd client
- inOrder.verify(mMockNative).enableAndConfigure(transactionIdCapture.capture(),
- eq(configRequest2), eq(false));
- transactionId = transactionIdCapture.getValue();
- mDut.onConfigSuccessResponse(transactionId);
- mMockLooper.dispatchAll();
-
inOrder.verify(mockCallback2).onConnectSuccess(clientId2);
- // (3) deliver NAN events - without LOCATIONING permission
+ // (2) deliver NAN events - without LOCATIONING permission
mDut.onClusterChangeNotification(WifiNanClientState.CLUSTER_CHANGE_EVENT_STARTED, someMac);
mDut.onInterfaceAddressChangeNotification(someMac);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2).onIdentityChanged(ALL_ZERO_MAC);
- // (4) deliver new identity - still without LOCATIONING permission (should get an event)
+ // (3) deliver new identity - still without LOCATIONING permission (should get an event)
mDut.onInterfaceAddressChangeNotification(someMac2);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2).onIdentityChanged(ALL_ZERO_MAC);
- // (5) deliver same identity - still without LOCATIONING permission (should
+ // (4) deliver same identity - still without LOCATIONING permission (should
// not get an event)
mDut.onInterfaceAddressChangeNotification(someMac2);
mMockLooper.dispatchAll();
- // (6) deliver new identity - with LOCATIONING permission
+ // (5) deliver new identity - with LOCATIONING permission
when(mMockContext.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION),
anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
when(mMockAppOpsManager.noteOp(eq(AppOpsManager.OP_COARSE_LOCATION), anyInt(),
@@ -373,7 +361,7 @@ public class WifiNanStateManagerTest {
inOrder.verify(mockCallback2).onIdentityChanged(someMac);
- // (7) NAN down (no feedback)
+ // (6) NAN down (no feedback)
mDut.onNanDownNotification(reason);
mMockLooper.dispatchAll();
@@ -412,7 +400,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect (successfully)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -470,7 +458,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -525,7 +513,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -599,7 +587,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -673,7 +661,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -732,7 +720,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -787,7 +775,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -860,7 +848,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -934,7 +922,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1008,7 +996,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -1115,7 +1103,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1210,7 +1198,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1294,7 +1282,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1361,7 +1349,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1455,7 +1443,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1542,7 +1530,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1633,7 +1621,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -1749,7 +1737,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1917,7 +1905,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1970,23 +1958,17 @@ public class WifiNanStateManagerTest {
final int clusterLow2 = 7;
final int clusterHigh2 = 155;
final int masterPref2 = 0;
- final int clientId3 = 55;
ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class);
ArgumentCaptor<ConfigRequest> crCapture = ArgumentCaptor.forClass(ConfigRequest.class);
ConfigRequest configRequest1 = new ConfigRequest.Builder().setClusterLow(clusterLow1)
- .setClusterHigh(clusterHigh1).setMasterPreference(masterPref1)
- .setEnableIdentityChangeCallback(false).build();
+ .setClusterHigh(clusterHigh1).setMasterPreference(masterPref1).build();
ConfigRequest configRequest2 = new ConfigRequest.Builder().setSupport5gBand(support5g2)
.setClusterLow(clusterLow2).setClusterHigh(clusterHigh2)
.setMasterPreference(masterPref2).build();
- ConfigRequest configRequest3 = new ConfigRequest.Builder().setClusterLow(clusterLow1)
- .setClusterHigh(clusterHigh1).setMasterPreference(masterPref1)
- .setEnableIdentityChangeCallback(true).build();
-
IWifiNanEventCallback mockCallback1 = mock(IWifiNanEventCallback.class);
IWifiNanEventCallback mockCallback2 = mock(IWifiNanEventCallback.class);
IWifiNanEventCallback mockCallback3 = mock(IWifiNanEventCallback.class);
@@ -2001,7 +1983,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) config1 (valid)
- mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest1);
+ mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest1, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
crCapture.capture(), eq(true));
@@ -2011,42 +1993,12 @@ public class WifiNanStateManagerTest {
inOrder.verify(mockCallback1).onConnectSuccess(clientId1);
// (2) config2 (incompatible with config1)
- mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2);
+ mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2)
- .onConnectFail(WifiNanEventCallback.REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG);
+ .onConnectFail(WifiNanAttachCallback.REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG);
validateInternalClientInfoCleanedUp(clientId2);
- // (3) config3 (compatible with config1 but requires upgrade - i.e. no
- // OTA changes)
- mDut.connect(clientId3, uid, pid, callingPackage, mockCallback3, configRequest3);
- mMockLooper.dispatchAll();
- inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
- crCapture.capture(), eq(false));
- collector.checkThat("merge: stage 3: support 5g", crCapture.getValue().mSupport5gBand,
- equalTo(false));
- collector.checkThat("merge: stage 3: master pref", crCapture.getValue().mMasterPreference,
- equalTo(masterPref1));
- collector.checkThat("merge: stage 3: cluster low", crCapture.getValue().mClusterLow,
- equalTo(clusterLow1));
- collector.checkThat("merge: stage 3: cluster high", crCapture.getValue().mClusterHigh,
- equalTo(clusterHigh1));
- collector.checkThat("merge: stage 3: enable identity change callback",
- crCapture.getValue().mEnableIdentityChangeCallback, equalTo(true));
- mDut.onConfigSuccessResponse(transactionId.getValue());
- mMockLooper.dispatchAll();
- inOrder.verify(mockCallback3).onConnectSuccess(clientId3);
-
- // (4) disconnect config3: want a downgrade
- mDut.disconnect(clientId3);
- mMockLooper.dispatchAll();
- validateInternalClientInfoCleanedUp(clientId3);
- inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
- crCapture.capture(), eq(false));
- collector.checkThat("merge: stage 4", crCapture.getValue(), equalTo(configRequest1));
- mDut.onConfigSuccessResponse(transactionId.getValue());
- mMockLooper.dispatchAll();
-
// (5) disconnect config1: disable
mDut.disconnect(clientId1);
mMockLooper.dispatchAll();
@@ -2095,7 +2047,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2171,7 +2123,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2215,7 +2167,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect (no response)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2250,7 +2202,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect and succeed
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2307,7 +2259,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2363,7 +2315,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -2417,7 +2369,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));