summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2016-11-28 11:28:40 -0800
committerRebecca Silberstein <silberst@google.com>2016-12-15 16:16:38 -0800
commitda918df16e03ee19be62343313d954027d3eb3ab (patch)
tree7146fe0793f9f36bc0906c3149f7f8bc62f15a07 /tests
parent2c42f1c08ec37e0cb9d5ebbc66584dc294d4bf42 (diff)
WifiServiceImpl: allow for unit tests
Some structural cleanup that allows for WifiServiceImplTest development. Bug: 33167818 Test: runtests.sh Change-Id: Ic3ca545f210dfaa3277cc28166b2611b3c818408
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));
+ }
+
+}