Package org.robolectric.shadows
Class WifiScanResultBuilder
java.lang.Object
org.robolectric.shadows.WifiScanResultBuilder
Builder class for
ScanResult
allowing for more accurate construction of Wi-Fi scan
results in test code.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newScanResult
instance as configured in this builder.Sets the value of theScanResult.BSSID
field.setCapabilities
(String capabilities) Sets the value of theScanResult.capabilities
field.setCenterFreq0
(int centerFreq0) Sets the center frequency, in MHz, of the first segment (seeScanResult.centerFreq0
).setCenterFreq1
(int centerFreq1) Sets the center frequency, in MHz, of the second segment (seeScanResult.centerFreq1
).setChannelWidth
(int channelWidth) Sets the value returned byScanResult.channelWidth
.setFrequency
(int frequency) Sets the value of the frequency, in MHz, returned by theScanResult.frequency
field.setIs80211azNtbRttResponder
(boolean is80211azNtbRttResponder) Sets the return value ofScanResult.is80211azNtbResponder()
.setIs80211McRttResponder
(boolean is80211McRttResponder) Sets the return value ofScanResult.is80211mcResponder()
.setIsTwtResponder
(boolean isTwtResponder) Sets the return value ofScanResult.isTwtResponder()
.setRssi
(int rssi) Sets the value of theScanResult.level
field (aka RSSI).Sets the value of theScanResult.SSID
field.setTimeSinceSeen
(Duration timeSinceSeen) Sets the duration since boot since the result was seen.setWifiSsid
(WifiSsid wifiSsid) Sets the value returned byScanResult.getWifiSsid()
, additionally setting the deprecatedScanResult.SSID
field.
-
Constructor Details
-
WifiScanResultBuilder
public WifiScanResultBuilder()
-
-
Method Details
-
setCapabilities
Sets the value of theScanResult.capabilities
field.- Returns:
- this builder, for chaining
-
setBssid
Sets the value of theScanResult.BSSID
field.- Returns:
- this builder, for chaining
-
setRssi
Sets the value of theScanResult.level
field (aka RSSI).- Returns:
- this builder, for chaining
-
setFrequency
Sets the value of the frequency, in MHz, returned by theScanResult.frequency
field.- Returns:
- this builder, for chaining
-
setSsid
Sets the value of theScanResult.SSID
field. On API 33 and above, this also sets the return value ofScanResult.getWifiSsid()
.- Parameters:
ssid
- the name of the network, or null; this should be either a UTF-8 encoded string, surrounded by quotes (e.g. '"Network name"'), or an unquoted hex-encoded string (e.g. '0a8b2c1f').- Returns:
- this builder, for chaining
-
setTimeSinceSeen
Sets the duration since boot since the result was seen.- Returns:
- this builder, for chaining
- See Also:
-
setWifiSsid
@RequiresApi(33) @CanIgnoreReturnValue public WifiScanResultBuilder setWifiSsid(@Nullable WifiSsid wifiSsid) Sets the value returned byScanResult.getWifiSsid()
, additionally setting the deprecatedScanResult.SSID
field.- Returns:
- this builder, for chaining
-
setChannelWidth
@RequiresApi(23) @CanIgnoreReturnValue public WifiScanResultBuilder setChannelWidth(int channelWidth) Sets the value returned byScanResult.channelWidth
. This should be one of the constants inScanResult
such asScanResult.CHANNEL_WIDTH_20MHZ
.- Returns:
- this builder, for chaining
-
setCenterFreq0
Sets the center frequency, in MHz, of the first segment (seeScanResult.centerFreq0
).- Returns:
- this builder, for chaining
-
setCenterFreq1
Sets the center frequency, in MHz, of the second segment (seeScanResult.centerFreq1
).- Returns:
- this builder, for chaining
-
setIs80211McRttResponder
@CanIgnoreReturnValue @RequiresApi(23) public WifiScanResultBuilder setIs80211McRttResponder(boolean is80211McRttResponder) Sets the return value ofScanResult.is80211mcResponder()
.- Returns:
- this builder, for chaining
-
setIs80211azNtbRttResponder
@CanIgnoreReturnValue @RequiresApi(35) public WifiScanResultBuilder setIs80211azNtbRttResponder(boolean is80211azNtbRttResponder) Sets the return value ofScanResult.is80211azNtbResponder()
.- Returns:
- this builder, for chaining
-
setIsTwtResponder
@CanIgnoreReturnValue @RequiresApi(35) public WifiScanResultBuilder setIsTwtResponder(boolean isTwtResponder) Sets the return value ofScanResult.isTwtResponder()
.- Returns:
- this builder, for chaining
-
build
Returns a newScanResult
instance as configured in this builder.
-