• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef TESTVAAPI_test_va_api_fixture_h
26 #define TESTVAAPI_test_va_api_fixture_h
27 
28 #include "test.h"
29 #include "test_data.h"
30 #include "test_defs.h"
31 #include "test_streamable.h"
32 
33 namespace VAAPI
34 {
35 
36 // The fixture for testing class Foo.
37 class VAAPIFixture : public ::testing::Test
38 {
39 public:
40     VAAPIFixture();
41 
42     virtual ~VAAPIFixture();
43 
44     VADisplay getDisplay();
45     VADisplay doInitialize();
46     void doTerminate();
47 
48     void doCreateContext(const Resolution&,
49                          const VAStatus& expectation = VA_STATUS_SUCCESS);
50     void doDestroyContext(const VAStatus& expectation = VA_STATUS_SUCCESS);
51 
52     void queryConfigProfiles(Profiles&) const;
53     void queryConfigEntrypoints(const VAProfile&, Entrypoints&,
54                                 const VAStatus& = VA_STATUS_SUCCESS) const;
55     VAStatus getSupportStatus(const VAProfile&, const VAEntrypoint&) const;
56     bool isSupported(const VAProfile&, const VAEntrypoint&) const;
57 
58     void getConfigAttributes(const VAProfile&, const VAEntrypoint&,
59                              ConfigAttributes&, const VAStatus& = VA_STATUS_SUCCESS) const;
60     void createConfig(const VAProfile&, const VAEntrypoint&,
61                       const ConfigAttributes& = ConfigAttributes(),
62                       const VAStatus& = VA_STATUS_SUCCESS);
63     void queryConfigAttributes(const VAProfile&, const VAEntrypoint&,
64                                ConfigAttributes&, const VAStatus& = VA_STATUS_SUCCESS) const;
65     void destroyConfig(const VAStatus& = VA_STATUS_SUCCESS);
66 
67     void querySurfaceAttributes(SurfaceAttributes&) const;
68     void getMinMaxSurfaceResolution(Resolution&, Resolution&) const;
69     void createSurfaces(Surfaces&, const unsigned format, const Resolution&,
70                         const SurfaceAttributes& = SurfaceAttributes(),
71                         const VAStatus& = VA_STATUS_SUCCESS) const;
72     void destroySurfaces(Surfaces&) const;
73 
74     void createBuffer(const VABufferType&, const size_t,
75                       const VAStatus& = VA_STATUS_SUCCESS);
76     void destroyBuffer(const VAStatus& = VA_STATUS_SUCCESS);
77 
78     void skipTest(const std::string& message);
79     void skipTest(const VAProfile&, const VAEntrypoint&);
80 
81 protected:
82     // You can remove any or all of the following functions if its body
83     // is empty.
84 
85     // If the constructor and destructor are not enough for setting up
86     // and cleaning up each test, you can define the following methods:
87 
SetUp()88     virtual void SetUp()
89     {
90         // Code here will be called immediately after the constructor (right
91         // before each test).
92     }
93 
TearDown()94     virtual void TearDown()
95     {
96         // Code here will be called immediately after each test (right
97         // before the destructor).
98     }
99 
100     // Objects declared here can be used by all tests in the test case for
101     // VAAPIFixture.
102     VADisplay m_vaDisplay;
103 
104 private:
105     std::string m_restoreDriverName;
106     int m_drmHandle;
107 
108     VAConfigID m_configID;
109     VAContextID m_contextID;
110     VABufferID m_bufferID;
111 
112     std::string m_skip;
113 };
114 
115 /* Test fixture that initializes a shared display once per test suite, and
116  * provides it to you in m_vaDisplay from its SetUp() routine.
117  */
118 class VAAPIFixtureSharedDisplay : public VAAPIFixture
119 {
120 public:
121     VAAPIFixtureSharedDisplay();
122 
123     virtual void SetUp();
124 
125     static void SetUpTestSuite();
126     static void TearDownTestSuite();
127 
128 private:
129     static int s_drmHandle;
130     static VADisplay s_vaDisplay;
131     static VAStatus s_initStatus;
132 };
133 
134 } // namespace VAAPI
135 
136 #endif
137