aboutsummaryrefslogtreecommitdiff
path: root/java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2024-01-29 21:19:33 -0800
committerXin Li <delphij@google.com>2024-01-29 21:19:33 -0800
commit5da47bce8c0c1d22fb4801b5f773554df03c3e05 (patch)
tree901d28f60bbc5213a61abb55a527906eb6d7bb46 /java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java
parent76f16eedeb439084dcd71a8ae1132b77109949f7 (diff)
parentdd6812f5375184cafc2834da6d5e4208b2f821ca (diff)
downloadchre-5da47bce8c0c1d22fb4801b5f773554df03c3e05.tar.gz
Merge Android 24Q1 Release (ab/11220357)
Bug: 319669529 Merged-In: I12e0fbad4cb34fa11eaf6e022ea61b59c4a0d7d3 Change-Id: If5c6f78ee9a08a1caae56c56426d329b0ec3b5ce
Diffstat (limited to 'java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java')
-rw-r--r--java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java80
1 files changed, 36 insertions, 44 deletions
diff --git a/java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java b/java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java
index 7a0be9e6..d30d3ed3 100644
--- a/java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java
+++ b/java/test/utils/src/com/google/android/utils/chre/ChreApiTestUtil.java
@@ -19,6 +19,7 @@ package com.google.android.utils.chre;
import androidx.annotation.NonNull;
import com.google.android.chre.utils.pigweed.ChreRpcClient;
+import com.google.protobuf.Empty;
import com.google.protobuf.MessageLite;
import java.util.ArrayList;
@@ -55,6 +56,11 @@ public class ChreApiTestUtil {
public static final int RPC_TIMEOUT_IN_MS = RPC_TIMEOUT_IN_SECONDS * 1000;
/**
+ * The default timeout for an RPC call in nanosecond.
+ */
+ public static final long RPC_TIMEOUT_IN_NS = RPC_TIMEOUT_IN_SECONDS * 1000000000L;
+
+ /**
* The number of threads for the executor that executes the futures.
* We need at least 2 here. One to process the RPCs for server streaming
* and one to process events (which has server streaming as a dependent).
@@ -140,7 +146,7 @@ public class ChreApiTestUtil {
/**
* Calls a server streaming RPC method with RPC_TIMEOUT_IN_SECONDS seconds of
- * timeout with a void request.
+ * timeout with an empty request.
*
* @param <ResponseType> the type of the response (proto generated type).
* @param rpcClient the RPC client.
@@ -155,7 +161,7 @@ public class ChreApiTestUtil {
Objects.requireNonNull(rpcClient);
Objects.requireNonNull(method);
- ChreApiTest.Void request = ChreApiTest.Void.newBuilder().build();
+ Empty request = Empty.newBuilder().build();
return callServerStreamingRpcMethodSync(rpcClient, method, request);
}
@@ -266,7 +272,7 @@ public class ChreApiTestUtil {
}
/**
- * Calls an RPC method with RPC_TIMEOUT_IN_SECONDS seconds of timeout with a void request.
+ * Calls an RPC method with RPC_TIMEOUT_IN_SECONDS seconds of timeout with an empty request.
*
* @param <ResponseType> the type of the response (proto generated type).
* @param rpcClient the RPC client.
@@ -280,7 +286,7 @@ public class ChreApiTestUtil {
Objects.requireNonNull(rpcClient);
Objects.requireNonNull(method);
- ChreApiTest.Void request = ChreApiTest.Void.newBuilder().build();
+ Empty request = Empty.newBuilder().build();
return callUnaryRpcMethodSync(rpcClient, method, request);
}
@@ -303,7 +309,6 @@ public class ChreApiTestUtil {
ChreApiTest.GatherEventsInput input = ChreApiTest.GatherEventsInput.newBuilder()
.addAllEventTypes(eventTypes)
- .setEventTypeCount(eventTypes.size())
.setEventCount(eventCount)
.setTimeoutInNs(timeoutInNs)
.build();
@@ -385,69 +390,56 @@ public class ChreApiTestUtil {
return new Service("chre.rpc.ChreApiTestService",
Service.unaryMethod(
"ChreBleGetCapabilities",
- ChreApiTest.Void.class,
- ChreApiTest.Capabilities.class),
+ Empty.parser(),
+ ChreApiTest.Capabilities.parser()),
Service.unaryMethod(
"ChreBleGetFilterCapabilities",
- ChreApiTest.Void.class,
- ChreApiTest.Capabilities.class),
- Service.unaryMethod(
- "ChreBleStartScanAsync",
- ChreApiTest.ChreBleStartScanAsyncInput.class,
- ChreApiTest.Status.class),
+ Empty.parser(),
+ ChreApiTest.Capabilities.parser()),
Service.serverStreamingMethod(
"ChreBleStartScanSync",
- ChreApiTest.ChreBleStartScanAsyncInput.class,
- ChreApiTest.GeneralSyncMessage.class),
- Service.unaryMethod(
- "ChreBleStopScanAsync",
- ChreApiTest.Void.class,
- ChreApiTest.Status.class),
+ ChreApiTest.ChreBleStartScanAsyncInput.parser(),
+ ChreApiTest.GeneralSyncMessage.parser()),
Service.serverStreamingMethod(
"ChreBleStopScanSync",
- ChreApiTest.Void.class,
- ChreApiTest.GeneralSyncMessage.class),
+ Empty.parser(),
+ ChreApiTest.GeneralSyncMessage.parser()),
Service.unaryMethod(
"ChreSensorFindDefault",
- ChreApiTest.ChreSensorFindDefaultInput.class,
- ChreApiTest.ChreSensorFindDefaultOutput.class),
+ ChreApiTest.ChreSensorFindDefaultInput.parser(),
+ ChreApiTest.ChreSensorFindDefaultOutput.parser()),
Service.unaryMethod(
"ChreGetSensorInfo",
- ChreApiTest.ChreHandleInput.class,
- ChreApiTest.ChreGetSensorInfoOutput.class),
+ ChreApiTest.ChreHandleInput.parser(),
+ ChreApiTest.ChreGetSensorInfoOutput.parser()),
Service.unaryMethod(
"ChreGetSensorSamplingStatus",
- ChreApiTest.ChreHandleInput.class,
- ChreApiTest.ChreGetSensorSamplingStatusOutput.class),
+ ChreApiTest.ChreHandleInput.parser(),
+ ChreApiTest.ChreGetSensorSamplingStatusOutput.parser()),
Service.unaryMethod(
"ChreSensorConfigure",
- ChreApiTest.ChreSensorConfigureInput.class,
- ChreApiTest.Status.class),
+ ChreApiTest.ChreSensorConfigureInput.parser(),
+ ChreApiTest.Status.parser()),
Service.unaryMethod(
"ChreSensorConfigureModeOnly",
- ChreApiTest.ChreSensorConfigureModeOnlyInput.class,
- ChreApiTest.Status.class),
+ ChreApiTest.ChreSensorConfigureModeOnlyInput.parser(),
+ ChreApiTest.Status.parser()),
Service.unaryMethod(
"ChreAudioGetSource",
- ChreApiTest.ChreHandleInput.class,
- ChreApiTest.ChreAudioGetSourceOutput.class),
+ ChreApiTest.ChreHandleInput.parser(),
+ ChreApiTest.ChreAudioGetSourceOutput.parser()),
Service.unaryMethod(
"ChreConfigureHostEndpointNotifications",
- ChreApiTest.ChreConfigureHostEndpointNotificationsInput.class,
- ChreApiTest.Status.class),
- Service.unaryMethod(
- "RetrieveLatestDisconnectedHostEndpointEvent",
- ChreApiTest.Void.class,
- ChreApiTest.RetrieveLatestDisconnectedHostEndpointEventOutput
- .class),
+ ChreApiTest.ChreConfigureHostEndpointNotificationsInput.parser(),
+ ChreApiTest.Status.parser()),
Service.unaryMethod(
"ChreGetHostEndpointInfo",
- ChreApiTest.ChreGetHostEndpointInfoInput.class,
- ChreApiTest.ChreGetHostEndpointInfoOutput.class),
+ ChreApiTest.ChreGetHostEndpointInfoInput.parser(),
+ ChreApiTest.ChreGetHostEndpointInfoOutput.parser()),
Service.serverStreamingMethod(
"GatherEvents",
- ChreApiTest.GatherEventsInput.class,
- ChreApiTest.GeneralEventsMessage.class));
+ ChreApiTest.GatherEventsInput.parser(),
+ ChreApiTest.GeneralEventsMessage.parser()));
}
/**