Convert when() to doReturn()
Bug: 243340634
Test: NetworkStackTests
Change-Id: I75b1ccbe3bb0439637c7d6d3b609678112e568da
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
index 6cc4bfb..7077faf 100644
--- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
+++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
@@ -92,7 +92,6 @@
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import static java.lang.System.currentTimeMillis;
import static java.util.Collections.singletonList;
@@ -475,46 +474,46 @@
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- when(mDependencies.getPrivateDnsBypassNetwork(any())).thenReturn(mCleartextDnsNetwork);
- when(mDependencies.getDnsResolver()).thenReturn(mDnsResolver);
- when(mDependencies.getRandom()).thenReturn(mRandom);
- when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_MODE), anyInt()))
- .thenReturn(Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT);
- when(mDependencies.getDeviceConfigPropertyInt(any(), eq(CAPTIVE_PORTAL_USE_HTTPS),
- anyInt())).thenReturn(1);
- when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTP_URL), any()))
- .thenReturn(TEST_HTTP_URL);
- when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTPS_URL), any()))
- .thenReturn(TEST_HTTPS_URL);
+ doReturn(mCleartextDnsNetwork).when(mDependencies).getPrivateDnsBypassNetwork(any());
+ doReturn(mDnsResolver).when(mDependencies).getDnsResolver();
+ doReturn(mRandom).when(mDependencies).getRandom();
+ doReturn(Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT).when(mDependencies)
+ .getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_MODE), anyInt());
+ doReturn(1).when(mDependencies)
+ .getDeviceConfigPropertyInt(any(), eq(CAPTIVE_PORTAL_USE_HTTPS), anyInt());
+ doReturn(TEST_HTTP_URL).when(mDependencies)
+ .getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTP_URL), any());
+ doReturn(TEST_HTTPS_URL).when(mDependencies)
+ .getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTPS_URL), any());
doReturn(mCleartextDnsNetwork).when(mNetwork).getPrivateDnsBypassingCopy();
- when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mCm);
- when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephony);
- when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifi);
- when(mContext.getResources()).thenReturn(mResources);
+ doReturn(mCm).when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
+ doReturn(mTelephony).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
+ doReturn(mWifi).when(mContext).getSystemService(Context.WIFI_SERVICE);
+ doReturn(mResources).when(mContext).getResources();
- when(mServiceManager.getNotifier()).thenReturn(mNotifier);
+ doReturn(mNotifier).when(mServiceManager).getNotifier();
- when(mTelephony.getDataNetworkType()).thenReturn(TelephonyManager.NETWORK_TYPE_LTE);
- when(mTelephony.getNetworkOperator()).thenReturn(TEST_MCCMNC);
- when(mTelephony.getSimOperator()).thenReturn(TEST_MCCMNC);
+ doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephony).getDataNetworkType();
+ doReturn(TEST_MCCMNC).when(mTelephony).getNetworkOperator();
+ doReturn(TEST_MCCMNC).when(mTelephony).getSimOperator();
- when(mResources.getString(anyInt())).thenReturn("");
- when(mResources.getStringArray(anyInt())).thenReturn(new String[0]);
+ doReturn("").when(mResources).getString(anyInt());
+ doReturn(new String[0]).when(mResources).getStringArray(anyInt());
doReturn(mConfiguration).when(mResources).getConfiguration();
- when(mMccContext.getResources()).thenReturn(mMccResource);
+ doReturn(mMccResource).when(mMccContext).getResources();
setFallbackUrl(TEST_FALLBACK_URL);
setOtherFallbackUrls(TEST_OTHER_FALLBACK_URL);
setFallbackSpecs(null); // Test with no fallback spec by default
- when(mRandom.nextInt()).thenReturn(0);
+ doReturn(0).when(mRandom).nextInt();
- when(mTstDependencies.getNetd()).thenReturn(mNetd);
+ doReturn(mNetd).when(mTstDependencies).getNetd();
// DNS probe timeout should not be defined more than half of HANDLER_TIMEOUT_MS. Otherwise,
// it will fail the test because of timeout expired for querying AAAA and A sequentially.
- when(mResources.getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout)))
- .thenReturn(200);
+ doReturn(200).when(mResources)
+ .getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout));
doAnswer((invocation) -> {
URL url = invocation.getArgument(0);
@@ -547,8 +546,8 @@
return null;
}
}).when(mCleartextDnsNetwork).openConnection(any());
- when(mHttpConnection.getRequestProperties()).thenReturn(new ArrayMap<>());
- when(mHttpsConnection.getRequestProperties()).thenReturn(new ArrayMap<>());
+ doReturn(new ArrayMap<>()).when(mHttpConnection).getRequestProperties();
+ doReturn(new ArrayMap<>()).when(mHttpsConnection).getRequestProperties();
mFakeDns = new FakeDns();
mFakeDns.startMocking();
@@ -560,15 +559,14 @@
mFakeDns.setAnswer(PRIVATE_DNS_PROBE_HOST_SUFFIX, new String[]{"192.0.2.2"}, TYPE_A);
mFakeDns.setAnswer(PRIVATE_DNS_PROBE_HOST_SUFFIX, new String[]{"2001:db8::1"}, TYPE_AAAA);
- when(mContext.registerReceiver(any(BroadcastReceiver.class), any())).then((invocation) -> {
+ doAnswer((invocation) -> {
mRegisteredReceivers.add(invocation.getArgument(0));
return new Intent();
- });
- when(mContext.registerReceiver(any(BroadcastReceiver.class), any(), anyInt())).then(
- (invocation) -> {
- mRegisteredReceivers.add(invocation.getArgument(0));
- return new Intent();
- });
+ }).when(mContext).registerReceiver(any(BroadcastReceiver.class), any());
+ doAnswer((invocation) -> {
+ mRegisteredReceivers.add(invocation.getArgument(0));
+ return new Intent();
+ }).when(mContext).registerReceiver(any(BroadcastReceiver.class), any(), anyInt());
doAnswer((invocation) -> {
mRegisteredReceivers.remove(invocation.getArgument(0));
@@ -677,7 +675,7 @@
setNetworkCapabilities(nm, nc);
HandlerUtils.waitForIdle(nm.getHandler(), HANDLER_TIMEOUT_MS);
mCreatedNetworkMonitors.add(nm);
- when(mTstDependencies.isTcpInfoParsingSupported()).thenReturn(false);
+ doReturn(false).when(mTstDependencies).isTcpInfoParsingSupported();
return nm;
}
@@ -890,8 +888,8 @@
doReturn(TEST_HTTP_URL).when(mResources).getString(R.string.config_captive_portal_http_url);
doReturn(TEST_HTTP_OTHER_URL2).when(mResources).getString(
R.string.default_captive_portal_http_url);
- when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTP_URL), any()))
- .thenReturn(TEST_HTTP_OTHER_URL1);
+ doReturn(TEST_HTTP_OTHER_URL1).when(mDependencies)
+ .getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTP_URL), any());
final WrappedNetworkMonitor wnm = makeCellNotMeteredNetworkMonitor();
assertEquals(TEST_HTTP_URL, wnm.getCaptivePortalServerHttpUrl(mContext));
// If config_captive_portal_http_url is unset and the global setting is set, the global
@@ -901,8 +899,8 @@
// If both config_captive_portal_http_url and global setting are unset,
// default_captive_portal_http_url is used. But the global setting will only be read in the
// constructor.
- when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTP_URL), any()))
- .thenReturn(null);
+ doReturn(null).when(mDependencies)
+ .getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTP_URL), any());
assertEquals(TEST_HTTP_OTHER_URL1, wnm.getCaptivePortalServerHttpUrl(mContext));
// default_captive_portal_http_url is used when the configuration is applied in new NM.
final WrappedNetworkMonitor wnm2 = makeCellNotMeteredNetworkMonitor();
@@ -1050,8 +1048,8 @@
// Clear setting provider value. Verify it to get configuration from resource instead.
setFallbackUrl(null);
// Verify that getting resource with exception.
- when(mResources.getStringArray(R.array.config_captive_portal_fallback_urls))
- .thenThrow(Resources.NotFoundException.class);
+ doThrow(Resources.NotFoundException.class).when(mResources)
+ .getStringArray(R.array.config_captive_portal_fallback_urls);
urls = wnm.makeCaptivePortalFallbackUrls(mContext);
assertEquals(urls.length, 0);
@@ -1138,17 +1136,16 @@
DEFAULT_CAPTIVE_PORTAL_DNS_PROBE_TIMEOUT));
// Set device config. Expect to get device config.
- when(mDependencies.getDeviceConfigPropertyInt(any(),
- eq(NetworkMonitor.CONFIG_CAPTIVE_PORTAL_DNS_PROBE_TIMEOUT), anyInt()))
- .thenReturn(1234);
+ doReturn(1234).when(mDependencies).getDeviceConfigPropertyInt(any(),
+ eq(NetworkMonitor.CONFIG_CAPTIVE_PORTAL_DNS_PROBE_TIMEOUT), anyInt());
assertEquals(1234, wnm.getIntSetting(mContext,
R.integer.config_captive_portal_dns_probe_timeout,
NetworkMonitor.CONFIG_CAPTIVE_PORTAL_DNS_PROBE_TIMEOUT,
DEFAULT_CAPTIVE_PORTAL_DNS_PROBE_TIMEOUT));
// Set config resource. Expect to get config resource.
- when(mResources.getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout)))
- .thenReturn(5678);
+ doReturn(5678).when(mResources)
+ .getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout));
assertEquals(5678, wnm.getIntSetting(mContext,
R.integer.config_captive_portal_dns_probe_timeout,
NetworkMonitor.CONFIG_CAPTIVE_PORTAL_DNS_PROBE_TIMEOUT,
@@ -1202,16 +1199,16 @@
@Test
public void testIsCaptivePortal_PrivateIpNotPortal_Enabled_IPv4() throws Exception {
- when(mDependencies.isFeatureEnabled(any(), eq(DNS_PROBE_PRIVATE_IP_NO_INTERNET_VERSION)))
- .thenReturn(true);
+ doReturn(true).when(mDependencies)
+ .isFeatureEnabled(any(), eq(DNS_PROBE_PRIVATE_IP_NO_INTERNET_VERSION));
setupPrivateIpResponse("192.168.1.1");
runFailedNetworkTest();
}
@Test
public void testIsCaptivePortal_PrivateIpNotPortal_Enabled_IPv6() throws Exception {
- when(mDependencies.isFeatureEnabled(any(), eq(DNS_PROBE_PRIVATE_IP_NO_INTERNET_VERSION)))
- .thenReturn(true);
+ doReturn(true).when(mDependencies)
+ .isFeatureEnabled(any(), eq(DNS_PROBE_PRIVATE_IP_NO_INTERNET_VERSION));
setupPrivateIpResponse("fec0:1234::1");
runFailedNetworkTest();
}
@@ -1268,7 +1265,7 @@
setPortal302(mOtherFallbackConnection);
// TEST_OTHER_FALLBACK_URL is third
- when(mRandom.nextInt()).thenReturn(2);
+ doReturn(2).when(mRandom).nextInt();
// First check always uses the first fallback URL: inconclusive
final NetworkMonitor monitor = runFailedNetworkTest();
@@ -1613,7 +1610,7 @@
setStatus(mHttpConnection, 500);
// Use the 2nd fallback spec
- when(mRandom.nextInt()).thenReturn(1);
+ doReturn(1).when(mRandom).nextInt();
}
@Test
@@ -1819,9 +1816,9 @@
public void testIsDataStall_SkipEvaluateOnValidationNotRequiredNetwork() {
// Make DNS and TCP stall condition satisfied.
setDataStallEvaluationType(DATA_STALL_EVALUATION_TYPE_DNS | DATA_STALL_EVALUATION_TYPE_TCP);
- when(mTstDependencies.isTcpInfoParsingSupported()).thenReturn(true);
- when(mTst.getLatestReceivedCount()).thenReturn(0);
- when(mTst.isDataStallSuspected()).thenReturn(true);
+ doReturn(true).when(mTstDependencies).isTcpInfoParsingSupported();
+ doReturn(0).when(mTst).getLatestReceivedCount();
+ doReturn(true).when(mTst).isDataStallSuspected();
final WrappedNetworkMonitor nm = makeMonitor(CELL_NO_INTERNET_CAPABILITIES);
nm.setLastProbeTime(SystemClock.elapsedRealtime() - 1000);
makeDnsTimeoutEvent(nm, DEFAULT_DNS_TIMEOUT_THRESHOLD);
@@ -1854,21 +1851,21 @@
@Test
public void testIsDataStall_EvaluationTcp() throws Exception {
- when(mTstDependencies.isTcpInfoParsingSupported()).thenReturn(true);
+ doReturn(true).when(mTstDependencies).isTcpInfoParsingSupported();
// Evaluate TCP only. Expect ignoring DNS signal.
setDataStallEvaluationType(DATA_STALL_EVALUATION_TYPE_TCP);
WrappedNetworkMonitor wrappedMonitor = makeMonitor(CELL_METERED_CAPABILITIES);
assertFalse(wrappedMonitor.isDataStall());
// Packet received.
- when(mTst.getLatestReceivedCount()).thenReturn(5);
+ doReturn(5).when(mTst).getLatestReceivedCount();
// Trigger a tcp event immediately.
setTcpPollingInterval(0);
wrappedMonitor.sendTcpPollingEvent();
HandlerUtils.waitForIdle(wrappedMonitor.getHandler(), HANDLER_TIMEOUT_MS);
assertFalse(wrappedMonitor.isDataStall());
- when(mTst.getLatestReceivedCount()).thenReturn(0);
- when(mTst.isDataStallSuspected()).thenReturn(true);
+ doReturn(0).when(mTst).getLatestReceivedCount();
+ doReturn(true).when(mTst).isDataStallSuspected();
// Trigger a tcp event immediately.
setTcpPollingInterval(0);
wrappedMonitor.sendTcpPollingEvent();
@@ -1888,7 +1885,7 @@
verify(mCallbacks).notifyDataStallSuspected(
matchDnsAndTcpDataStallParcelable(DEFAULT_DNS_TIMEOUT_THRESHOLD));
- when(mTst.getLatestReceivedCount()).thenReturn(5);
+ doReturn(5).when(mTst).getLatestReceivedCount();
// Trigger a tcp event immediately.
setTcpPollingInterval(0);
nm.sendTcpPollingEvent();
@@ -2010,7 +2007,7 @@
public void setupAndLaunchCaptivePortalApp(final NetworkMonitor nm) throws Exception {
setSslException(mHttpsConnection);
setPortal302(mHttpConnection);
- when(mHttpConnection.getHeaderField(eq("location"))).thenReturn(TEST_LOGIN_URL);
+ doReturn(TEST_LOGIN_URL).when(mHttpConnection).getHeaderField(eq("location"));
notifyNetworkConnected(nm, CELL_METERED_CAPABILITIES);
verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1))
@@ -2291,12 +2288,12 @@
}
private void setupTcpDataStall() {
- when(mTstDependencies.isTcpInfoParsingSupported()).thenReturn(true);
- when(mTst.getLatestReceivedCount()).thenReturn(0);
- when(mTst.getLatestPacketFailPercentage()).thenReturn(TEST_TCP_FAIL_RATE);
- when(mTst.getSentSinceLastRecv()).thenReturn(TEST_TCP_PACKET_COUNT);
- when(mTst.isDataStallSuspected()).thenReturn(true);
- when(mTst.pollSocketsInfo()).thenReturn(true);
+ doReturn(true).when(mTstDependencies).isTcpInfoParsingSupported();
+ doReturn(0).when(mTst).getLatestReceivedCount();
+ doReturn(TEST_TCP_FAIL_RATE).when(mTst).getLatestPacketFailPercentage();
+ doReturn(TEST_TCP_PACKET_COUNT).when(mTst).getSentSinceLastRecv();
+ doReturn(true).when(mTst).isDataStallSuspected();
+ doReturn(true).when(mTst).pollSocketsInfo();
}
private void verifySendDataStallDetectionStats(WrappedNetworkMonitor nm, int evalType,
@@ -2417,10 +2414,10 @@
}
private void setupTestWifiInfo() {
- when(mWifi.getConnectionInfo()).thenReturn(mWifiInfo);
- when(mWifiInfo.getRssi()).thenReturn(TEST_SIGNAL_STRENGTH);
+ doReturn(mWifiInfo).when(mWifi).getConnectionInfo();
+ doReturn(TEST_SIGNAL_STRENGTH).when(mWifiInfo).getRssi();
// Set to 2.4G band. Map to DataStallEventProto.AP_BAND_2GHZ proto definition.
- when(mWifiInfo.getFrequency()).thenReturn(2450);
+ doReturn(2450).when(mWifiInfo).getFrequency();
}
private void testDataStallMetricsWithCellular(int evalType) {
@@ -2631,7 +2628,7 @@
setDismissPortalInValidatedNetwork(true);
setSslException(mHttpsConnection);
setPortal302(mHttpConnection);
- when(mHttpConnection.getHeaderField(eq("location"))).thenReturn(locationUrl);
+ doReturn(locationUrl).when(mHttpConnection).getHeaderField(eq("location"));
final NetworkMonitor nm = makeMonitor(CELL_METERED_CAPABILITIES);
notifyNetworkConnected(nm, CELL_METERED_CAPABILITIES);
@@ -2832,8 +2829,9 @@
public void testIsCaptivePortal_FromExternalSource() throws Exception {
assumeTrue(CaptivePortalDataShimImpl.isSupported());
assumeTrue(ShimUtils.isAtLeastS());
- when(mDependencies.isFeatureEnabled(any(), eq(NAMESPACE_CONNECTIVITY),
- eq(DISMISS_PORTAL_IN_VALIDATED_NETWORK), anyBoolean())).thenReturn(true);
+ doReturn(true).when(mDependencies)
+ .isFeatureEnabled(any(), eq(NAMESPACE_CONNECTIVITY),
+ eq(DISMISS_PORTAL_IN_VALIDATED_NETWORK), anyBoolean());
final NetworkMonitor monitor = makeMonitor(WIFI_NOT_METERED_CAPABILITIES);
NetworkInformationShim networkShim = NetworkInformationShimImpl.newInstance();
@@ -2940,10 +2938,10 @@
private void setupResourceForMultipleProbes() {
// Configure the resource to send multiple probe.
- when(mResources.getStringArray(R.array.config_captive_portal_https_urls))
- .thenReturn(TEST_HTTPS_URLS);
- when(mResources.getStringArray(R.array.config_captive_portal_http_urls))
- .thenReturn(TEST_HTTP_URLS);
+ doReturn(TEST_HTTPS_URLS).when(mResources)
+ .getStringArray(R.array.config_captive_portal_https_urls);
+ doReturn(TEST_HTTP_URLS).when(mResources)
+ .getStringArray(R.array.config_captive_portal_http_urls);
}
private void makeDnsTimeoutEvent(WrappedNetworkMonitor wrappedMonitor, int count) {
@@ -2965,23 +2963,23 @@
}
private void setDataStallEvaluationType(int type) {
- when(mDependencies.getDeviceConfigPropertyInt(any(),
- eq(CONFIG_DATA_STALL_EVALUATION_TYPE), anyInt())).thenReturn(type);
+ doReturn(type).when(mDependencies).getDeviceConfigPropertyInt(any(),
+ eq(CONFIG_DATA_STALL_EVALUATION_TYPE), anyInt());
}
private void setMinDataStallEvaluateInterval(int time) {
- when(mDependencies.getDeviceConfigPropertyInt(any(),
- eq(CONFIG_DATA_STALL_MIN_EVALUATE_INTERVAL), anyInt())).thenReturn(time);
+ doReturn(time).when(mDependencies).getDeviceConfigPropertyInt(any(),
+ eq(CONFIG_DATA_STALL_MIN_EVALUATE_INTERVAL), anyInt());
}
private void setValidDataStallDnsTimeThreshold(int time) {
- when(mDependencies.getDeviceConfigPropertyInt(any(),
- eq(CONFIG_DATA_STALL_VALID_DNS_TIME_THRESHOLD), anyInt())).thenReturn(time);
+ doReturn(time).when(mDependencies).getDeviceConfigPropertyInt(any(),
+ eq(CONFIG_DATA_STALL_VALID_DNS_TIME_THRESHOLD), anyInt());
}
private void setConsecutiveDnsTimeoutThreshold(int num) {
- when(mDependencies.getDeviceConfigPropertyInt(any(),
- eq(CONFIG_DATA_STALL_CONSECUTIVE_DNS_TIMEOUT_THRESHOLD), anyInt())).thenReturn(num);
+ doReturn(num).when(mDependencies).getDeviceConfigPropertyInt(any(),
+ eq(CONFIG_DATA_STALL_CONSECUTIVE_DNS_TIMEOUT_THRESHOLD), anyInt());
}
private void setTcpPollingInterval(int time) {
@@ -2990,28 +2988,28 @@
}
private void setFallbackUrl(String url) {
- when(mDependencies.getSetting(any(),
- eq(Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL), any())).thenReturn(url);
+ doReturn(url).when(mDependencies).getSetting(any(),
+ eq(Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL), any());
}
private void setOtherFallbackUrls(String urls) {
- when(mDependencies.getDeviceConfigProperty(any(),
- eq(CAPTIVE_PORTAL_OTHER_FALLBACK_URLS), any())).thenReturn(urls);
+ doReturn(urls).when(mDependencies).getDeviceConfigProperty(any(),
+ eq(CAPTIVE_PORTAL_OTHER_FALLBACK_URLS), any());
}
private void setFallbackSpecs(String specs) {
- when(mDependencies.getDeviceConfigProperty(any(),
- eq(CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS), any())).thenReturn(specs);
+ doReturn(specs).when(mDependencies).getDeviceConfigProperty(any(),
+ eq(CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS), any());
}
private void setCaptivePortalMode(int mode) {
- when(mDependencies.getSetting(any(),
- eq(Settings.Global.CAPTIVE_PORTAL_MODE), anyInt())).thenReturn(mode);
+ doReturn(mode).when(mDependencies).getSetting(any(),
+ eq(Settings.Global.CAPTIVE_PORTAL_MODE), anyInt());
}
private void setDismissPortalInValidatedNetwork(boolean enabled) {
- when(mDependencies.isFeatureEnabled(any(), any(),
- eq(DISMISS_PORTAL_IN_VALIDATED_NETWORK), anyBoolean())).thenReturn(enabled);
+ doReturn(enabled).when(mDependencies).isFeatureEnabled(any(), any(),
+ eq(DISMISS_PORTAL_IN_VALIDATED_NETWORK), anyBoolean());
}
private void setDeviceConfig(String key, String value) {
@@ -3170,8 +3168,8 @@
}
private void generateTestTcpStats(DataStallDetectionStats.Builder stats) {
- when(mTst.getLatestPacketFailPercentage()).thenReturn(TEST_TCP_FAIL_RATE);
- when(mTst.getSentSinceLastRecv()).thenReturn(TEST_TCP_PACKET_COUNT);
+ doReturn(TEST_TCP_FAIL_RATE).when(mTst).getLatestPacketFailPercentage();
+ doReturn(TEST_TCP_PACKET_COUNT).when(mTst).getSentSinceLastRecv();
stats.setTcpFailRate(TEST_TCP_FAIL_RATE).setTcpSentSinceLastRecv(TEST_TCP_PACKET_COUNT);
}