Hash :
bb134678
Author :
Date :
2013-10-23T13:06:46
Added a gtest environment class to initialize the ANGLETest class window. Change-Id: I6fa59201364960cc8fe1cb44e2d09a14cf61dd8a Reviewed-on: https://chromium-review.googlesource.com/179352 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Commit-Queue: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
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
//
// Copyright (c) 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.
//
#ifndef ANGLE_TESTS_ANGLE_TEST_H_
#define ANGLE_TESTS_ANGLE_TEST_H_
#include "gtest/gtest.h"
#define GL_GLEXT_PROTOTYPES
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#define EXPECT_GL_ERROR(err) EXPECT_EQ(glGetError(), (err))
#define EXPECT_GL_NO_ERROR() EXPECT_GL_ERROR(GL_NO_ERROR)
#define ASSERT_GL_ERROR(err) EXPECT_EQ(glGetError(), (err))
#define ASSERT_GL_NO_ERROR() ASSERT_GL_ERROR(GL_NO_ERROR)
#define EXPECT_PIXEL_EQ(x, y, r, g, b, a) \
{ \
GLubyte pixel[4]; \
glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); \
EXPECT_GL_NO_ERROR(); \
EXPECT_EQ(pixel[0], (r)); \
EXPECT_EQ(pixel[1], (g)); \
EXPECT_EQ(pixel[2], (b)); \
EXPECT_EQ(pixel[3], (a)); \
}
#define SHADER_SOURCE(...) #__VA_ARGS__
class ANGLETest : public testing::Test
{
protected:
ANGLETest();
public:
static bool InitTestWindow();
static bool DestroyTestWindow();
static bool ReizeWindow(int width, int height);
protected:
virtual void SetUp();
virtual void TearDown();
virtual void swapBuffers();
static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth);
static GLuint compileShader(GLenum type, const std::string &source);
static GLuint compileProgram(const std::string &vsSource, const std::string &fsSource);
static bool extensionEnabled(const std::string &extName);
void setClientVersion(int clientVersion);
void setWindowWidth(int width);
void setWindowHeight(int height);
void setConfigRedBits(int bits);
void setConfigGreenBits(int bits);
void setConfigBlueBits(int bits);
void setConfigAlphaBits(int bits);
void setConfigDepthBits(int bits);
void setConfigStencilBits(int bits);
void setMultisampleEnabled(bool enabled);
int getClientVersion() const;
int getWindowWidth() const;
int getWindowHeight() const;
int getConfigRedBits() const;
int getConfigGreenBits() const;
int getConfigBlueBits() const;
int getConfigAlphaBits() const;
int getConfigDepthBits() const;
int getConfigStencilBits() const;
bool isMultisampleEnabled() const;
private:
bool createEGLContext();
bool destroyEGLContext();
int mClientVersion;
int mWidth;
int mHeight;
int mRedBits;
int mGreenBits;
int mBlueBits;
int mAlphaBits;
int mDepthBits;
int mStencilBits;
bool mMultisample;
EGLConfig mConfig;
EGLSurface mSurface;
EGLContext mContext;
static EGLDisplay mDisplay;
static EGLNativeWindowType mNativeWindow;
static EGLNativeDisplayType mNativeDisplay;
};
class ANGLETestEnvironment : public testing::Environment
{
public:
virtual void SetUp();
virtual void TearDown();
};
#endif // ANGLE_TESTS_ANGLE_TEST_H_