chromium/third_party/angle/src/tests/test_utils/ANGLETest.h

//
// Copyright 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ANGLETest:
//   Implementation of common ANGLE testing fixture.
//

#ifndef ANGLE_TESTS_ANGLE_TEST_H_
#define ANGLE_TESTS_ANGLE_TEST_H_

#include <gtest/gtest.h>
#include <algorithm>
#include <array>

#include "RenderDoc.h"
#include "angle_test_configs.h"
#include "angle_test_platform.h"
#include "common/angleutils.h"
#include "common/system_utils.h"
#include "common/vector_utils.h"
#include "platform/PlatformMethods.h"
#include "util/EGLWindow.h"
#include "util/shader_utils.h"
#include "util/util_gl.h"

namespace angle
{
struct SystemInfo;
class RNG;
}  // namespace angle

#define ASSERT_GL_TRUE(a)
#define ASSERT_GL_FALSE(a)
#define EXPECT_GL_TRUE(a)
#define EXPECT_GL_FALSE(a)

#define EXPECT_GL_ERROR(err)
#define EXPECT_GL_NO_ERROR()

#define ASSERT_GL_ERROR(err)
#define ASSERT_GL_NO_ERROR()

#define EXPECT_EGL_ERROR(err)
#define EXPECT_EGL_SUCCESS()

// EGLBoolean is |unsigned int| but EGL_TRUE is 0, not 0u.
#define ASSERT_EGL_TRUE(a)
#define ASSERT_EGL_FALSE(a)
#define EXPECT_EGL_TRUE(a)
#define EXPECT_EGL_FALSE(a)

#define ASSERT_EGL_ERROR(err)
#define ASSERT_EGL_SUCCESS()

#define ASSERT_GLENUM_EQ(expected, actual)
#define EXPECT_GLENUM_EQ(expected, actual)
#define ASSERT_GLENUM_NE(expected, actual)
#define EXPECT_GLENUM_NE(expected, actual)

testing::AssertionResult AssertEGLEnumsEqual(const char *lhsExpr,
                                             const char *rhsExpr,
                                             EGLenum lhs,
                                             EGLenum rhs);

#define ASSERT_EGLENUM_EQ(expected, actual)
#define EXPECT_EGLENUM_EQ(expected, actual)

#define ASSERT_GL_FRAMEBUFFER_COMPLETE(framebuffer)
#define EXPECT_GL_FRAMEBUFFER_COMPLETE(framebuffer)

namespace angle
{
struct GLColorRGB
{};

struct GLColorRG
{};

struct GLColorR
{};

struct GLColor
{};

template <typename T>
struct GLColorT
{};

GLColor16;
GLColor32F;
GLColor32I;
GLColor32UI;

static constexpr GLColor32F kFloatBlack =;
static constexpr GLColor32F kFloatRed   =;
static constexpr GLColor32F kFloatGreen =;
static constexpr GLColor32F kFloatBlue  =;

// The input here for pixelPoints are the expected integer window coordinates, we add .5 to every
// one of them and re-scale the numbers to be between [-1,1]. Using this technique, we can make
// sure the rasterization stage will end up drawing pixels at the expected locations.
void CreatePixelCenterWindowCoords(const std::vector<Vector2> &pixelPoints,
                                   int windowWidth,
                                   int windowHeight,
                                   std::vector<Vector3> *outVertices);

// Useful to cast any type to GLubyte.
template <typename TR, typename TG, typename TB, typename TA>
GLColor MakeGLColor(TR r, TG g, TB b, TA a)
{}

GLColor RandomColor(angle::RNG *rng);

bool operator==(const GLColor &a, const GLColor &b);
bool operator!=(const GLColor &a, const GLColor &b);
std::ostream &operator<<(std::ostream &ostream, const GLColor &color);
GLColor ReadColor(GLint x, GLint y);

bool operator==(const GLColorRGB &a, const GLColorRGB &b);
bool operator!=(const GLColorRGB &a, const GLColorRGB &b);
std::ostream &operator<<(std::ostream &ostream, const GLColorRGB &color);

// Useful to cast any type to GLfloat.
template <typename TR, typename TG, typename TB, typename TA>
GLColor32F MakeGLColor32F(TR r, TG g, TB b, TA a)
{}

template <typename T>
bool operator==(const GLColorT<T> &a, const GLColorT<T> &b)
{}

std::ostream &operator<<(std::ostream &ostream, const GLColor32F &color);
GLColor32F ReadColor32F(GLint x, GLint y);

constexpr std::array<GLenum, 6> kCubeFaces =;

void LoadEntryPointsWithUtilLoader(angle::GLESDriverType driver);

bool IsFormatEmulated(GLenum target);
}  // namespace angle

