Update Matrix Room API and allow media swipe on pinned event only.
This commit is contained in:
@@ -84,6 +84,27 @@ class EnsureCalledOnceWithTwoParams<T, U>(
|
||||
}
|
||||
}
|
||||
|
||||
class EnsureCalledOnceWithTwoParamsAndResult<T, U, R>(
|
||||
private val expectedParam1: T,
|
||||
private val expectedParam2: U,
|
||||
private val result: R,
|
||||
) : (T, U) -> R {
|
||||
private var counter = 0
|
||||
override fun invoke(p1: T, p2: U): R {
|
||||
if (p1 != expectedParam1 || p2 != expectedParam2) {
|
||||
throw AssertionError("Expected to be called with $expectedParam1 and $expectedParam2, but was called with $p1 and $p2")
|
||||
}
|
||||
counter++
|
||||
return result
|
||||
}
|
||||
|
||||
fun assertSuccess() {
|
||||
if (counter != 1) {
|
||||
throw AssertionError("Expected to be called once, but was called $counter times")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for [<T, R> ensureCalledOnceWithParam] with Unit result.
|
||||
*/
|
||||
|
||||
@@ -32,3 +32,9 @@ class EnsureNeverCalledWithTwoParams<T, U> : (T, U) -> Unit {
|
||||
lambdaError("Should not be called and is called with $p1 and $p2")
|
||||
}
|
||||
}
|
||||
|
||||
class EnsureNeverCalledWithTwoParamsAndResult<T, U, R> : (T, U) -> R {
|
||||
override fun invoke(p1: T, p2: U): R {
|
||||
lambdaError("Should not be called and is called with $p1 and $p2")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user