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"
34 typedef std::vector<VASurfaceID> Surfaces;
35 typedef std::vector<VASurfaceAttrib> SurfaceAttribs;
36 typedef std::vector<VAConfigAttrib> ConfigAttribs;
39 * This test fixture handles initialization and termination of the i965 driver
40 * and display. It defines various operators to make it implicitly convertible
41 * to a VADriverContextP, VADisplay, VADisplayContextP, and i965_driver_data*.
42 * Other operators may be defined, too. These operators allow an instance of
43 * the test fixture to be passed to various driver functions that take one of
44 * those parameter types. Various driver functions are also wrapped by this
45 * test fixture to simplify writing test cases.
47 * Test cases that wish to use this fixture should define their own test
48 * fixture class that derives from this one. The derived test fixture may
49 * override the SetUp() and TearDown() methods. These two methods are invoked
50 * by gtest before and after a TEST_F test body is executed, respectively. The
51 * derived test fixture should be sure to call the I965TestFixture::SetUp() and
52 * I965TestFixture::TearDown() methods when they are overridden to ensure
53 * proper initialization and termination of the driver and display.
55 * See the "Test Fixtures" section in gtest/docs/Primer.md for more details
56 * on how test fixtures are used.
59 : public ::testing::Test
63 virtual ~I965TestFixture();
67 * This is invoked by gtest before the test body is executed. Gtest will
68 * not run the test body if this method generates a fatal test assertion
73 ASSERT_NO_FATAL_FAILURE(initialize());
77 * This is invoked by gtest after the test body is executed... even if the
78 * test body generates a fatal or non-fatal test assertion failure. If
79 * SetUp() generates a fatal test assertion, this is also invoked by gtest
82 virtual void TearDown()
87 const std::string getFullTestName() const;
91 * Initializes the i965 driver and display. May generate a fatal or
92 * non-fatal test assertion failure.
97 * Terminates the i965 driver and display. May generate a non-fatal
98 * test assertion failure.
103 * Convenience wrapper for i965_CreateSurfaces or i965_CreateSurfaces2.
104 * If SurfaceAttribs are specified then i965_CreateSurfaces2 is used,
105 * otherwise i965_CreateSurfaces is used. May generate a non-fatal test
108 Surfaces createSurfaces(int w, int h, int format, size_t count = 1,
109 const SurfaceAttribs& = SurfaceAttribs());
112 * Convenience wrapper for i965_DestroySurfaces. May generate a non-fatal
113 * test assertion failure.
115 void destroySurfaces(Surfaces&);
118 * Convenience wrapper for i965_CreateConfig. May generate a non-fatal
119 * test assertion failure.
121 VAConfigID createConfig(VAProfile, VAEntrypoint, ConfigAttribs&);
124 * Convenience wrapper for i965_DestroyConfig. May generate a non-fatal
125 * test assertion failure.
127 void destroyConfig(VAConfigID);
130 * Convenience wrapper for i965_CreateContext. May generate a non-fatal
131 * test assertion failure.
133 VAContextID createContext(VAConfigID, int, int, int, Surfaces&);
136 * Convenience wrapper for i965_DestroyContext. May generate a non-fatal
137 * test assertion failure.
139 void destroyContext(VAContextID);
142 * Convenience wrapper for i965_CreateBuffer. May generate a non-fatal
143 * test assertion failure.
145 VABufferID createBuffer(
146 VAContextID, VABufferType, unsigned, unsigned = 1, const void * = NULL);
149 * Convenience wrapper for i965_DestroyBuffer. May generate a non-fatal
150 * test assertion failure.
152 void destroyBuffer(VABufferID);
155 * Convenience wrapper for i965_MapBuffer. May generate a non-fatal
156 * test assertion failure.
159 T* mapBuffer(VABufferID id)
163 i965_MapBuffer(*this, id, (void**)&data));
169 * Convenience Wrapper for i965_UnmapBuffer. May generate a non-fatal
170 * test assertion failure.
172 void unmapBuffer(VABufferID id)
175 i965_UnmapBuffer(*this, id));
179 * Convenience wrapper for i965_BeginPicture. May generate a non-fatal
180 * test assertion failure.
182 void beginPicture(VAContextID, VASurfaceID);
185 * Convenience wrapper for i965_RenderPicture. May generate a non-fatal
186 * test assertion failure.
188 void renderPicture(VAContextID, VABufferID *, int = 1);
191 * Convenience wrapper for i965_EndPicture. May generate a non-fatal
192 * test assertion failure.
194 void endPicture(VAContextID);
197 * Convenience wrapper for i965_DeriveImage. May generate a non-fatal
198 * test assertion failure.
200 void deriveImage(VASurfaceID, VAImage &);
203 * Convenience wrapper for i965_DestroyImage. May generate a non-fatal
204 * test assertion failure.
206 void destroyImage(VAImage &);
209 * VADisplay implicit and explicit conversion operator.
211 operator VADisplay();
214 * VADisplayContextP implict and explicit conversion operator.
216 inline operator VADisplayContextP()
218 return (VADisplayContextP)((VADisplay)*this);
222 * VADriverContextP implict and explicit conversion operator.
224 inline operator VADriverContextP()
226 VADisplayContextP dctx(*this);
227 return dctx ? dctx->pDriverContext : NULL;
231 * i965_driver_data * implict and explicit conversion operator.
233 inline operator struct i965_driver_data *()
235 VADriverContextP ctx(*this);
236 return ctx ? i965_driver_data(ctx) : NULL;
240 int m_handle; /* current native display handle */
241 VADisplay m_vaDisplay; /* current VADisplay handle */