#define EXPECT_PIXEL_EQ(x, y, r, g, b, a)

#define EXPECT_PIXEL_NE(x, y, r, g, b, a)

#define EXPECT_PIXEL_32F_EQ(x, y, r, g, b, a)

#define EXPECT_PIXEL_ALPHA_EQ(x, y, a)

#define EXPECT_PIXEL_ALPHA_NEAR(x, y, a, abs_error)

#define EXPECT_PIXEL_ALPHA32F_EQ(x, y, a)

#define EXPECT_PIXEL_COLOR_EQ(x, y, angleColor)
#define EXPECT_PIXEL_COLOR_EQ_VEC2(vec2, angleColor)

#define EXPECT_PIXEL_COLOR32F_EQ(x, y, angleColor)

#define EXPECT_PIXEL_RECT_T_EQ(T, x, y, width, height, format, type, color)

#define EXPECT_PIXEL_RECT_EQ(x, y, width, height, color)

#define EXPECT_PIXEL_RECT32F_EQ(x, y, width, height, color)

#define EXPECT_PIXEL_RECT32I_EQ(x, y, width, height, color)

#define EXPECT_PIXEL_RECT32UI_EQ(x, y, width, height, color)

#define EXPECT_PIXEL_NEAR_HELPER(x, y, r, g, b, a, abs_error, ctype, format, type)

#define EXPECT_PIXEL_EQ_HELPER(x, y, r, g, b, a, ctype, format, type)

#define EXPECT_PIXEL_NEAR(x, y, r, g, b, a, abs_error)

#define EXPECT_PIXEL_16_NEAR(x, y, r, g, b, a, abs_error)

#define EXPECT_PIXEL_8S_NEAR(x, y, r, g, b, a, abs_error)

#define EXPECT_PIXEL_16S_NEAR(x, y, r, g, b, a, abs_error)

#define EXPECT_PIXEL_32F_NEAR(x, y, r, g, b, a, abs_error)

#define EXPECT_PIXEL_8I(x, y, r, g, b, a)

#define EXPECT_PIXEL_8UI(x, y, r, g, b, a)

#define EXPECT_PIXEL_32UI(x, y, r, g, b, a)

#define EXPECT_PIXEL_32I(x, y, r, g, b, a)

#define EXPECT_PIXEL_32UI_COLOR(x, y, color)

#define EXPECT_PIXEL_32I_COLOR(x, y, color)

// TODO(jmadill): Figure out how we can use GLColor's nice printing with EXPECT_NEAR.
#define EXPECT_PIXEL_COLOR_NEAR(x, y, angleColor, abs_error)

#define EXPECT_PIXEL_COLOR16_NEAR(x, y, angleColor, abs_error)

#define EXPECT_PIXEL_COLOR32F_NEAR(x, y, angleColor, abs_error)

#define EXPECT_COLOR_NEAR(expected, actual, abs_error)
#define EXPECT_PIXEL32F_NEAR(x, y, r, g, b, a, abs_error)

#define EXPECT_PIXEL_COLOR32F_NEAR(x, y, angleColor, abs_error)

#define EXPECT_PIXEL_STENCIL_EQ(x, y, expected)

class ANGLETestBase;
class EGLWindow;
class GLWindowBase;
class OSWindow;
class WGLWindow;

struct TestPlatformContext final : private angle::NonCopyable
{};

class ANGLETestBase
{};

template <typename Params = angle::PlatformParameters>
class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<Params>
{};

enum class APIExtensionVersion
{};

template <typename Params>
ANGLETest<Params>::ANGLETest()
    :{}

template <>
inline ANGLETest<angle::PlatformParameters>::ANGLETest() :{}

class ANGLETestEnvironment : public testing::Environment
{};

extern angle::PlatformMethods gDefaultPlatformMethods;

#endif  // ANGLE_TESTS_ANGLE_TEST_H_