Merge changes from topic "testStatsProvider-cp"
* changes: Add getter for quotaBytes Add OnSetWarningAndLimit into TestableNetworkStatsProvider
This commit is contained in:
commit
89bd9975ce
1 changed files with 16 additions and 3 deletions
|
|
@ -30,7 +30,16 @@ open class TestableNetworkStatsProvider(
|
|||
) : NetworkStatsProvider() {
|
||||
sealed class CallbackType {
|
||||
data class OnRequestStatsUpdate(val token: Int) : CallbackType()
|
||||
data class OnSetLimit(val iface: String?, val quotaBytes: Long) : CallbackType()
|
||||
data class OnSetWarningAndLimit(
|
||||
val iface: String,
|
||||
val warningBytes: Long,
|
||||
val limitBytes: Long
|
||||
) : CallbackType()
|
||||
data class OnSetLimit(val iface: String, val limitBytes: Long) : CallbackType() {
|
||||
// Add getter for backward compatibility since old tests do not recognize limitBytes.
|
||||
val quotaBytes: Long
|
||||
get() = limitBytes
|
||||
}
|
||||
data class OnSetAlert(val quotaBytes: Long) : CallbackType()
|
||||
}
|
||||
|
||||
|
|
@ -42,6 +51,10 @@ open class TestableNetworkStatsProvider(
|
|||
history.add(CallbackType.OnRequestStatsUpdate(token))
|
||||
}
|
||||
|
||||
override fun onSetWarningAndLimit(iface: String, warningBytes: Long, limitBytes: Long) {
|
||||
history.add(CallbackType.OnSetWarningAndLimit(iface, warningBytes, limitBytes))
|
||||
}
|
||||
|
||||
override fun onSetLimit(iface: String, quotaBytes: Long) {
|
||||
history.add(CallbackType.OnSetLimit(iface, quotaBytes))
|
||||
}
|
||||
|
|
@ -56,10 +69,10 @@ open class TestableNetworkStatsProvider(
|
|||
if (token != TOKEN_ANY) {
|
||||
assertEquals(token, event.token)
|
||||
}
|
||||
return token
|
||||
return event.token
|
||||
}
|
||||
|
||||
fun expectOnSetLimit(iface: String?, quotaBytes: Long, timeout: Long = defaultTimeoutMs) {
|
||||
fun expectOnSetLimit(iface: String, quotaBytes: Long, timeout: Long = defaultTimeoutMs) {
|
||||
assertEquals(CallbackType.OnSetLimit(iface, quotaBytes), history.poll(timeout))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue