Hash :
b759a748
Author :
Date :
2014-07-17T10:40:49
Fix test class names to reflect their class-ness. Style guide dictates a camel case scheme for classes. Since the tests are actually classes, update their names to reflect that. Change-Id: Ib7422b6d8c5de8414765439704fc103eae8b2d63 Reviewed-on: https://chromium-review.googlesource.com/208680 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@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 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
#include "ANGLETest.h"
class TextureTest : public ANGLETest
{
protected:
TextureTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
virtual void SetUp()
{
ANGLETest::SetUp();
glGenTextures(1, &mTexture2D);
glGenTextures(1, &mTextureCube);
glBindTexture(GL_TEXTURE_2D, mTexture2D);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
EXPECT_GL_NO_ERROR();
glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
glTexStorage2DEXT(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 1, 1);
EXPECT_GL_NO_ERROR();
ASSERT_GL_NO_ERROR();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
attribute vec4 position;
varying vec2 texcoord;
void main()
{
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
}
);
const std::string fragmentShaderSource2D = SHADER_SOURCE
(
precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
}
);
const std::string fragmentShaderSourceCube = SHADER_SOURCE
(
precision highp float;
uniform sampler2D tex2D;
uniform samplerCube texCube;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex2D, texcoord);
gl_FragColor += textureCube(texCube, vec3(texcoord, 0));
}
);
m2DProgram = compileProgram(vertexShaderSource, fragmentShaderSource2D);
mCubeProgram = compileProgram(vertexShaderSource, fragmentShaderSourceCube);
if (m2DProgram == 0 || mCubeProgram == 0)
{
FAIL() << "shader compilation failed.";
}
mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex");
}
virtual void TearDown()
{
glDeleteTextures(1, &mTexture2D);
glDeleteTextures(1, &mTextureCube);
glDeleteProgram(m2DProgram);
glDeleteProgram(mCubeProgram);
ANGLETest::TearDown();
}
GLuint mTexture2D;
GLuint mTextureCube;
GLuint m2DProgram;
GLuint mCubeProgram;
GLint mTexture2DUniformLocation;
};
TEST_F(TextureTest, NegativeAPISubImage)
{
glBindTexture(GL_TEXTURE_2D, mTexture2D);
EXPECT_GL_ERROR(GL_NO_ERROR);
const GLubyte *pixels[20] = { 0 };
glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
EXPECT_GL_ERROR(GL_INVALID_VALUE);
}
TEST_F(TextureTest, ZeroSizedUploads)
{
glBindTexture(GL_TEXTURE_2D, mTexture2D);
EXPECT_GL_ERROR(GL_NO_ERROR);
// Use the texture first to make sure it's in video memory
glUseProgram(m2DProgram);
glUniform1i(mTexture2DUniformLocation, 0);
drawQuad(m2DProgram, "position", 0.5f);
const GLubyte *pixel[4] = { 0 };
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
EXPECT_GL_NO_ERROR();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
EXPECT_GL_NO_ERROR();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
EXPECT_GL_NO_ERROR();
}
// Test drawing with two texture types, to trigger an ANGLE bug in validation
TEST_F(TextureTest, CubeMapBug)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mTexture2D);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
EXPECT_GL_ERROR(GL_NO_ERROR);
glUseProgram(mCubeProgram);
GLint tex2DUniformLocation = glGetUniformLocation(mCubeProgram, "tex2D");
GLint texCubeUniformLocation = glGetUniformLocation(mCubeProgram, "texCube");
EXPECT_NE(-1, tex2DUniformLocation);
EXPECT_NE(-1, texCubeUniformLocation);
glUniform1i(tex2DUniformLocation, 0);
glUniform1i(texCubeUniformLocation, 1);
drawQuad(mCubeProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
}