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(),
81 const VAStatus = VA_STATUS_SUCCESS);
84 * Convenience wrapper for i965_DestroyConfig. May generate a non-fatal
85 * test assertion failure.
87 void destroyConfig(VAConfigID);
90 * Convenience wrapper for i965_CreateContext. May generate a non-fatal
91 * test assertion failure.
93 VAContextID createContext(VAConfigID, int, int, int = 0,
94 const Surfaces& = Surfaces());
97 * Convenience wrapper for i965_DestroyContext. May generate a non-fatal
98 * test assertion failure.
100 void destroyContext(VAContextID);
103 * Convenience wrapper for i965_CreateBuffer. May generate a non-fatal
104 * test assertion failure.
106 VABufferID createBuffer(
107 VAContextID, VABufferType, unsigned, unsigned = 1, const void * = NULL);
110 * Convenience wrapper for i965_DestroyBuffer. May generate a non-fatal
111 * test assertion failure.
113 void destroyBuffer(VABufferID);
116 * Convenience wrapper for i965_MapBuffer. May generate a non-fatal
117 * test assertion failure.
120 T* mapBuffer(VABufferID id)
124 i965_MapBuffer(*this, id, (void**)&data));
130 * Convenience Wrapper for i965_UnmapBuffer. May generate a non-fatal
131 * test assertion failure.
133 void unmapBuffer(VABufferID id)
136 i965_UnmapBuffer(*this, id));
140 * Convenience wrapper for i965_BeginPicture. May generate a non-fatal
141 * test assertion failure.
143 void beginPicture(VAContextID, VASurfaceID);
146 * Convenience wrapper for i965_RenderPicture. May generate a non-fatal
147 * test assertion failure.
149 void renderPicture(VAContextID, VABufferID *, int = 1);
152 * Convenience wrapper for i965_EndPicture. May generate a non-fatal
153 * test assertion failure.
155 void endPicture(VAContextID);
158 * Convenience wrapper for i965_DeriveImage. May generate a non-fatal
159 * test assertion failure.
161 void deriveImage(VASurfaceID, VAImage &);
164 * Convenience wrapper for i965_DestroyImage. May generate a non-fatal
165 * test assertion failure.
167 void destroyImage(VAImage &);
170 * Convenience wrapper for i965_SyncSurface. May generate a non-fatal
171 * test assertion failure.
173 void syncSurface(VASurfaceID);
176 * VADisplay implicit and explicit conversion operator.
178 inline operator VADisplay()
179 { return *I965TestEnvironment::instance(); }
182 * VADisplayContextP implict and explicit conversion operator.
184 inline operator VADisplayContextP()
185 { return *I965TestEnvironment::instance(); }
188 * VADriverContextP implict and explicit conversion operator.
190 inline operator VADriverContextP()
191 { return *I965TestEnvironment::instance(); }
194 * i965_driver_data * implict and explicit conversion operator.
196 inline operator struct i965_driver_data *()
197 { return *I965TestEnvironment::instance(); }