Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0eabcc2f authored by Thomas Girardier's avatar Thomas Girardier Committed by Gerrit Code Review
Browse files

Merge "PTS-bot: add default timeout and AVDTP tests"

parents b4bc8991 effcf35b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,5 +20,6 @@
        <option name="tests-config-file" value="pts_bot_tests_config.json" />
        <option name="physical" value="false" />
        <option name="profile" value="A2DP/SRC" />
        <option name="profile" value="AVDTP/SRC" />
    </test>
</configuration>
+2 −1
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@
    "AVDTP/SRC/ACP/SIG/SMG/BV-12-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-16-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-18-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-20-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-22-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-24-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-26-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-14-C",
    "AVDTP/SRC/ACP/SIG/SMG/ESR04/BI-28-C",
    "AVDTP/SRC/ACP/SIG/SYN/BV-06-C",
    "AVDTP/SRC/ACP/TRA/BTR/BI-01-C",
@@ -56,6 +56,7 @@
    "A2DP/SRC/SYN/BV-02-I",
    "AVDTP/SRC/ACP/SIG/SMG/BI-11-C",
    "AVDTP/SRC/ACP/SIG/SMG/BI-23-C",
    "AVDTP/SRC/ACP/SIG/SMG/BV-14-C",
    "AVDTP/SRC/ACP/SIG/SMG/ESR05/BV-14-C",
    "AVDTP/SRC/INT/SIG/SMG/BV-11-C",
    "AVDTP/SRC/INT/SIG/SMG/BV-13-C",
+21 −15
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout

/**
 * Creates a cold flow of intents based on an intent filter. If used multiple times in a same class,
@@ -60,6 +61,8 @@ fun intentFlow(context: Context, intentFilter: IntentFilter) = callbackFlow {
 * @param T the type of gRPC response.
 * @param scope coroutine scope used to run the coroutine.
 * @param responseObserver the gRPC stream observer on which to send the response.
 * @param timeout the duration in seconds after which the coroutine is automatically cancelled and
 * returns a timeout error. Default: 60s.
 * @param block the suspended function to execute to get the response.
 * @return reference to the coroutine as a Job.
 *
@@ -79,13 +82,16 @@ fun intentFlow(context: Context, intentFilter: IntentFilter) = callbackFlow {
fun <T> grpcUnary(
    scope: CoroutineScope,
    responseObserver: StreamObserver<T>,
    timeout: Long = 60,
    block: suspend () -> T
): Job {
  return scope.launch {
    try {
      withTimeout(timeout * 1000) {
        val response = block()
        responseObserver.onNext(response)
        responseObserver.onCompleted()
      }
    } catch (e: Throwable) {
      e.printStackTrace()
      responseObserver.onError(e)