1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
/*
* Copyright (C) 2016 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef I965_TEST_FIXTURE_H
#define I965_TEST_FIXTURE_H
#include "i965_test_environment.h"
#include <string>
#include <vector>
typedef std::vector<VASurfaceID> Surfaces;
typedef std::vector<VASurfaceAttrib> SurfaceAttribs;
typedef std::vector<VAConfigAttrib> ConfigAttribs;
typedef std::vector<VABufferID> Buffers;
/**
* This test fixture defines various operators to make it implicitly convertible
* to a VADriverContextP, VADisplay, VADisplayContextP, and i965_driver_data*.
* Other operators may be defined, too. These operators allow an instance of
* the test fixture to be passed to various driver functions that take one of
* those parameter types. Various driver functions are also wrapped by this
* test fixture to simplify writing test cases.
*
* Test cases that wish to use this fixture should define their own test
* fixture class that derives from this one.
*
* See the "Test Fixtures" section in gtest/docs/Primer.md for more details
* on how test fixtures are used.
*/
class I965TestFixture
: public ::testing::Test
{
public:
virtual ~I965TestFixture() { }
const std::string getFullTestName() const;
/**
* Convenience wrapper for i965_CreateSurfaces or i965_CreateSurfaces2.
* If SurfaceAttribs are specified then i965_CreateSurfaces2 is used,
* otherwise i965_CreateSurfaces is used. May generate a non-fatal test
* assertion failure.
*/
Surfaces createSurfaces(int w, int h, int format, size_t count = 1,
const SurfaceAttribs& = SurfaceAttribs());
/**
* Convenience wrapper for i965_DestroySurfaces. May generate a non-fatal
* test assertion failure.
*/
void destroySurfaces(Surfaces&);
/**
* Convenience wrapper for i965_CreateConfig. May generate a non-fatal
* test assertion failure.
*/
VAConfigID createConfig(VAProfile, VAEntrypoint,
const ConfigAttribs& = ConfigAttribs(),
const VAStatus = VA_STATUS_SUCCESS);
/**
* Convenience wrapper for i965_DestroyConfig. May generate a non-fatal
* test assertion failure.
*/
void destroyConfig(VAConfigID);
/**
* Convenience wrapper for i965_CreateContext. May generate a non-fatal
* test assertion failure.
*/
VAContextID createContext(VAConfigID, int, int, int = 0,
const Surfaces& = Surfaces());
/**
* Convenience wrapper for i965_DestroyContext. May generate a non-fatal
* test assertion failure.
*/
void destroyContext(VAContextID);
/**
* Convenience wrapper for i965_CreateBuffer. May generate a non-fatal
* test assertion failure.
*/
VABufferID createBuffer(
VAContextID, VABufferType, unsigned, unsigned = 1, const void * = NULL);
/**
* Convenience wrapper for i965_DestroyBuffer. May generate a non-fatal
* test assertion failure.
*/
void destroyBuffer(VABufferID);
/**
* Convenience wrapper for i965_MapBuffer. May generate a non-fatal
* test assertion failure.
*/
template<typename T>
T* mapBuffer(VABufferID id)
{
T* data = NULL;
EXPECT_STATUS(
i965_MapBuffer(*this, id, (void**)&data));
EXPECT_PTR(data);
return data;
}
/**
* Convenience Wrapper for i965_UnmapBuffer. May generate a non-fatal
* test assertion failure.
*/
void unmapBuffer(VABufferID id)
{
EXPECT_STATUS(
i965_UnmapBuffer(*this, id));
}
/**
* Convenience wrapper for i965_BeginPicture. May generate a non-fatal
* test assertion failure.
*/
void beginPicture(VAContextID, VASurfaceID);
/**
* Convenience wrapper for i965_RenderPicture. May generate a non-fatal
* test assertion failure.
*/
void renderPicture(VAContextID, VABufferID *, int = 1);
/**
* Convenience wrapper for i965_EndPicture. May generate a non-fatal
* test assertion failure.
*/
void endPicture(VAContextID);
/**
* Convenience wrapper for i965_DeriveImage. May generate a non-fatal
* test assertion failure.
*/
void deriveImage(VASurfaceID, VAImage &);
/**
* Convenience wrapper for i965_DestroyImage. May generate a non-fatal
* test assertion failure.
*/
void destroyImage(VAImage &);
/**
* Convenience wrapper for i965_SyncSurface. May generate a non-fatal
* test assertion failure.
*/
void syncSurface(VASurfaceID);
/**
* VADisplay implicit and explicit conversion operator.
*/
inline operator VADisplay()
{ return *I965TestEnvironment::instance(); }
/**
* VADisplayContextP implict and explicit conversion operator.
*/
inline operator VADisplayContextP()
{ return *I965TestEnvironment::instance(); }
/**
* VADriverContextP implict and explicit conversion operator.
*/
inline operator VADriverContextP()
{ return *I965TestEnvironment::instance(); }
/**
* i965_driver_data * implict and explicit conversion operator.
*/
inline operator struct i965_driver_data *()
{ return *I965TestEnvironment::instance(); }
};
#endif
|