summaryrefslogtreecommitdiff
path: root/automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp
diff options
context:
space:
mode:
authorYu Shan <shanyu@google.com>2022-03-02 00:46:13 +0000
committerYu Shan <shanyu@google.com>2022-03-03 02:31:37 +0000
commita58110ea5961f149974f34c274e65967995e6304 (patch)
tree5c934f65bebb4ab6c040613693b5bd0848f4d2be /automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp
parentd0625cc3292a5192891bf2950bd874debca1de55 (diff)
Define custom error type for StatusCode.
Define a wrapper class for StatusCode to be used as E in Result<T, E>. By default E is errorno as defined in linux and does not print out the correct error message. Migrate existing Result usage in VHAL to Result<T, VhalError>. Test: atest VehicleUtilsTest Bug: 219612366 Change-Id: Ic5369b6035bc46afc4c61da26c4b50f7fa9969d8
Diffstat (limited to 'automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp')
-rw-r--r--automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp b/automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp
index de8b26d37f..cc299641f8 100644
--- a/automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp
+++ b/automotive/vehicle/aidl/impl/utils/common/test/VehicleUtilsTest.cpp
@@ -32,6 +32,7 @@ namespace vehicle {
namespace {
+using ::aidl::android::hardware::automotive::vehicle::StatusCode;
using ::aidl::android::hardware::automotive::vehicle::VehicleArea;
using ::aidl::android::hardware::automotive::vehicle::VehicleAreaConfig;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig;
@@ -39,6 +40,8 @@ using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropValue;
+using ::android::base::Error;
+using ::android::base::Result;
struct InvalidPropValueTestCase {
std::string name;
@@ -759,6 +762,12 @@ TEST(VehicleUtilsTest, testConcurrentQueueDeactivateNotifyWaitingThread) {
t.join();
}
+TEST(VehicleUtilsTest, testVhalError) {
+ Result<void, VhalError> result = Error<VhalError>(StatusCode::INVALID_ARG) << "error message";
+
+ ASSERT_EQ(result.error().message(), "error message: INVALID_ARG");
+}
+
class InvalidPropValueTest : public testing::TestWithParam<InvalidPropValueTestCase> {};
INSTANTIATE_TEST_SUITE_P(InvalidPropValueTests, InvalidPropValueTest,