Merge "Convert cas hal test to use VtsHalHidlTargetTestEnvBase" am: fadafee26a am: 16465a4b37

am: 707258b232

Change-Id: Ia1cd0ec1ed287ff20f64ea840dadcbc539981091
This commit is contained in:
Zhuoyao Zhang 2018-02-09 20:42:12 +00:00 committed by android-build-merger
commit a964d83a1f

View file

@ -17,6 +17,7 @@
#define LOG_TAG "mediacas_hidl_hal_test"
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/cas/1.0/ICas.h>
#include <android/hardware/cas/1.0/ICasListener.h>
@ -206,10 +207,23 @@ void MediaCasListener::testEventEcho(sp<ICas>& mediaCas, int32_t& event, int32_t
EXPECT_TRUE(mEventData == eventData);
}
// Test environment for Cas HIDL HAL.
class CasHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
public:
// get the test environment singleton
static CasHidlEnvironment* Instance() {
static CasHidlEnvironment* instance = new CasHidlEnvironment;
return instance;
}
virtual void registerTestServices() override { registerTestService<IMediaCasService>(); }
};
class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
mService = ::testing::VtsHalHidlTargetTestBase::getService<IMediaCasService>();
mService = ::testing::VtsHalHidlTargetTestBase::getService<IMediaCasService>(
CasHidlEnvironment::Instance()->getServiceName<IMediaCasService>());
ASSERT_NE(mService, nullptr);
}
@ -843,7 +857,9 @@ TEST_F(MediaCasHidlTest, TestClearKeyOobFails) {
} // anonymous namespace
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(CasHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
CasHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;