summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'media/omx/1.0/vts/functional/common/media_hidl_test_common.h')
-rw-r--r--media/omx/1.0/vts/functional/common/media_hidl_test_common.h76
1 files changed, 76 insertions, 0 deletions
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 bec733dc..c1863d54 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 @@
21#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS 21#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
22#endif 22#endif
23 23
24#include <getopt.h>
24#include <media/stagefright/foundation/ALooper.h> 25#include <media/stagefright/foundation/ALooper.h>
25#include <utils/Condition.h> 26#include <utils/Condition.h>
26#include <utils/List.h> 27#include <utils/List.h>
@@ -33,6 +34,8 @@
33#include <media/openmax/OMX_AudioExt.h> 34#include <media/openmax/OMX_AudioExt.h>
34#include <media/openmax/OMX_VideoExt.h> 35#include <media/openmax/OMX_VideoExt.h>
35 36
37#include <VtsHalHidlTargetTestEnvBase.h>
38
36/* TIME OUTS (Wait time in dequeueMessage()) */ 39/* TIME OUTS (Wait time in dequeueMessage()) */
37 40
38/* As component is switching states (loaded<->idle<->execute), dequeueMessage() 41/* As component is switching states (loaded<->idle<->execute), dequeueMessage()
@@ -355,4 +358,77 @@ void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
355 portreconfig fptr = nullptr, OMX_U32 kPortIndexInput = 0, 358 portreconfig fptr = nullptr, OMX_U32 kPortIndexInput = 0,
356 OMX_U32 kPortIndexOutput = 1, void* args = nullptr); 359 OMX_U32 kPortIndexOutput = 1, void* args = nullptr);
357 360
361// A class for test environment setup
362class ComponentTestEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
363 private:
364 typedef ::testing::VtsHalHidlTargetTestEnvBase Super;
365
366 public:
367 virtual void registerTestServices() override { registerTestService<IOmx>(); }
368
369 ComponentTestEnvironment() : res("/sdcard/media/") {}
370
371 void setComponent(const char* _component) { component = _component; }
372
373 void setRole(const char* _role) { role = _role; }
374
375 void setRes(const char* _res) { res = _res; }
376
377 const hidl_string getInstance() { return Super::getServiceName<IOmx>(); }
378
379 const hidl_string getComponent() const { return component; }
380
381 const hidl_string getRole() const { return role; }
382
383 const hidl_string getRes() const { return res; }
384
385 int initFromOptions(int argc, char** argv) {
386 static struct option options[] = {{"component", required_argument, 0, 'C'},
387 {"role", required_argument, 0, 'R'},
388 {"res", required_argument, 0, 'P'},
389 {0, 0, 0, 0}};
390
391 while (true) {
392 int index = 0;
393 int c = getopt_long(argc, argv, "C:R:P:", options, &index);
394 if (c == -1) {
395 break;
396 }
397
398 switch (c) {
399 case 'C':
400 setComponent(optarg);
401 break;
402 case 'R':
403 setRole(optarg);
404 break;
405 case 'P':
406 setRes(optarg);
407 break;
408 case '?':
409 break;
410 }
411 }
412
413 if (optind < argc) {
414 fprintf(stderr,
415 "unrecognized option: %s\n\n"
416 "usage: %s <gtest options> <test options>\n\n"
417 "test options are:\n\n"
418 "-C, --component: OMX component to test\n"
419 "-R, --role: OMX component Role\n"
420 "-P, --res: Resource files directory location\n",
421 argv[optind ?: 1], argv[0]);
422 return 2;
423 }
424 return 0;
425 }
426
427 private:
428 hidl_string instance;
429 hidl_string component;
430 hidl_string role;
431 hidl_string res;
432};
433
358#endif // MEDIA_HIDL_TEST_COMMON_H 434#endif // MEDIA_HIDL_TEST_COMMON_H