summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hugo Benichi <hugobenichi@google.com> 2017-07-18 16:17:49 +0900
committer Hugo Benichi <hugobenichi@google.com> 2017-07-18 21:31:17 +0900
commitc10fe5f463676a05ecd3f76a5f7037700ea49b0d (patch)
treeda0fca48c10b6f3d4912d6f687e4fa445ddd036e
parentd2c8dcfcfe4cdc4fb4d3d86a8a7e6e7d43fdd9c0 (diff)
IpManager: fix test for default ProvisioningConfiguration
The test did not properly account for the stopAllIP() done in starting state of the IpManager state machine, which could cause assertions to fail when stopAllIP() is called again after stop(). Bug: 62988545 Test: runtest frameworks-net Change-Id: I2c6eb76461a81c1d743bf448da36c58a99ce082d
-rw-r--r--tests/net/java/android/net/ip/IpManagerTest.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/net/java/android/net/ip/IpManagerTest.java b/tests/net/java/android/net/ip/IpManagerTest.java
index e7dbfe3f5044..867324d99920 100644
--- a/tests/net/java/android/net/ip/IpManagerTest.java
+++ b/tests/net/java/android/net/ip/IpManagerTest.java
@@ -75,7 +75,8 @@ public class IpManagerTest {
@Mock private AlarmManager mAlarm;
private MockContentResolver mContentResolver;
- @Before public void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(eq(Context.ALARM_SERVICE))).thenReturn(mAlarm);
@@ -88,6 +89,13 @@ public class IpManagerTest {
when(mContext.getContentResolver()).thenReturn(mContentResolver);
}
+ private IpManager makeIpManager(String ifname) throws Exception {
+ final IpManager ipm = new IpManager(mContext, ifname, mCb, mNMService);
+ verify(mNMService, timeout(100).times(1)).disableIpv6(ifname);
+ verify(mNMService, timeout(100).times(1)).clearInterfaceAddresses(ifname);
+ return ipm;
+ }
+
@Test
public void testNullCallbackDoesNotThrow() throws Exception {
final IpManager ipm = new IpManager(mContext, "lo", null, mNMService);
@@ -101,7 +109,8 @@ public class IpManagerTest {
@Test
public void testDefaultProvisioningConfiguration() throws Exception {
final String iface = "test_wlan0";
- final IpManager ipm = new IpManager(mContext, iface, mCb, mNMService);
+ final IpManager ipm = makeIpManager(iface);
+
ProvisioningConfiguration config = new ProvisioningConfiguration.Builder()
.withoutIPv4()
// TODO: mock IpReachabilityMonitor's dependencies (NetworkInterface, PowerManager)