summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSohani Rao <sohanirao@google.com>2016-12-19 18:33:32 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-12-19 18:33:32 +0000
commitf64b4f9cab2e72bea96f8243055c539fff3d19a7 (patch)
tree22d8c51d526501e3db02c5bd8e57adcaf2c78c88 /tests
parent3114533107f4fb87b4f1f9cca61829d37d2c2d03 (diff)
parent4fbaf3821bd5c3056c7c4cdd1aee3e17ac7046d0 (diff)
Merge changes from topic 'WifiHandler'
* changes: Log API surfaces of WifiScanningService Add logging for messages sent to WifiP2pService Subclass Handler to log incoming messages
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/WifiHandlerTest.java62
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
index 8e3be65cb..d99d290fa 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -48,6 +48,7 @@ import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;
import com.android.internal.util.test.BidirectionalAsyncChannel;
import com.android.server.wifi.Clock;
+import com.android.server.wifi.FakeWifiLog;
import com.android.server.wifi.ScanResults;
import com.android.server.wifi.TestUtil;
import com.android.server.wifi.WifiInjector;
@@ -62,6 +63,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
import org.mockito.internal.matchers.CapturingMatcher;
import java.io.FileDescriptor;
@@ -89,6 +91,7 @@ public class WifiScanningServiceTest {
@Mock IBatteryStats mBatteryStats;
@Mock WifiInjector mWifiInjector;
@Mock Clock mClock;
+ @Spy FakeWifiLog mLog;
WifiMetrics mWifiMetrics;
TestLooper mLooper;
WifiScanningServiceImpl mWifiScanningServiceImpl;
@@ -114,6 +117,7 @@ public class WifiScanningServiceTest {
.thenReturn(mWifiScannerImpl);
when(mWifiScannerImpl.getChannelHelper()).thenReturn(channelHelper);
when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics);
+ when(mWifiInjector.makeLog(anyString())).thenReturn(mLog);
mWifiScanningServiceImpl = new WifiScanningServiceImpl(mContext, mLooper.getLooper(),
mWifiScannerImplFactory, mBatteryStats, mWifiInjector);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/util/WifiHandlerTest.java b/tests/wifitests/src/com/android/server/wifi/util/WifiHandlerTest.java
new file mode 100644
index 000000000..220e6d78e
--- /dev/null
+++ b/tests/wifitests/src/com/android/server/wifi/util/WifiHandlerTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.server.wifi.util;
+
+import android.os.Looper;
+import android.os.Message;
+import android.os.test.TestLooper;
+
+import com.android.server.wifi.FakeWifiLog;
+
+import static org.mockito.Matchers.contains;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+
+/** Unit tests for {@link WifiHandler}. */
+@RunWith(JUnit4.class)
+public class WifiHandlerTest {
+ private static final String TAG = "WifiHandlerTest";
+ private WifiHandler mCodeUnderTest;
+ @Spy FakeWifiLog mWifiLog;
+ TestLooper mLooper;
+
+ private class WifiHandlerTestClass extends WifiHandler {
+ WifiHandlerTestClass(String tag, Looper looper) {
+ super(tag, looper);
+ super.setWifiLog(mWifiLog);
+ }
+ }
+
+ @Before public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mLooper = new TestLooper();
+ mCodeUnderTest = new WifiHandlerTestClass(TAG, mLooper.getLooper());
+ }
+
+ @Test public void testHandleMessage() {
+ Message msg = Message.obtain();
+ msg.what = 0;
+ msg.sendingUid = 0;
+ mCodeUnderTest.handleMessage(msg);
+ verify(mWifiLog).trace(contains("message"));
+ }
+}