2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
25 #ifndef I965_TEST_FIXTURE_H
26 #define I965_TEST_FIXTURE_H
29 #include "i965_internal_decl.h"
30 #include "i965_streamable.h"
35 typedef std::vector<VASurfaceID> Surfaces;
36 typedef std::vector<VASurfaceAttrib> SurfaceAttribs;
37 typedef std::vector<VAConfigAttrib> ConfigAttribs;
40 * This test fixture handles initialization and termination of the i965 driver
41 * and display. It defines various operators to make it implicitly convertible
42 * to a VADriverContextP, VADisplay, VADisplayContextP, and i965_driver_data*.
43 * Other operators may be defined, too. These operators allow an instance of
44 * the test fixture to be passed to various driver functions that take one of
45 * those parameter types. Various driver functions are also wrapped by this
46 * test fixture to simplify writing test cases.
48 * Test cases that wish to use this fixture should define their own test
49 * fixture class that derives from this one. The derived test fixture may
50 * override the SetUp() and TearDown() methods. These two methods are invoked
51 * by gtest before and after a TEST_F test body is executed, respectively. The
52 * derived test fixture should be sure to call the I965TestFixture::SetUp() and
53 * I965TestFixture::TearDown() methods when they are overridden to ensure
54 * proper initialization and termination of the driver and display.
56 * See the "Test Fixtures" section in gtest/docs/Primer.md for more details
57 * on how test fixtures are used.
60 : public ::testing::Test
64 virtual ~I965TestFixture();
68 * This is invoked by gtest before the test body is executed. Gtest will
69 * not run the test body if this method generates a fatal test assertion
74 ASSERT_NO_FATAL_FAILURE(initialize());
78 * This is invoked by gtest after the test body is executed... even if the
79 * test body generates a fatal or non-fatal test assertion failure. If
80 * SetUp() generates a fatal test assertion, this is also invoked by gtest
83 virtual void TearDown()
88 const std::string getFullTestName() const;
92 * Initializes the i965 driver and display. May generate a fatal or
93 * non-fatal test assertion failure.
98 * Terminates the i965 driver and display. May generate a non-fatal
99 * test assertion failure.
104 * Convenience wrapper for i965_CreateSurfaces or i965_CreateSurfaces2.
105 * If SurfaceAttribs are specified then i965_CreateSurfaces2 is used,
106 * otherwise i965_CreateSurfaces is used. May generate a non-fatal test
109 Surfaces createSurfaces(int w, int h, int format, size_t count = 1,
110 const SurfaceAttribs& = SurfaceAttribs());
113 * Convenience wrapper for i965_DestroySurfaces. May generate a non-fatal
114 * test assertion failure.
116 void destroySurfaces(Surfaces&);
119 * Convenience wrapper for i965_CreateConfig. May generate a non-fatal
120 * test assertion failure.
122 VAConfigID createConfig(VAProfile, VAEntrypoint, ConfigAttribs&);
125 * Convenience wrapper for i965_DestroyConfig. May generate a non-fatal
126 * test assertion failure.
128 void destroyConfig(VAConfigID);
131 * Convenience wrapper for i965_CreateContext. May generate a non-fatal
132 * test assertion failure.
134 VAContextID createContext(VAConfigID, int, int, int, Surfaces&);
137 * Convenience wrapper for i965_DestroyContext. May generate a non-fatal
138 * test assertion failure.
140 void destroyContext(VAContextID);
143 * Convenience wrapper for i965_CreateBuffer. May generate a non-fatal
144 * test assertion failure.
146 VABufferID createBuffer(
147 VAContextID, VABufferType, unsigned, unsigned = 1, const void * = NULL);
150 * Convenience wrapper for i965_DestroyBuffer. May generate a non-fatal
151 * test assertion failure.
153 void destroyBuffer(VABufferID);
156 * Convenience wrapper for i965_MapBuffer. May generate a non-fatal
157 * test assertion failure.
160 T* mapBuffer(VABufferID id)
164 i965_MapBuffer(*this, id, (void**)&data));
170 * Convenience Wrapper for i965_UnmapBuffer. May generate a non-fatal
171 * test assertion failure.
173 void unmapBuffer(VABufferID id)
176 i965_UnmapBuffer(*this, id));
180 * Convenience wrapper for i965_BeginPicture. May generate a non-fatal
181 * test assertion failure.
183 void beginPicture(VAContextID, VASurfaceID);
186 * Convenience wrapper for i965_RenderPicture. May generate a non-fatal
187 * test assertion failure.
189 void renderPicture(VAContextID, VABufferID *, int = 1);
192 * Convenience wrapper for i965_EndPicture. May generate a non-fatal
193 * test assertion failure.
195 void endPicture(VAContextID);
198 * Convenience wrapper for i965_DeriveImage. May generate a non-fatal
199 * test assertion failure.
201 void deriveImage(VASurfaceID, VAImage &);
204 * Convenience wrapper for i965_DestroyImage. May generate a non-fatal
205 * test assertion failure.
207 void destroyImage(VAImage &);
210 * Convenience wrapper for i965_SyncSurface. May generate a non-fatal
211 * test assertion failure.
213 void syncSurface(VASurfaceID);
216 * VADisplay implicit and explicit conversion operator.
218 operator VADisplay();
221 * VADisplayContextP implict and explicit conversion operator.
223 inline operator VADisplayContextP()
225 return (VADisplayContextP)((VADisplay)*this);
229 * VADriverContextP implict and explicit conversion operator.
231 inline operator VADriverContextP()
233 VADisplayContextP dctx(*this);
234 return dctx ? dctx->pDriverContext : NULL;
238 * i965_driver_data * implict and explicit conversion operator.
240 inline operator struct i965_driver_data *()
242 VADriverContextP ctx(*this);
243 return ctx ? i965_driver_data(ctx) : NULL;
247 int m_handle; /* current native display handle */
248 VADisplay m_vaDisplay; /* current VADisplay handle */