diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp index 38cdcd6508..42f99471d2 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp @@ -50,85 +50,6 @@ using ::android::sp; #include #include -// A class for test environment setup -class ComponentTestEnvironment : public ::testing::Environment { - public: - virtual void SetUp() {} - virtual void TearDown() {} - - ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {} - - void setInstance(const char* _instance) { instance = _instance; } - - void setComponent(const char* _component) { component = _component; } - - void setRole(const char* _role) { role = _role; } - - void setRes(const char* _res) { res = _res; } - - const hidl_string getInstance() const { return instance; } - - const hidl_string getComponent() const { return component; } - - const hidl_string getRole() const { return role; } - - const hidl_string getRes() const { return res; } - - int initFromOptions(int argc, char** argv) { - static struct option options[] = { - {"instance", required_argument, 0, 'I'}, - {"component", required_argument, 0, 'C'}, - {"role", required_argument, 0, 'R'}, - {"res", required_argument, 0, 'P'}, - {0, 0, 0, 0}}; - - while (true) { - int index = 0; - int c = getopt_long(argc, argv, "I:C:R:P:", options, &index); - if (c == -1) { - break; - } - - switch (c) { - case 'I': - setInstance(optarg); - break; - case 'C': - setComponent(optarg); - break; - case 'R': - setRole(optarg); - break; - case 'P': - setRes(optarg); - break; - case '?': - break; - } - } - - if (optind < argc) { - fprintf(stderr, - "unrecognized option: %s\n\n" - "usage: %s \n\n" - "test options are:\n\n" - "-I, --instance: HAL instance to test\n" - "-C, --component: OMX component to test\n" - "-R, --role: OMX component Role\n" - "-P, --res: Resource files directory location\n", - argv[optind ?: 1], argv[0]); - return 2; - } - return 0; - } - - private: - hidl_string instance; - hidl_string component; - hidl_string role; - hidl_string res; -}; - static ComponentTestEnvironment* gEnv = nullptr; // audio decoder test fixture class @@ -1220,6 +1141,7 @@ int main(int argc, char** argv) { gEnv = new ComponentTestEnvironment(); ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); + gEnv->init(&argc, argv); int status = gEnv->initFromOptions(argc, argv); if (status == 0) { status = RUN_ALL_TESTS(); diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp index 953dc7507b..d5f1f2da37 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp @@ -50,85 +50,6 @@ using ::android::sp; #include #include -// A class for test environment setup -class ComponentTestEnvironment : public ::testing::Environment { - public: - virtual void SetUp() {} - virtual void TearDown() {} - - ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {} - - void setInstance(const char* _instance) { instance = _instance; } - - void setComponent(const char* _component) { component = _component; } - - void setRole(const char* _role) { role = _role; } - - void setRes(const char* _res) { res = _res; } - - const hidl_string getInstance() const { return instance; } - - const hidl_string getComponent() const { return component; } - - const hidl_string getRole() const { return role; } - - const hidl_string getRes() const { return res; } - - int initFromOptions(int argc, char** argv) { - static struct option options[] = { - {"instance", required_argument, 0, 'I'}, - {"component", required_argument, 0, 'C'}, - {"role", required_argument, 0, 'R'}, - {"res", required_argument, 0, 'P'}, - {0, 0, 0, 0}}; - - while (true) { - int index = 0; - int c = getopt_long(argc, argv, "I:C:R:P:", options, &index); - if (c == -1) { - break; - } - - switch (c) { - case 'I': - setInstance(optarg); - break; - case 'C': - setComponent(optarg); - break; - case 'R': - setRole(optarg); - break; - case 'P': - setRes(optarg); - break; - case '?': - break; - } - } - - if (optind < argc) { - fprintf(stderr, - "unrecognized option: %s\n\n" - "usage: %s \n\n" - "test options are:\n\n" - "-I, --instance: HAL instance to test\n" - "-C, --component: OMX component to test\n" - "-R, --role: OMX component Role\n" - "-P, --res: Resource files directory location\n", - argv[optind ?: 1], argv[0]); - return 2; - } - return 0; - } - - private: - hidl_string instance; - hidl_string component; - hidl_string role; - hidl_string res; -}; - static ComponentTestEnvironment* gEnv = nullptr; // audio encoder test fixture class @@ -562,6 +483,7 @@ int main(int argc, char** argv) { gEnv = new ComponentTestEnvironment(); ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); + gEnv->init(&argc, argv); int status = gEnv->initFromOptions(argc, argv); if (status == 0) { status = RUN_ALL_TESTS(); diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h index bec733dc93..c1863d5469 100644 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h @@ -21,6 +21,7 @@ #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS #endif +#include #include #include #include @@ -33,6 +34,8 @@ #include #include +#include + /* TIME OUTS (Wait time in dequeueMessage()) */ /* As component is switching states (loaded<->idle<->execute), dequeueMessage() @@ -355,4 +358,77 @@ void testEOS(sp omxNode, sp observer, portreconfig fptr = nullptr, OMX_U32 kPortIndexInput = 0, OMX_U32 kPortIndexOutput = 1, void* args = nullptr); +// A class for test environment setup +class ComponentTestEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + private: + typedef ::testing::VtsHalHidlTargetTestEnvBase Super; + + public: + virtual void registerTestServices() override { registerTestService(); } + + ComponentTestEnvironment() : res("/sdcard/media/") {} + + void setComponent(const char* _component) { component = _component; } + + void setRole(const char* _role) { role = _role; } + + void setRes(const char* _res) { res = _res; } + + const hidl_string getInstance() { return Super::getServiceName(); } + + const hidl_string getComponent() const { return component; } + + const hidl_string getRole() const { return role; } + + const hidl_string getRes() const { return res; } + + int initFromOptions(int argc, char** argv) { + static struct option options[] = {{"component", required_argument, 0, 'C'}, + {"role", required_argument, 0, 'R'}, + {"res", required_argument, 0, 'P'}, + {0, 0, 0, 0}}; + + while (true) { + int index = 0; + int c = getopt_long(argc, argv, "C:R:P:", options, &index); + if (c == -1) { + break; + } + + switch (c) { + case 'C': + setComponent(optarg); + break; + case 'R': + setRole(optarg); + break; + case 'P': + setRes(optarg); + break; + case '?': + break; + } + } + + if (optind < argc) { + fprintf(stderr, + "unrecognized option: %s\n\n" + "usage: %s \n\n" + "test options are:\n\n" + "-C, --component: OMX component to test\n" + "-R, --role: OMX component Role\n" + "-P, --res: Resource files directory location\n", + argv[optind ?: 1], argv[0]); + return 2; + } + return 0; + } + + private: + hidl_string instance; + hidl_string component; + hidl_string role; + hidl_string res; +}; + #endif // MEDIA_HIDL_TEST_COMMON_H diff --git a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp index d66136d212..f7c843363c 100644 --- a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp +++ b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp @@ -48,75 +48,6 @@ using ::android::sp; #include #include -// A class for test environment setup -class ComponentTestEnvironment : public ::testing::Environment { - public: - virtual void SetUp() {} - virtual void TearDown() {} - - ComponentTestEnvironment() : instance("default") {} - - void setInstance(const char* _instance) { instance = _instance; } - - void setComponent(const char* _component) { component = _component; } - - void setRole(const char* _role) { role = _role; } - - const hidl_string getInstance() const { return instance; } - - const hidl_string getComponent() const { return component; } - - const hidl_string getRole() const { return role; } - - int initFromOptions(int argc, char** argv) { - static struct option options[] = { - {"instance", required_argument, 0, 'I'}, - {"component", required_argument, 0, 'C'}, - {"role", required_argument, 0, 'R'}, - {0, 0, 0, 0}}; - - while (true) { - int index = 0; - int c = getopt_long(argc, argv, "I:C:R:", options, &index); - if (c == -1) { - break; - } - - switch (c) { - case 'I': - setInstance(optarg); - break; - case 'C': - setComponent(optarg); - break; - case 'R': - setRole(optarg); - break; - case '?': - break; - } - } - - if (optind < argc) { - fprintf(stderr, - "unrecognized option: %s\n\n" - "usage: %s \n\n" - "test options are:\n\n" - "-I, --instance: HAL instance to test\n" - "-C, --component: OMX component to test\n" - "-R, --Role: OMX component Role\n", - argv[optind ?: 1], argv[0]); - return 2; - } - return 0; - } - - private: - hidl_string instance; - hidl_string component; - hidl_string role; -}; - static ComponentTestEnvironment* gEnv = nullptr; // generic component test fixture class @@ -1321,6 +1252,7 @@ int main(int argc, char** argv) { gEnv = new ComponentTestEnvironment(); ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); + gEnv->init(&argc, argv); int status = gEnv->initFromOptions(argc, argv); if (status == 0) { status = RUN_ALL_TESTS(); diff --git a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp index 5a31d691c9..64abe1c1b1 100644 --- a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp +++ b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp @@ -50,54 +50,6 @@ using ::android::sp; #include #include -// A class for test environment setup -class ComponentTestEnvironment : public ::testing::Environment { - public: - virtual void SetUp() {} - virtual void TearDown() {} - - ComponentTestEnvironment() : instance("default") {} - - void setInstance(const char* _instance) { instance = _instance; } - - const hidl_string getInstance() const { return instance; } - - int initFromOptions(int argc, char** argv) { - static struct option options[] = { - {"instance", required_argument, 0, 'I'}, {0, 0, 0, 0}}; - - while (true) { - int index = 0; - int c = getopt_long(argc, argv, "I:", options, &index); - if (c == -1) { - break; - } - - switch (c) { - case 'I': - setInstance(optarg); - break; - case '?': - break; - } - } - - if (optind < argc) { - fprintf(stderr, - "unrecognized option: %s\n\n" - "usage: %s \n\n" - "test options are:\n\n" - "-I, --instance: HAL instance to test\n", - argv[optind ?: 1], argv[0]); - return 2; - } - return 0; - } - - private: - hidl_string instance; -}; - static ComponentTestEnvironment* gEnv = nullptr; class MasterHidlTest : public ::testing::VtsHalHidlTargetTestBase { @@ -226,6 +178,7 @@ int main(int argc, char** argv) { gEnv = new ComponentTestEnvironment(); ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); + gEnv->init(&argc, argv); int status = gEnv->initFromOptions(argc, argv); if (status == 0) { status = RUN_ALL_TESTS(); diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp index 034992ec00..40e76c9a3b 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp @@ -51,85 +51,6 @@ using ::android::sp; #include #include -// A class for test environment setup -class ComponentTestEnvironment : public ::testing::Environment { - public: - virtual void SetUp() {} - virtual void TearDown() {} - - ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {} - - void setInstance(const char* _instance) { instance = _instance; } - - void setComponent(const char* _component) { component = _component; } - - void setRole(const char* _role) { role = _role; } - - void setRes(const char* _res) { res = _res; } - - const hidl_string getInstance() const { return instance; } - - const hidl_string getComponent() const { return component; } - - const hidl_string getRole() const { return role; } - - const hidl_string getRes() const { return res; } - - int initFromOptions(int argc, char** argv) { - static struct option options[] = { - {"instance", required_argument, 0, 'I'}, - {"component", required_argument, 0, 'C'}, - {"role", required_argument, 0, 'R'}, - {"res", required_argument, 0, 'P'}, - {0, 0, 0, 0}}; - - while (true) { - int index = 0; - int c = getopt_long(argc, argv, "I:C:R:P:", options, &index); - if (c == -1) { - break; - } - - switch (c) { - case 'I': - setInstance(optarg); - break; - case 'C': - setComponent(optarg); - break; - case 'R': - setRole(optarg); - break; - case 'P': - setRes(optarg); - break; - case '?': - break; - } - } - - if (optind < argc) { - fprintf(stderr, - "unrecognized option: %s\n\n" - "usage: %s \n\n" - "test options are:\n\n" - "-I, --instance: HAL instance to test\n" - "-C, --component: OMX component to test\n" - "-R, --role: OMX component Role\n" - "-P, --res: Resource files directory location\n", - argv[optind ?: 1], argv[0]); - return 2; - } - return 0; - } - - private: - hidl_string instance; - hidl_string component; - hidl_string role; - hidl_string res; -}; - static ComponentTestEnvironment* gEnv = nullptr; // video decoder test fixture class @@ -1488,6 +1409,7 @@ int main(int argc, char** argv) { gEnv = new ComponentTestEnvironment(); ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); + gEnv->init(&argc, argv); int status = gEnv->initFromOptions(argc, argv); if (status == 0) { status = RUN_ALL_TESTS(); diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp index 099658f8ae..2056d9e670 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp @@ -64,85 +64,6 @@ using ::android::sp; #include #include -// A class for test environment setup -class ComponentTestEnvironment : public ::testing::Environment { - public: - virtual void SetUp() {} - virtual void TearDown() {} - - ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {} - - void setInstance(const char* _instance) { instance = _instance; } - - void setComponent(const char* _component) { component = _component; } - - void setRole(const char* _role) { role = _role; } - - void setRes(const char* _res) { res = _res; } - - const hidl_string getInstance() const { return instance; } - - const hidl_string getComponent() const { return component; } - - const hidl_string getRole() const { return role; } - - const hidl_string getRes() const { return res; } - - int initFromOptions(int argc, char** argv) { - static struct option options[] = { - {"instance", required_argument, 0, 'I'}, - {"component", required_argument, 0, 'C'}, - {"role", required_argument, 0, 'R'}, - {"res", required_argument, 0, 'P'}, - {0, 0, 0, 0}}; - - while (true) { - int index = 0; - int c = getopt_long(argc, argv, "I:C:R:P:", options, &index); - if (c == -1) { - break; - } - - switch (c) { - case 'I': - setInstance(optarg); - break; - case 'C': - setComponent(optarg); - break; - case 'R': - setRole(optarg); - break; - case 'P': - setRes(optarg); - break; - case '?': - break; - } - } - - if (optind < argc) { - fprintf(stderr, - "unrecognized option: %s\n\n" - "usage: %s \n\n" - "test options are:\n\n" - "-I, --instance: HAL instance to test\n" - "-C, --component: OMX component to test\n" - "-R, --role: OMX component Role\n" - "-P, --res: Resource files directory location\n", - argv[optind ?: 1], argv[0]); - return 2; - } - return 0; - } - - private: - hidl_string instance; - hidl_string component; - hidl_string role; - hidl_string res; -}; - static ComponentTestEnvironment* gEnv = nullptr; // video encoder test fixture class @@ -1580,6 +1501,7 @@ int main(int argc, char** argv) { gEnv = new ComponentTestEnvironment(); ::testing::AddGlobalTestEnvironment(gEnv); ::testing::InitGoogleTest(&argc, argv); + gEnv->init(&argc, argv); int status = gEnv->initFromOptions(argc, argv); if (status == 0) { status = RUN_ALL_TESTS();