diff options
author | Roshan Pius <rpius@google.com> | 2019-11-25 07:35:34 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-11-25 20:57:06 -0800 |
commit | 7cede7ab8e6aa31cd8237e40a9b66da26f6fedcf (patch) | |
tree | eb72d64081d6e8a1f5bf3e03513bdb608ecf6c17 /tests | |
parent | 5af72d01d81f092db948432d2c1e6ddd50f8af3a (diff) |
wifi-service: Convert to java_library
a) Move the resources to an APK which is linked by the wifi-service java
library.
b) Load the resource values lazily since the resources APK will not be
available when the wifi service jar is initialized.
Also, unit tests now compile the service sources directly instead of
linking wifi-service library. This is because the wifi-service library
linked is jar-jar'ed now which causes compilation failure when
attempting to compile the vanilla test sources.
Bug: 144722612
Test: Device boots up and connects to wifi networks.
Test: atest com.android.server.wifi
Change-Id: I1c20c41b9e6669fbbae0ff9d6f70e0ec30f0d073
Diffstat (limited to 'tests')
29 files changed, 113 insertions, 60 deletions
diff --git a/tests/wifitests/Android.bp b/tests/wifitests/Android.bp index 2e3b28ecf..12b6fc3ff 100644 --- a/tests/wifitests/Android.bp +++ b/tests/wifitests/Android.bp @@ -15,11 +15,15 @@ // Make test APK // ============================================================ android_test { - // TODO(rpius): Rename once all google3 config files are changed - // name: "WifiStackTests", name: "FrameworksWifiTests", - srcs: ["**/*.java"], + srcs: [ + "**/*.java", + // wifi-service sources must be included here so that the latest changes + // will be used when tests. Otherwise the tests would run against the installed + // system. + ":wifi-service-srcs", + ], // For coverage jacoco: { @@ -51,7 +55,6 @@ android_test { "com.android.server.wifi.aware.WifiAwareStateManager", "com.android.server.wifi.aware.WifiAwareStateManager.*", "com.android.server.wifi.BaseWifiDiagnostics", - "com.android.server.wifi.BootCompleteReceiver", "com.android.server.wifi.BssidBlocklistMonitor", "com.android.server.wifi.BssidBlocklistMonitor.*", "com.android.server.wifi.BubbleFunScorer", @@ -370,8 +373,6 @@ android_test { "com.android.server.wifi.WifiSettingsStore", "com.android.server.wifi.WifiShellCommand", "com.android.server.wifi.WifiShellCommand.*", - "com.android.server.wifi.WifiStackService", - "com.android.server.wifi.WifiStackService.*", "com.android.server.wifi.WifiStateTracker", "com.android.server.wifi.WifiThreadRunner", "com.android.server.wifi.WifiThreadRunner.*", @@ -392,26 +393,55 @@ android_test { java_version: "1.9", - // wifi-service and services must be included here so that the latest changes - // will be used when tests. Otherwise the tests would run against the installed - // system. - // TODO figure out if this is the correct thing to do, this seems to not be right - // since neither is declared a static java library. static_libs: [ "androidx.test.rules", "hamcrest-library", "mockito-target-extended-minus-junit4", "frameworks-base-testutils", - "services", - "wifi-service", - "truth-prebuilt", + "truth-prebuilt", + + // Libraries needed by wifi-service + "android.hardware.wifi-V1.0-java", + "android.hardware.wifi-V1.1-java", + "android.hardware.wifi-V1.2-java", + "android.hardware.wifi-V1.3-java", + "android.hardware.wifi-V1.4-java", + "android.hardware.wifi.hostapd-V1.0-java", + "android.hardware.wifi.hostapd-V1.1-java", + "android.hardware.wifi.supplicant-V1.0-java", + "android.hardware.wifi.supplicant-V1.1-java", + "android.hardware.wifi.supplicant-V1.2-java", + "android.hardware.wifi.supplicant-V1.3-java", + "android.hidl.manager-V1.2-java", + "androidx.annotation_annotation", + "bouncycastle-unbundled", + "ksoap2", + // Note: libprotobuf-java-lite uses a few core platform APIs which + // does show up as @hide API usage. But, this can be safely ignored + // since the library uses reflection to ensure that the OS does provide + // the necessary core platform APIs. + "libprotobuf-java-lite", + "libnanohttpd", + "libwificond_aidl-java", + "services.net", + "services.core", + "wifi_proto_scorecard", + "wifi_proto_metrics", ], + jarjar_rules: ":wifi-service-jarjar-rules", + libs: [ "android.test.runner", - "android.hidl.manager-V1.2-java", "android.test.base", "android.test.mock", + + // Libraries needed by wifi-service + "error_prone_annotations", + "jsr305", + "services", + // load the resources from the resources APK. + "wifi-service-resources" ], // These must be explicitly included because they are not normally accessible @@ -432,8 +462,6 @@ android_test { "libstaticjvmtiagent", ], - jarjar_rules: ":wifi-jarjar-rules", - min_sdk_version: "29", platform_apis: true, privileged: true, diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java index e681534ca..029e423f8 100644 --- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java @@ -58,7 +58,7 @@ import androidx.test.filters.SmallTest; import com.android.server.wifi.util.GeneralUtil; import com.android.server.wifi.util.WifiPermissionsUtil; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 19ac38213..7946ecbc0 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -103,7 +103,7 @@ import com.android.server.wifi.util.RssiUtilTest; import com.android.server.wifi.util.TelephonyUtil; import com.android.server.wifi.util.WifiPermissionsUtil; import com.android.server.wifi.util.WifiPermissionsWrapper; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; @@ -664,10 +664,6 @@ public class ClientModeImplTest extends WifiBaseTest { assertEquals(WifiManager.WIFI_STATE_ENABLED, mCmi.syncGetWifiState()); assertEquals("enabled", mCmi.syncGetWifiStateByName()); - // reset the expectations on mContext since we did get an expected broadcast, but we should - // not on the next transition - reset(mContext); - // now disable wifi and verify the reported wifi state mCmi.setWifiStateForApiCalls(WifiManager.WIFI_STATE_DISABLED); mCmi.setOperationalMode(ClientModeImpl.DISABLED_MODE, null); diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java index 900d3a7f3..ddce73be1 100644 --- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java @@ -33,7 +33,7 @@ import android.util.ArraySet; import androidx.test.filters.SmallTest; import com.android.dx.mockito.inline.extended.ExtendedMockito; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java index 8a5d4deae..94f5eb77c 100644 --- a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java @@ -39,7 +39,7 @@ import android.os.test.TestLooper; import androidx.test.filters.SmallTest; import com.android.server.wifi.util.NativeUtil; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java index 46b0ba067..74396a02e 100644 --- a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java @@ -37,7 +37,7 @@ import android.provider.Settings; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; @@ -86,6 +86,10 @@ public class LinkProbeManagerTest extends WifiBaseTest { mTimeMs = 1000; when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs); + // Simulate new connection to trigger check for isSupported resource flag. + mLinkProbeManager.resetOnNewConnection(); + mLinkProbeManager.resetOnScreenTurnedOn(); + ArgumentCaptor<ContentObserver> observerCaptor = ArgumentCaptor.forClass( ContentObserver.class); verify(mFrameworkFacade).registerContentObserver(eq(mContext), diff --git a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java index f6db3dd3f..ce9c596d4 100644 --- a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java @@ -34,7 +34,7 @@ import android.telephony.TelephonyManager; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; @@ -123,6 +123,8 @@ public class SarManagerTest extends WifiBaseTest { mSarMgr = new SarManager(mContext, mTelephonyManager, mLooper.getLooper(), mWifiNative); + mSarMgr.handleBootCompleted(); + if (isSarEnabled) { /* Capture the PhoneStateListener */ ArgumentCaptor<PhoneStateListener> phoneStateListenerCaptor = diff --git a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java index 3a76eda50..90420b889 100644 --- a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java @@ -33,7 +33,7 @@ import android.util.LocalLog; import com.android.server.wifi.WifiNetworkSelector.NetworkEvaluator.OnConnectableListener; import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiConfigs; import com.android.server.wifi.util.TelephonyUtil; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java index 3fefb443c..41900f3fa 100644 --- a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java @@ -35,7 +35,7 @@ import android.provider.Settings; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java index 68c0cf866..27ed5be10 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java @@ -67,7 +67,7 @@ import androidx.test.filters.SmallTest; import com.android.internal.util.WakeupMessage; import com.android.server.wifi.wificond.IApInterfaceEventCallback; import com.android.server.wifi.wificond.NativeWifiClient; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java index a9436e7e1..f7a5a4c2b 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java @@ -47,7 +47,7 @@ import android.text.TextUtils; import androidx.test.filters.SmallTest; import com.android.server.wifi.util.NativeUtil; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java index 08119e59b..35ace4eac 100644 --- a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java @@ -30,7 +30,7 @@ import android.net.wifi.ScanResult; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java index 214e80947..ad890ebb7 100644 --- a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java @@ -26,7 +26,7 @@ import android.net.wifi.WifiInfo; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java index 851289c0d..ba3fbeeff 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java @@ -40,7 +40,7 @@ import android.os.test.TestLooper; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 0e4d049de..147b2a0d8 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -54,7 +54,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.server.wifi.util.TelephonyUtil; import com.android.server.wifi.util.WifiPermissionsUtil; import com.android.server.wifi.util.WifiPermissionsWrapper; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 96e5b5d22..c1445c158 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -51,7 +51,7 @@ import android.util.LocalLog; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java index 3a2583bdb..6fb035462 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiCountryCodeTest.java @@ -33,6 +33,8 @@ import android.telephony.TelephonyManager; import androidx.test.filters.SmallTest; +import com.android.wifi.resources.R; + import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -54,6 +56,7 @@ public class WifiCountryCodeTest extends WifiBaseTest { private String mTelephonyCountryCode = "JP"; private boolean mRevertCountryCodeOnCellularLoss = true; @Mock Context mContext; + MockResources mResources = new MockResources(); @Mock TelephonyManager mTelephonyManager; @Mock Handler mHandler; @Mock WifiNative mWifiNative; @@ -76,12 +79,14 @@ public class WifiCountryCodeTest extends WifiBaseTest { } private void createWifiCountryCode() { + mResources.setBoolean(R.bool.config_wifi_revert_country_code_on_cellular_loss, + mRevertCountryCodeOnCellularLoss); + when(mContext.getResources()).thenReturn(mResources); mWifiCountryCode = new WifiCountryCode( mContext, mHandler, mWifiNative, - mDefaultCountryCode, - mRevertCountryCodeOnCellularLoss); + mDefaultCountryCode); verify(mContext, atLeastOnce()).registerReceiver( mBroadcastReceiverCaptor.capture(), any(), any(), any()); } @@ -247,12 +252,8 @@ public class WifiCountryCodeTest extends WifiBaseTest { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); - mWifiCountryCode = new WifiCountryCode( - mContext, - mHandler, - mWifiNative, - null, - false /* config_wifi_revert_country_code_on_cellular_loss */); + mRevertCountryCodeOnCellularLoss = false; + createWifiCountryCode(); mWifiCountryCode.dump(null, pw, null); String dumpCountryCodeStr = sw.toString(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java index 82b62afef..27990e738 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java @@ -41,7 +41,7 @@ import android.os.UserHandle; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Ignore; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java index fc85b4d6e..282393f1d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java @@ -31,7 +31,7 @@ import android.util.Pair; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java index 2d6bb5a3c..608c76e13 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java @@ -18,6 +18,9 @@ package com.android.server.wifi; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import android.content.Context; import androidx.test.filters.SmallTest; @@ -41,7 +44,7 @@ public class WifiLinkLayerStatsTest extends WifiBaseTest { */ @Before public void setUp() throws Exception { - mWifiInfo = new ExtendedWifiInfo(); + mWifiInfo = new ExtendedWifiInfo(mock(Context.class)); mWifiLinkLayerStats = new WifiLinkLayerStats(); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index b55735f8e..4ee6c79a4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -103,6 +103,7 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStatsEnt import com.android.server.wifi.proto.nano.WifiMetricsProto.WpsMetrics; import com.android.server.wifi.rtt.RttMetrics; import com.android.server.wifi.util.ExternalCallbackTracker; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; @@ -137,6 +138,7 @@ public class WifiMetricsTest extends WifiBaseTest { private static final int TEST_WIFI_USABILITY_STATS_LISTENER_IDENTIFIER = 2; private static final int TEST_NETWORK_ID = 42; @Mock Context mContext; + MockResources mResources; @Mock FrameworkFacade mFacade; @Mock Clock mClock; @Mock ScoringParams mScoringParams; @@ -157,6 +159,8 @@ public class WifiMetricsTest extends WifiBaseTest { mDecodedProto = null; when(mClock.getElapsedSinceBootMillis()).thenReturn((long) 0); mTestLooper = new TestLooper(); + mResources = new MockResources(); + when(mContext.getResources()).thenReturn(mResources); mWifiMetrics = new WifiMetrics(mContext, mFacade, mClock, mTestLooper.getLooper(), new WifiAwareMetrics(mClock), new RttMetrics(mClock), mWifiPowerMetrics, mWifiP2pMetrics, mDppMetrics); @@ -863,7 +867,8 @@ public class WifiMetricsTest extends WifiBaseTest { } mWifiMetrics.setWatchdogSuccessTimeDurationMs(NUM_WATCHDOG_SUCCESS_DURATION_MS); - mWifiMetrics.setIsMacRandomizationOn(IS_MAC_RANDOMIZATION_ON); + mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported, + IS_MAC_RANDOMIZATION_ON); addWifiPowerMetrics(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index 77d4cdeb7..d1860c947 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -41,7 +41,7 @@ import androidx.test.filters.SmallTest; import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiConfigs; import com.android.server.wifi.proto.nano.WifiMetricsProto; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index 6dc87aaf7..b50cf27ea 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -64,7 +64,7 @@ import com.android.server.wifi.WifiNetworkSuggestionsManager.PerAppInfo; import com.android.server.wifi.hotspot2.PasspointManager; import com.android.server.wifi.util.TelephonyUtil; import com.android.server.wifi.util.WifiPermissionsUtil; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java index 135a71ee2..128bdc15d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java @@ -21,6 +21,7 @@ import static com.android.server.wifi.util.NativeUtil.hexStringFromByteArray; import static org.junit.Assert.*; import static org.mockito.Mockito.*; +import android.content.Context; import android.net.MacAddress; import android.net.wifi.WifiInfo; import android.net.wifi.WifiSsid; @@ -51,7 +52,7 @@ import java.util.Arrays; public class WifiScoreCardTest extends WifiBaseTest { static final WifiSsid TEST_SSID_1 = WifiSsid.createFromAsciiEncoded("Joe's Place"); - static final WifiSsid TEST_SSID_2 = WifiSsid.createFromAsciiEncoded("Poe's Raven"); + static final WifiSsid TEST_SSID_2 = WifiSsid.createFromAsciiEncoded("Poe's Ravn"); static final MacAddress TEST_BSSID_1 = MacAddress.fromString("aa:bb:cc:dd:ee:ff"); static final MacAddress TEST_BSSID_2 = MacAddress.fromString("1:2:3:4:5:6"); @@ -96,7 +97,7 @@ public class WifiScoreCardTest extends WifiBaseTest { mBlobListeners.clear(); mBlobs.clear(); mMilliSecondsSinceBoot = 0; - mWifiInfo = new ExtendedWifiInfo(); + mWifiInfo = new ExtendedWifiInfo(mock(Context.class)); mWifiInfo.setSSID(TEST_SSID_1); mWifiInfo.setBSSID(TEST_BSSID_1.toString()); mWifiInfo.setNetworkId(TEST_NETWORK_CONFIG_ID); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java index c85b9f49c..73af4ae5e 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java @@ -38,7 +38,7 @@ import android.net.wifi.WifiInfo; import androidx.test.filters.SmallTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 4bf695d77..6282abed1 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -143,6 +143,7 @@ import com.android.server.wifi.hotspot2.PasspointProvisioningTestUtil; import com.android.server.wifi.util.WifiAsyncChannel; import com.android.server.wifi.util.WifiPermissionsUtil; import com.android.server.wifi.util.WifiPermissionsWrapper; +import com.android.wifi.resources.R; import org.junit.After; import org.junit.Before; @@ -1668,7 +1669,7 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testStartLocalOnlyHotspotAt5Ghz() { when(mResources.getBoolean( - eq(com.android.wifi.R.bool.config_wifi_local_only_hotspot_5ghz))) + eq(R.bool.config_wifi_local_only_hotspot_5ghz))) .thenReturn(true); when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)).thenReturn(true); when(mClientModeImpl.syncGetSupportedFeatures(any(AsyncChannel.class))) @@ -3030,16 +3031,22 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testHandleDelayedScanAfterIdleMode() throws Exception { when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false); + when(mWifiInjector.getPasspointProvisionerHandlerThread()) + .thenReturn(mock(HandlerThread.class)); mWifiServiceImpl.checkAndStartWifi(); + mWifiServiceImpl.handleBootCompleted(); verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(), (IntentFilter) argThat(new IdleModeIntentMatcher())); // Tell the wifi service that the device became idle. when(mPowerManager.isDeviceIdleMode()).thenReturn(true); TestUtil.sendIdleModeChanged(mBroadcastReceiverCaptor.getValue(), mContext); + mLooper.dispatchAll(); // Send a scan request while the device is idle. + mLooper.startAutoDispatch(); assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME, TEST_FEATURE_ID)); + mLooper.stopAutoDispatchAndIgnoreExceptions(); // No scans must be made yet as the device is idle. verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME); @@ -3184,7 +3191,10 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testUserRemovedBroadcastHandling() { + when(mWifiInjector.getPasspointProvisionerHandlerThread()) + .thenReturn(mock(HandlerThread.class)); mWifiServiceImpl.checkAndStartWifi(); + mWifiServiceImpl.handleBootCompleted(); verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(), argThat((IntentFilter filter) -> filter.hasAction(Intent.ACTION_USER_REMOVED))); @@ -3201,7 +3211,10 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testUserRemovedBroadcastHandlingWithWrongIntentAction() { + when(mWifiInjector.getPasspointProvisionerHandlerThread()) + .thenReturn(mock(HandlerThread.class)); mWifiServiceImpl.checkAndStartWifi(); + mWifiServiceImpl.handleBootCompleted(); verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(), argThat((IntentFilter filter) -> filter.hasAction(Intent.ACTION_USER_REMOVED))); @@ -3222,7 +3235,7 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testNeeds5GHzToAnyApBandConversionReturnedTrue() { when(mResources.getBoolean( - eq(com.android.wifi.R.bool.config_wifi_convert_apband_5ghz_to_any))) + eq(R.bool.config_wifi_convert_apband_5ghz_to_any))) .thenReturn(true); assertTrue(mWifiServiceImpl.needs5GHzToAnyApBandConversion()); @@ -3237,7 +3250,7 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testNeeds5GHzToAnyApBandConversionReturnedFalse() { when(mResources.getBoolean( - eq(com.android.wifi.R.bool.config_wifi_convert_apband_5ghz_to_any))) + eq(R.bool.config_wifi_convert_apband_5ghz_to_any))) .thenReturn(false); assertFalse(mWifiServiceImpl.needs5GHzToAnyApBandConversion()); @@ -4123,7 +4136,7 @@ public class WifiServiceImplTest extends WifiBaseTest { private void setupMaxApInterfaces(int val) { when(mResources.getInteger( - eq(com.android.wifi.R.integer.config_wifi_max_ap_interfaces))) + eq(R.integer.config_wifi_max_ap_interfaces))) .thenReturn(val); } diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java index 9bd99953d..57c5d8aee 100644 --- a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java @@ -83,7 +83,7 @@ import com.android.server.wifi.WifiInjector; import com.android.server.wifi.proto.nano.WifiMetricsProto.P2pConnectionEvent; import com.android.server.wifi.util.WifiPermissionsUtil; import com.android.server.wifi.util.WifiPermissionsWrapper; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java index ad66e55ab..e15fa2bb1 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java @@ -38,7 +38,7 @@ import com.android.server.wifi.WifiBaseTest; import com.android.server.wifi.WifiMonitor; import com.android.server.wifi.WifiNative; import com.android.server.wifi.scanner.ChannelHelper.ChannelCollection; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java index cebf83766..d87d94c56 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/RssiUtilTest.java @@ -34,7 +34,7 @@ import android.os.Looper; import androidx.test.filters.SmallTest; import com.android.server.wifi.WifiBaseTest; -import com.android.wifi.R; +import com.android.wifi.resources.R; import org.junit.Before; import org.junit.Test; |