diff options
author | Mitchell Wills <mwills@google.com> | 2016-04-12 16:45:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-04-12 16:45:34 +0000 |
commit | b0af0c308d20860dc90727eff1c76e0445d20c96 (patch) | |
tree | 455029cd141b033679d3bb9a6b212a05602c3a2d /tests | |
parent | 7f8d45b1a56d7c6f2702aabb84e0eba597b525b0 (diff) | |
parent | a8367288377cbaed6371256ca837b7aa22280706 (diff) |
Merge "Move WifiScanner related code to scanner package" into nyc-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/android/net/wifi/WifiScannerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/WifiScannerTest.java) | 9 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/MockResources.java | 19 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java | 9 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java (renamed from tests/wifitests/src/com/android/server/wifi/BaseWifiScannerImplTest.java) | 24 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/HalWifiScannerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/HalWifiScannerTest.java) | 6 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/SupplicantPnoScannerTest.java) | 13 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/SupplicantWifiScannerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/SupplicantWifiScannerTest.java) | 11 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java (renamed from tests/wifitests/src/com/android/server/wifi/WifiScanningServiceTest.java) | 20 |
8 files changed, 70 insertions, 41 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScannerTest.java b/tests/wifitests/src/android/net/wifi/WifiScannerTest.java index 34140b521..b68d52721 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScannerTest.java +++ b/tests/wifitests/src/android/net/wifi/WifiScannerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi; +package android.net.wifi; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.anyString; @@ -26,14 +26,15 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; -import android.net.wifi.IWifiScanner; -import android.net.wifi.WifiScanner; import android.net.wifi.WifiScanner.BssidInfo; import android.net.wifi.WifiScanner.BssidListener; import android.os.Handler; import android.os.Message; import android.test.suitebuilder.annotation.SmallTest; +import com.android.server.wifi.BidirectionalAsyncChannelServer; +import com.android.server.wifi.MockLooper; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -42,7 +43,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** - * Unit tests for {@link WifiScanner}. + * Unit tests for {@link android.net.wifi.WifiScanner}. */ @SmallTest public class WifiScannerTest { diff --git a/tests/wifitests/src/com/android/server/wifi/MockResources.java b/tests/wifitests/src/com/android/server/wifi/MockResources.java index 2ce7300f4..ab40c6f8d 100644 --- a/tests/wifitests/src/com/android/server/wifi/MockResources.java +++ b/tests/wifitests/src/com/android/server/wifi/MockResources.java @@ -1,15 +1,30 @@ +/* + * 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 java.util.HashMap; -class MockResources extends android.test.mock.MockResources { +public class MockResources extends android.test.mock.MockResources { private HashMap<Integer, Boolean> mBooleanValues; private HashMap<Integer, Integer> mIntegerValues; private HashMap<Integer, String> mStringValues; - MockResources() { + public MockResources() { mBooleanValues = new HashMap<Integer, Boolean>(); mIntegerValues = new HashMap<Integer, Integer>(); mStringValues = new HashMap<Integer, String>(); diff --git a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java index 9b27c48f7..8228118d8 100644 --- a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java @@ -11,7 +11,7 @@ * 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 + * limitations under the License. */ package com.android.server.wifi; @@ -29,7 +29,6 @@ import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; -import java.lang.reflect.Field; import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -39,12 +38,6 @@ import java.util.Set; */ public class ScanTestUtil { - public static void installWlanWifiNative(WifiNative wifiNative) throws Exception { - Field field = WifiNative.class.getDeclaredField("wlanNativeInterface"); - field.setAccessible(true); - field.set(null, wifiNative); - } - public static void setupMockChannels(WifiNative wifiNative, int[] channels24, int[] channels5, int[] channelsDfs) throws Exception { when(wifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ)) diff --git a/tests/wifitests/src/com/android/server/wifi/BaseWifiScannerImplTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java index bfb4739be..04684d932 100644 --- a/tests/wifitests/src/com/android/server/wifi/BaseWifiScannerImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java @@ -11,23 +11,17 @@ * 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 + * limitations under the License. */ -package com.android.server.wifi; +package com.android.server.wifi.scanner; import static com.android.server.wifi.ScanTestUtil.NativeScanSettingsBuilder; import static com.android.server.wifi.ScanTestUtil.assertScanDataEquals; import static com.android.server.wifi.ScanTestUtil.createFreqSet; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; import android.content.Context; import android.net.wifi.ScanResult; @@ -36,6 +30,14 @@ import android.net.wifi.WifiScanner.ScanData; import android.net.wifi.WifiSsid; import android.os.SystemClock; +import com.android.server.wifi.MockAlarmManager; +import com.android.server.wifi.MockLooper; +import com.android.server.wifi.MockResources; +import com.android.server.wifi.MockWifiMonitor; +import com.android.server.wifi.ScanDetail; +import com.android.server.wifi.ScanResults; +import com.android.server.wifi.WifiMonitor; +import com.android.server.wifi.WifiNative; import com.android.server.wifi.scanner.ChannelHelper.ChannelCollection; import org.junit.Before; @@ -52,7 +54,7 @@ import java.util.Set; /** * Base unit tests that should pass for all implementations of - * {@link com.android.server.wifi.WifiScannerImpl}. + * {@link com.android.server.wifi.scanner.WifiScannerImpl}. */ public abstract class BaseWifiScannerImplTest { @Mock Context mContext; diff --git a/tests/wifitests/src/com/android/server/wifi/HalWifiScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/HalWifiScannerTest.java index 338599d16..7da2bad90 100644 --- a/tests/wifitests/src/com/android/server/wifi/HalWifiScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/HalWifiScannerTest.java @@ -11,10 +11,10 @@ * 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 + * limitations under the License. */ -package com.android.server.wifi; +package com.android.server.wifi.scanner; import static com.android.server.wifi.ScanTestUtil.setupMockChannels; @@ -23,7 +23,7 @@ import android.test.suitebuilder.annotation.SmallTest; import org.junit.Before; /** - * Unit tests for {@link com.android.server.wifi.HalWifiScannerImpl}. + * Unit tests for {@link com.android.server.wifi.scanner.HalWifiScannerImpl}. */ @SmallTest public class HalWifiScannerTest extends BaseWifiScannerImplTest { diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantPnoScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java index 8586b1c93..4ef8a3f8d 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantPnoScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantPnoScannerTest.java @@ -11,10 +11,10 @@ * 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 + * limitations under the License. */ -package com.android.server.wifi; +package com.android.server.wifi.scanner; import static com.android.server.wifi.ScanTestUtil.NativeScanSettingsBuilder; import static com.android.server.wifi.ScanTestUtil.assertScanDataEquals; @@ -28,6 +28,13 @@ import android.net.wifi.WifiScanner; import android.test.suitebuilder.annotation.SmallTest; import com.android.internal.R; +import com.android.server.wifi.MockAlarmManager; +import com.android.server.wifi.MockLooper; +import com.android.server.wifi.MockResources; +import com.android.server.wifi.MockWifiMonitor; +import com.android.server.wifi.ScanResults; +import com.android.server.wifi.WifiMonitor; +import com.android.server.wifi.WifiNative; import com.android.server.wifi.scanner.ChannelHelper.ChannelCollection; import org.junit.Before; @@ -41,7 +48,7 @@ import java.util.Set; /** - * Unit tests for {@link com.android.server.wifi.SupplicantWifiScannerImpl.setPnoList}. + * Unit tests for {@link com.android.server.wifi.scanner.SupplicantWifiScannerImpl.setPnoList}. */ @SmallTest public class SupplicantPnoScannerTest { diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantWifiScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantWifiScannerTest.java index 6a39233eb..b107f8124 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantWifiScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/SupplicantWifiScannerTest.java @@ -11,10 +11,10 @@ * 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 + * limitations under the License. */ -package com.android.server.wifi; +package com.android.server.wifi.scanner; import static com.android.server.wifi.ScanTestUtil.NativeScanSettingsBuilder; import static com.android.server.wifi.ScanTestUtil.assertScanDatasEquals; @@ -28,6 +28,11 @@ import android.net.wifi.WifiScanner; import android.net.wifi.WifiSsid; import android.test.suitebuilder.annotation.SmallTest; +import com.android.server.wifi.ScanDetail; +import com.android.server.wifi.ScanResults; +import com.android.server.wifi.WifiMonitor; +import com.android.server.wifi.WifiNative; + import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; @@ -37,7 +42,7 @@ import java.util.HashSet; import java.util.Set; /** - * Unit tests for {@link com.android.server.wifi.SupplicantWifiScannerImpl}. + * Unit tests for {@link com.android.server.wifi.scanner.SupplicantWifiScannerImpl}. */ @SmallTest public class SupplicantWifiScannerTest extends BaseWifiScannerImplTest { diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java index f0b2f60b9..4fe7d53da 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScanningServiceTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java @@ -11,10 +11,10 @@ * 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 + * limitations under the License. */ -package com.android.server.wifi; +package com.android.server.wifi.scanner; import static com.android.server.wifi.ScanTestUtil.*; @@ -37,10 +37,16 @@ import android.util.Pair; import com.android.internal.app.IBatteryStats; import com.android.internal.util.Protocol; +import com.android.server.wifi.BidirectionalAsyncChannel; +import com.android.server.wifi.MockAlarmManager; import com.android.server.wifi.MockAnswerUtil.AnswerWithArguments; -import com.android.server.wifi.scanner.BackgroundScanScheduler; -import com.android.server.wifi.scanner.ChannelHelper; -import com.android.server.wifi.scanner.PresetKnownBandsChannelHelper; +import com.android.server.wifi.MockLooper; +import com.android.server.wifi.ScanResults; +import com.android.server.wifi.TestUtil; +import com.android.server.wifi.WifiInjector; +import com.android.server.wifi.WifiMetrics; +import com.android.server.wifi.WifiMetricsProto; +import com.android.server.wifi.WifiNative; import org.junit.After; import org.junit.Before; @@ -56,7 +62,7 @@ import java.util.Arrays; import java.util.Collections; /** - * Unit tests for {@link com.android.server.wifi.WifiScanningServiceImpl}. + * Unit tests for {@link com.android.server.wifi.scanner.WifiScanningServiceImpl}. */ @SmallTest public class WifiScanningServiceTest { @@ -826,7 +832,7 @@ public class WifiScanningServiceTest { Message networkFoundMessage) { assertEquals("what", WifiScanner.CMD_PNO_NETWORK_FOUND, networkFoundMessage.what); assertEquals("listenerId", listenerId, networkFoundMessage.arg2); - ScanTestUtil.assertScanResultsEquals(expected, + assertScanResultsEquals(expected, ((WifiScanner.ParcelableScanResults) networkFoundMessage.obj).getResults()); } |