OSDN Git Service

Fix packed headers attribute test in vaCreateConfig()
[android-x86/hardware-intel-common-vaapi.git] / test / i965_test_fixture.h
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 I965_TEST_FIXTURE_H
26 #define I965_TEST_FIXTURE_H
27
28 #include "i965_test_environment.h"
29
30 #include <string>
31 #include <vector>
32
33 typedef std::vector<VASurfaceID> Surfaces;
34 typedef std::vector<VASurfaceAttrib> SurfaceAttribs;
35 typedef std::vector<VAConfigAttrib> ConfigAttribs;
36 typedef std::vector<VABufferID> Buffers;
37
38 /**
39  * This test fixture defines various operators to make it implicitly convertible
40  * to a VADriverContextP, VADisplay, VADisplayContextP, and i965_driver_data*.
41  * Other operators may be defined, too.  These operators allow an instance of
42  * the test fixture to be passed to various driver functions that take one of
43  * those parameter types.  Various driver functions are also wrapped by this
44  * test fixture to simplify writing test cases.
45  *
46  * Test cases that wish to use this fixture should define their own test
47  * fixture class that derives from this one.
48  *
49  * See the "Test Fixtures" section in gtest/docs/Primer.md for more details
50  * on how test fixtures are used.
51  */
52 class I965TestFixture
53     : public ::testing::Test
54 {
55 public:
56     virtual ~I965TestFixture() { }
57
58     const std::string getFullTestName() const;
59
60     /**
61      * Convenience wrapper for i965_CreateSurfaces or i965_CreateSurfaces2.
62      * If SurfaceAttribs are specified then i965_CreateSurfaces2 is used,
63      * otherwise i965_CreateSurfaces is used. May generate a non-fatal test
64      * assertion failure.
65      */
66     Surfaces createSurfaces(int w, int h, int format, size_t count = 1,
67         const SurfaceAttribs& = SurfaceAttribs());
68
69     /**
70      * Convenience wrapper for i965_DestroySurfaces.  May generate a non-fatal
71      * test assertion failure.
72      */
73     void destroySurfaces(Surfaces&);
74
75     /**
76      * Convenience wrapper for i965_CreateConfig.  May generate a non-fatal
77      * test assertion failure.
78      */
79     VAConfigID createConfig(VAProfile, VAEntrypoint,
80         const ConfigAttribs& = ConfigAttribs(),
81         const VAStatus = VA_STATUS_SUCCESS);
82
83     /**
84      * Convenience wrapper for i965_DestroyConfig.  May generate a non-fatal
85      * test assertion failure.
86      */
87     void destroyConfig(VAConfigID);
88
89     /**
90      * Convenience wrapper for i965_CreateContext.  May generate a non-fatal
91      * test assertion failure.
92      */
93     VAContextID createContext(VAConfigID, int, int, int = 0,
94         const Surfaces& = Surfaces());
95
96     /**
97      * Convenience wrapper for i965_DestroyContext.  May generate a non-fatal
98      * test assertion failure.
99      */
100     void destroyContext(VAContextID);
101
102     /**
103      * Convenience wrapper for i965_CreateBuffer.  May generate a non-fatal
104      * test assertion failure.
105      */
106     VABufferID createBuffer(
107         VAContextID, VABufferType, unsigned, unsigned = 1, const void * = NULL);
108
109     /**
110      * Convenience wrapper for i965_DestroyBuffer.  May generate a non-fatal
111      * test assertion failure.
112      */
113     void destroyBuffer(VABufferID);
114
115     /**
116      * Convenience wrapper for i965_MapBuffer.  May generate a non-fatal
117      * test assertion failure.
118      */
119     template<typename T>
120     T* mapBuffer(VABufferID id)
121     {
122         T* data = NULL;
123         EXPECT_STATUS(
124             i965_MapBuffer(*this, id, (void**)&data));
125         EXPECT_PTR(data);
126         return data;
127     }
128
129     /**
130      * Convenience Wrapper for i965_UnmapBuffer.  May generate a non-fatal
131      * test assertion failure.
132      */
133     void unmapBuffer(VABufferID id)
134     {
135         EXPECT_STATUS(
136             i965_UnmapBuffer(*this, id));
137     }
138
139     /**
140      * Convenience wrapper for i965_BeginPicture.  May generate a non-fatal
141      * test assertion failure.
142      */
143     void beginPicture(VAContextID, VASurfaceID);
144
145     /**
146      * Convenience wrapper for i965_RenderPicture.  May generate a non-fatal
147      * test assertion failure.
148      */
149     void renderPicture(VAContextID, VABufferID *, int = 1);
150
151     /**
152      * Convenience wrapper for i965_EndPicture.  May generate a non-fatal
153      * test assertion failure.
154      */
155     void endPicture(VAContextID);
156
157     /**
158      * Convenience wrapper for i965_DeriveImage.  May generate a non-fatal
159      * test assertion failure.
160      */
161     void deriveImage(VASurfaceID, VAImage &);
162
163     /**
164      * Convenience wrapper for i965_DestroyImage.  May generate a non-fatal
165      * test assertion failure.
166      */
167     void destroyImage(VAImage &);
168
169     /**
170      * Convenience wrapper for i965_SyncSurface.  May generate a non-fatal
171      * test assertion failure.
172      */
173     void syncSurface(VASurfaceID);
174
175     /**
176      * VADisplay implicit and explicit conversion operator.
177      */
178     inline operator VADisplay()
179     { return *I965TestEnvironment::instance(); }
180
181     /**
182      * VADisplayContextP implict and explicit conversion operator.
183      */
184     inline operator VADisplayContextP()
185     { return *I965TestEnvironment::instance(); }
186
187     /**
188      * VADriverContextP implict and explicit conversion operator.
189      */
190     inline operator VADriverContextP()
191     { return *I965TestEnvironment::instance(); }
192
193     /**
194      * i965_driver_data * implict and explicit conversion operator.
195      */
196     inline operator struct i965_driver_data *()
197     { return *I965TestEnvironment::instance(); }
198 };
199
200 #endif