summaryrefslogtreecommitdiffstats
path: root/usb
diff options
context:
space:
mode:
authorZhuoyao Zhang <zhuoyao@google.com>2018-02-09 20:43:01 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-02-09 20:43:01 +0000
commit3818705c2de5c8efdf927b63f8bcfeb622003cc5 (patch)
treebfdca400b14f7f306ba38c5586e57a140bb8200b /usb
parentcf09967a8ea54cc6ce43c54a8448b6b0433bbd42 (diff)
parent5c5382e428010828bc532cae791eee68625e8080 (diff)
downloadandroid_hardware_interfaces-3818705c2de5c8efdf927b63f8bcfeb622003cc5.tar.gz
android_hardware_interfaces-3818705c2de5c8efdf927b63f8bcfeb622003cc5.tar.bz2
android_hardware_interfaces-3818705c2de5c8efdf927b63f8bcfeb622003cc5.zip
Merge "Convert usb hal test to use VtsHalHidlTargetTestEnvBase" am: a5123bb1b8 am: ef151c3693
am: 5c5382e428 Change-Id: I1723f96bd7e05320db3b89ef75d70f9051750251
Diffstat (limited to 'usb')
-rw-r--r--usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp18
-rw-r--r--usb/1.1/vts/functional/VtsHalUsbV1_1TargetTest.cpp18
2 files changed, 34 insertions, 2 deletions
diff --git a/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp b/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp
index e01b974ab..ee7ef1beb 100644
--- a/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp
+++ b/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp
@@ -22,6 +22,7 @@
#include <android/hardware/usb/1.0/types.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <log/log.h>
#include <stdlib.h>
#include <chrono>
@@ -48,6 +49,18 @@ using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
+// Test environment for Usb HIDL HAL.
+class UsbHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static UsbHidlEnvironment* Instance() {
+ static UsbHidlEnvironment* instance = new UsbHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IUsb>(); }
+};
+
// The main test class for the USB hidl HAL
class UsbHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
@@ -96,7 +109,8 @@ class UsbHidlTest : public ::testing::VtsHalHidlTargetTestBase {
virtual void SetUp() override {
ALOGI("Setup");
- usb = ::testing::VtsHalHidlTargetTestBase::getService<IUsb>();
+ usb = ::testing::VtsHalHidlTargetTestBase::getService<IUsb>(
+ UsbHidlEnvironment::Instance()->getServiceName<IUsb>());
ASSERT_NE(usb, nullptr);
usb_cb_2 = new UsbCallback(*this, 2);
@@ -343,7 +357,9 @@ TEST_F(UsbHidlTest, switchDataRole) {
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(UsbHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ UsbHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
diff --git a/usb/1.1/vts/functional/VtsHalUsbV1_1TargetTest.cpp b/usb/1.1/vts/functional/VtsHalUsbV1_1TargetTest.cpp
index 8a309930a..c990b237f 100644
--- a/usb/1.1/vts/functional/VtsHalUsbV1_1TargetTest.cpp
+++ b/usb/1.1/vts/functional/VtsHalUsbV1_1TargetTest.cpp
@@ -24,6 +24,7 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <log/log.h>
#include <stdlib.h>
#include <chrono>
@@ -113,12 +114,25 @@ class UsbCallback : public ::testing::VtsHalHidlTargetCallbackBase<UsbClientCall
};
};
+// Test environment for Usb HIDL HAL.
+class UsbHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static UsbHidlEnvironment* Instance() {
+ static UsbHidlEnvironment* instance = new UsbHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IUsb>(); }
+};
+
// The main test class for the USB hidl HAL
class UsbHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
ALOGI(__FUNCTION__);
- usb = ::testing::VtsHalHidlTargetTestBase::getService<IUsb>();
+ usb = ::testing::VtsHalHidlTargetTestBase::getService<IUsb>(
+ UsbHidlEnvironment::Instance()->getServiceName<IUsb>());
ASSERT_NE(usb, nullptr);
usb_cb_2 = new UsbCallback(2);
@@ -169,7 +183,9 @@ TEST_F(UsbHidlTest, queryPortStatus) {
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(UsbHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ UsbHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;