Fix validation in TexSubImage.
We weren't properly checking the x and y offsets against the texture
boundary, and were in some cases producing D3D errors with out-of-bounds
writes. This was popping up in IncompleteTextureTest. The test itself
was also bugged.
BUG=angle:610
Change-Id: Id58cac088fed03cae2aabbf00bce234f17208753
Reviewed-on: https://chromium-review.googlesource.com/195410
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/tests/angle_tests/TextureTest.cpp b/tests/angle_tests/TextureTest.cpp
new file mode 100644
index 0000000..701c020
--- /dev/null
+++ b/tests/angle_tests/TextureTest.cpp
@@ -0,0 +1,46 @@
+#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, &mTexture);
+
+ glBindTexture(GL_TEXTURE_2D, mTexture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ EXPECT_GL_NO_ERROR();
+
+ ASSERT_GL_NO_ERROR();
+ }
+
+ virtual void TearDown()
+ {
+ glDeleteTextures(1, &mTexture);
+
+ ANGLETest::TearDown();
+ }
+
+ GLuint mTexture;
+};
+
+TEST_F(TextureTest, negative_api_subimage)
+{
+ glBindTexture(GL_TEXTURE_2D, mTexture);
+ 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);
+}