summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGlen Kuhne <kuh@google.com>2016-02-11 17:05:33 +0000
committerAndroid Partner Code Review <android-gerrit-partner@google.com>2016-02-11 17:05:34 +0000
commit6eb121431c67b98d8b14242a34c28b205a42b119 (patch)
treee8e99898301404f45cd245838167c677470a0dd3 /tests
parentbbb3149f3bc301e81c202438b77c45574a90a851 (diff)
parent2532a24b254d724a9b6771d327dc410b32b18602 (diff)
Merge "WifiMetrics ConnectionEvent logging" into mm-wireless-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java28
1 files changed, 15 insertions, 13 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 69d8ac29a..57a223640 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -17,7 +17,6 @@ package com.android.server.wifi;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.net.wifi.WifiInfo;
@@ -26,6 +25,7 @@ import android.util.Base64;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
@@ -41,32 +41,34 @@ public class WifiMetricsTest {
WifiMetrics mWifiMetrics;
WifiMetricsProto.WifiLog mDeserializedWifiMetrics;
@Mock WifiInfo mWifiInfo;
-
@Before
public void setUp() throws Exception {
- mWifiInfo = null;
+ MockitoAnnotations.initMocks(this);
+ when(mWifiInfo.getRssi()).thenReturn(-70);
mDeserializedWifiMetrics = null;
mWifiMetrics = new WifiMetrics();
}
/**
* Test that startConnectionEvent and endConnectionEvent can be called repeatedly and out of
- * order. Only tests no exception occurs
+ * order. Only tests no exception occurs. Creates 3 ConnectionEvents.
*/
@Test
public void startAndEndConnectionEventSucceeds() throws Exception {
- mWifiInfo = mock(WifiInfo.class);
- when(mWifiInfo.getRssi()).thenReturn(77);
//Start and end Connection event
- mWifiMetrics.startConnectionEvent(mWifiInfo,
+ mWifiMetrics.startConnectionEvent(mWifiInfo, null,
WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE);
- mWifiMetrics.endConnectionEvent(88, WifiMetricsProto.ConnectionEvent.HLF_DHCP);
+ mWifiMetrics.endConnectionEvent(
+ WifiMetrics.ConnectionEvent.LLF_AUTHENTICATION_FAILURE,
+ WifiMetricsProto.ConnectionEvent.HLF_DHCP);
//end Connection event without starting one
- mWifiMetrics.endConnectionEvent(99, WifiMetricsProto.ConnectionEvent.HLF_DHCP);
+ mWifiMetrics.endConnectionEvent(
+ WifiMetrics.ConnectionEvent.LLF_AUTHENTICATION_FAILURE,
+ WifiMetricsProto.ConnectionEvent.HLF_DHCP);
//start two ConnectionEvents in a row
- mWifiMetrics.startConnectionEvent(mWifiInfo,
+ mWifiMetrics.startConnectionEvent(mWifiInfo, null,
WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE);
- mWifiMetrics.startConnectionEvent(mWifiInfo,
+ mWifiMetrics.startConnectionEvent(mWifiInfo, null,
WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE);
}
@@ -220,8 +222,8 @@ public class WifiMetricsTest {
startAndEndConnectionEventSucceeds();
serializeDeserialize();
assertDeserializedMetricsCorrect();
- assertEquals("mDeserializedWifiMetrics.connectionEvent.length == 4",
- mDeserializedWifiMetrics.connectionEvent.length, 4);
+ assertEquals("mDeserializedWifiMetrics.connectionEvent.length",
+ 3, mDeserializedWifiMetrics.connectionEvent.length);
//<TODO> test individual connectionEvents for correctness,
// check scanReturnEntries & wifiSystemStateEntries counts and individual elements
// pending their implementation</TODO>