summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2016-12-21 18:01:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-12-21 18:01:12 +0000
commit56924e1d3b0d360406d661f051d500e6bc16a953 (patch)
treeb436a6f144c82fa29ea10276dc9bd9501a66a04e /tests
parent1d1a1faf157dbdee628aee0919b089b10e0a7ed0 (diff)
parentda918df16e03ee19be62343313d954027d3eb3ab (diff)
Merge "WifiServiceImpl: allow for unit tests"
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
new file mode 100644
index 000000000..c5b0f8a4c
--- /dev/null
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.HandlerThread;
+import android.os.test.TestLooper;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.internal.util.AsyncChannel;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Unit tests for {@link WifiServiceImpl}.
+ *
+ * Note: this is intended to build up over time and will not immediately cover the entire file.
+ */
+@SmallTest
+public class WifiServiceImplTest {
+
+ private static final String TAG = "WifiServiceImplTest";
+ private static final int DEFAULT_VERBOSE_LOGGING = 0;
+
+ @Mock Context mContext;
+ @Mock WifiInjector mWifiInjector;
+ WifiServiceImpl mWifiServiceImpl;
+
+ @Mock WifiTrafficPoller mWifiTrafficPoller;
+ @Mock WifiStateMachine mWifiStateMachine;
+ @Mock HandlerThread mHandlerThread;
+ TestLooper mLooper;
+ @Mock AsyncChannel mAsyncChannel;
+ @Mock Resources mResources;
+ @Mock FrameworkFacade mFrameworkFacade;
+ @Mock WifiLockManager mLockManager;
+ @Mock WifiMulticastLockManager mWifiMulticastLockManager;
+ @Mock WifiLastResortWatchdog mWifiLastResortWatchdog;
+ @Mock WifiBackupRestore mWifiBackupRestore;
+
+ @Before public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mLooper = new TestLooper();
+
+ when(mWifiInjector.getWifiStateMachine()).thenReturn(mWifiStateMachine);
+ when(mWifiInjector.getWifiServiceHandlerThread()).thenReturn(mHandlerThread);
+ when(mHandlerThread.getLooper()).thenReturn(mLooper.getLooper());
+ when(mContext.getResources()).thenReturn(mResources);
+ when(mWifiInjector.getFrameworkFacade()).thenReturn(mFrameworkFacade);
+ when(mWifiInjector.getWifiLockManager()).thenReturn(mLockManager);
+ when(mWifiInjector.getWifiMulticastLockManager()).thenReturn(mWifiMulticastLockManager);
+ when(mWifiInjector.getWifiLastResortWatchdog()).thenReturn(mWifiLastResortWatchdog);
+ when(mWifiInjector.getWifiBackupRestore()).thenReturn(mWifiBackupRestore);
+ mWifiServiceImpl = new WifiServiceImpl(mContext, mWifiInjector, mAsyncChannel);
+ }
+
+ @Test
+ public void testRemoveNetworkUnknown() {
+ assertFalse(mWifiServiceImpl.removeNetwork(-1));
+ }
+
+}