[NAN] Fix unit tests: fail due to new method/renamed var
1. New interaction added with a mock which wasn't validated.
2. Unit tests depend on internal variable name (reflection) to
fool the underlying HAL implementation to think that it is
initialized.
Test: validated that test failures eliminated.
Bug: 27880727
Change-Id: I5c49ff7a532bd5a702ef5ed8173798bb4b47d94b
diff --git a/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalMock.java b/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalMock.java
index 60fdd1e..5c233af 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalMock.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalMock.java
@@ -94,7 +94,7 @@
private static native int initNanHalMock();
public static void initNanHalMockLibrary(WifiNanNative instance) throws Exception {
- Field field = WifiNanNative.class.getDeclaredField("mNanNativeInit");
+ Field field = WifiNanNative.class.getDeclaredField("mNativeHandlersIsInitialized");
field.setAccessible(true);
field.setBoolean(instance, true);
diff --git a/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
index 37ed493..a2bfe1b 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
@@ -132,6 +132,7 @@
mMockLooper.dispatchAll();
collector.checkThat("usage disabled", mDut.isUsageEnabled(), equalTo(false));
inOrder.verify(mMockNative).disable((short) 0);
+ inOrder.verify(mMockNative).deInitNan();
validateCorrectNanStatusChangeBroadcast(inOrder, false);
// (3) try connecting and validate that get nothing (app should be aware of non-availability
@@ -178,6 +179,7 @@
mMockLooper.dispatchAll();
collector.checkThat("usage disabled", mDut.isUsageEnabled(), equalTo(false));
inOrder.verify(mMockNative).disable((short) 0);
+ inOrder.verify(mMockNative).deInitNan();
validateCorrectNanStatusChangeBroadcast(inOrder, false);
validateInternalClientInfoCleanedUp(clientId);