Merge "Convert usb hal test to use VtsHalHidlTargetTestEnvBase"

am: a5123bb1b8

Change-Id: I5183de24d1cdb64989b757bb9a8177364ea5b5cc
This commit is contained in:
Zhuoyao Zhang 2018-02-09 20:30:29 +00:00 committed by android-build-merger
commit ef151c3693
2 changed files with 34 additions and 2 deletions

View file

@ -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;

View file

@ -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;