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
28 #include "i965_test_environment.h"
33 typedef std::vector<VASurfaceID> Surfaces;
34 typedef std::vector<VASurfaceAttrib> SurfaceAttribs;
35 typedef std::vector<VAConfigAttrib> ConfigAttribs;
36 typedef std::vector<VABufferID> Buffers;
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.
46 * Test cases that wish to use this fixture should define their own test
47 * fixture class that derives from this one.
49 * See the "Test Fixtures" section in gtest/docs/Primer.md for more details
50 * on how test fixtures are used.
53 : public ::testing::Test
56 virtual ~I965TestFixture() { }
58 const std::string getFullTestName() const;
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
66 Surfaces createSurfaces(int w, int h, int format, size_t count = 1,
67 const SurfaceAttribs& = SurfaceAttribs());
70 * Convenience wrapper for i965_DestroySurfaces. May generate a non-fatal
71 * test assertion failure.
73 void destroySurfaces(Surfaces&);
76 * Convenience wrapper for i965_CreateConfig. May generate a non-fatal
77 * test assertion failure.
79 VAConfigID createConfig(VAProfile, VAEntrypoint,
80 const ConfigAttribs& = ConfigAttribs());
83 * Convenience wrapper for i965_DestroyConfig. May generate a non-fatal
84 * test assertion failure.
86 void destroyConfig(VAConfigID);
89 * Convenience wrapper for i965_CreateContext. May generate a non-fatal
90 * test assertion failure.
92 VAContextID createContext(VAConfigID, int, int, int = 0,
93 const Surfaces& = Surfaces());
96 * Convenience wrapper for i965_DestroyContext. May generate a non-fatal
97 * test assertion failure.
99 void destroyContext(VAContextID);
102 * Convenience wrapper for i965_CreateBuffer. May generate a non-fatal
103 * test assertion failure.
105 VABufferID createBuffer(
106 VAContextID, VABufferType, unsigned, unsigned = 1, const void * = NULL);
109 * Convenience wrapper for i965_DestroyBuffer. May generate a non-fatal
110 * test assertion failure.
112 void destroyBuffer(VABufferID);
115 * Convenience wrapper for i965_MapBuffer. May generate a non-fatal
116 * test assertion failure.
119 T* mapBuffer(VABufferID id)
123 i965_MapBuffer(*this, id, (void**)&data));
129 * Convenience Wrapper for i965_UnmapBuffer. May generate a non-fatal
130 * test assertion failure.
132 void unmapBuffer(VABufferID id)
135 i965_UnmapBuffer(*this, id));
139 * Convenience wrapper for i965_BeginPicture. May generate a non-fatal
140 * test assertion failure.
142 void beginPicture(VAContextID, VASurfaceID);
145 * Convenience wrapper for i965_RenderPicture. May generate a non-fatal
146 * test assertion failure.
148 void renderPicture(VAContextID, VABufferID *, int = 1);
151 * Convenience wrapper for i965_EndPicture. May generate a non-fatal
152 * test assertion failure.
154 void endPicture(VAContextID);
157 * Convenience wrapper for i965_DeriveImage. May generate a non-fatal
158 * test assertion failure.
160 void deriveImage(VASurfaceID, VAImage &);
163 * Convenience wrapper for i965_DestroyImage. May generate a non-fatal
164 * test assertion failure.
166 void destroyImage(VAImage &);
169 * Convenience wrapper for i965_SyncSurface. May generate a non-fatal
170 * test assertion failure.
172 void syncSurface(VASurfaceID);
175 * VADisplay implicit and explicit conversion operator.
177 inline operator VADisplay()
178 { return *I965TestEnvironment::instance(); }
181 * VADisplayContextP implict and explicit conversion operator.
183 inline operator VADisplayContextP()
184 { return *I965TestEnvironment::instance(); }
187 * VADriverContextP implict and explicit conversion operator.
189 inline operator VADriverContextP()
190 { return *I965TestEnvironment::instance(); }
193 * i965_driver_data * implict and explicit conversion operator.
195 inline operator struct i965_driver_data *()
196 { return *I965TestEnvironment::instance(); }