summaryrefslogtreecommitdiff
path: root/lowpan/tests
diff options
context:
space:
mode:
authorRobert Quattlebaum <rquattle@google.com>2017-07-14 12:18:39 -0700
committerRobert Quattlebaum <rquattle@google.com>2017-07-18 00:42:18 -0700
commit6cfc490ccd8ea0d9ef4d52482ff65471f7631969 (patch)
tree59fc81eb7a0679a1850efbd86d0cd1d6c62d88f1 /lowpan/tests
parent865fdc75c324769d07881c04b3400d99e4b4b33f (diff)
lowpan: AIDL refactor to no longer use property design pattern
After doing a considerable amount of thinking on the subject, I decided that attempting to directly port wpantund's property-based API over to Binder was a mistake, so this commit contains the required changes to abandon that approach and go with a more traditional Binder interface. Bug: b/63708348 Change-Id: I685cd066fabe8470ef4bb456aea7d3bb515c3969 Test: Compiled and ran unit tests, manually confirmed lowpanctl and lowpan-service (with related changes) appeared to be working properly.
Diffstat (limited to 'lowpan/tests')
-rw-r--r--lowpan/tests/java/android/net/lowpan/LowpanInterfaceTest.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/lowpan/tests/java/android/net/lowpan/LowpanInterfaceTest.java b/lowpan/tests/java/android/net/lowpan/LowpanInterfaceTest.java
index a495d3d7a784..f26a37ed71ce 100644
--- a/lowpan/tests/java/android/net/lowpan/LowpanInterfaceTest.java
+++ b/lowpan/tests/java/android/net/lowpan/LowpanInterfaceTest.java
@@ -20,6 +20,7 @@ import static org.mockito.Mockito.*;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.net.LinkAddress;
import android.os.Handler;
import android.os.IBinder;
import android.os.test.TestLooper;
@@ -86,4 +87,66 @@ public class LowpanInterfaceTest {
.onStateChanged(
argThat(stateString -> stateString.equals(LowpanInterface.STATE_OFFLINE)));
}
+
+ @Test
+ public void testLinkAddressCallback() throws Exception {
+ // Register our callback
+ mLowpanInterface.registerCallback(mLowpanInterfaceCallback);
+
+ // Verify a listener was added
+ verify(mLowpanInterfaceService)
+ .addListener(
+ argThat(
+ listener -> {
+ mInterfaceListener = listener;
+ return listener instanceof ILowpanInterfaceListener;
+ }));
+
+ final LinkAddress linkAddress = new LinkAddress("fe80::1/64");
+
+ // Change some properties
+ mInterfaceListener.onLinkAddressAdded(linkAddress.toString());
+ mTestLooper.dispatchAll();
+
+ // Verify that the property was changed
+ verify(mLowpanInterfaceCallback)
+ .onLinkAddressAdded(argThat(addr -> addr.equals(linkAddress)));
+
+ // Change some properties
+ mInterfaceListener.onLinkAddressRemoved(linkAddress.toString());
+ mTestLooper.dispatchAll();
+
+ // Verify that the property was changed
+ verify(mLowpanInterfaceCallback)
+ .onLinkAddressRemoved(argThat(addr -> addr.equals(linkAddress)));
+ }
+
+ @Test
+ public void testBogusLinkAddressCallback() throws Exception {
+ // Register our callback
+ mLowpanInterface.registerCallback(mLowpanInterfaceCallback);
+
+ // Verify a listener was added
+ verify(mLowpanInterfaceService)
+ .addListener(
+ argThat(
+ listener -> {
+ mInterfaceListener = listener;
+ return listener instanceof ILowpanInterfaceListener;
+ }));
+
+ // Change some properties
+ mInterfaceListener.onLinkAddressAdded("fe80:::1/640");
+ mTestLooper.dispatchAll();
+
+ // Verify that no callback was called.
+ verifyNoMoreInteractions(mLowpanInterfaceCallback);
+
+ // Change some properties
+ mInterfaceListener.onLinkAddressRemoved("fe80:::1/640");
+ mTestLooper.dispatchAll();
+
+ // Verify that no callback was called.
+ verifyNoMoreInteractions(mLowpanInterfaceCallback);
+ }
}