diff options
author | Stephen Chen <stewchen@google.com> | 2016-12-05 22:38:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-12-05 22:38:11 +0000 |
commit | cf6d5cb0182cd9ed7f5c5955eb3b7e931ba761d8 (patch) | |
tree | 236fed7260e545091022db84064bac4b9f60e1e6 /tests | |
parent | 6cc31d8ca94e61193a27b395282defeed33cf7be (diff) | |
parent | f09b6de086d5a00417613886aa43402285d2a8ab (diff) |
Create an empty implementation of WifiWakeupController.
am: f09b6de086
Change-Id: I6ba4b4dfd4cdd719250c4add323c467acf73fec3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiWakeupControllerTest.java | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiWakeupControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiWakeupControllerTest.java new file mode 100644 index 000000000..c714d8225 --- /dev/null +++ b/tests/wifitests/src/com/android/server/wifi/WifiWakeupControllerTest.java @@ -0,0 +1,86 @@ +/* + * 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.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import android.app.NotificationManager; +import android.content.ContentResolver; +import android.content.Context; +import android.net.wifi.WifiScanner; +import android.os.test.TestLooper; +import android.provider.Settings; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.io.FileDescriptor; +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * Unit tests for {@link com.android.server.wifi.WifiWakeupController}. + */ +public class WifiWakeupControllerTest { + public static final String TAG = "WifiScanningServiceTest"; + + @Mock private Context mContext; + @Mock private WifiStateMachine mWifiStateMachine; + @Mock private FrameworkFacade mFrameworkFacade; + @Mock private NotificationManager mNotificationManager; + @Mock private WifiScanner mWifiScanner; + @Mock private ContentResolver mContentResolver; + private WifiWakeupController mWifiWakeupController; + + + /** Initialize objects before each test run. */ + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + when(mContext.getContentResolver()).thenReturn(mContentResolver); + when(mFrameworkFacade.getIntegerSetting(mContext, + Settings.Global.WIFI_WAKEUP_ENABLED, 0)).thenReturn(1); + TestLooper testLooper = new TestLooper(); + mWifiWakeupController = new WifiWakeupController( + mContext, testLooper.getLooper(), mFrameworkFacade); + } + + /** Test WifiWakeupEnabledSettingObserver enables feature correctly. */ + @Test + public void testEnableWifiWakeup() { + assertTrue(mWifiWakeupController.mWifiWakeupEnabled); + + when(mFrameworkFacade.getIntegerSetting(mContext, + Settings.Global.WIFI_WAKEUP_ENABLED, 0)).thenReturn(0); + mWifiWakeupController.mContentObserver.onChange(true); + assertFalse(mWifiWakeupController.mWifiWakeupEnabled); + } + + /** Test dump() does not crash. */ + @Test + public void testDump() { + StringWriter stringWriter = new StringWriter(); + mWifiWakeupController.dump( + new FileDescriptor(), new PrintWriter(stringWriter), new String[0]); + } + +} |