Index: ui/gl/test/gl_image_test_template.h |
diff --git a/ui/gl/test/gl_image_test_template.h b/ui/gl/test/gl_image_test_template.h |
index 8533ce20c44d7c824e4e1fdf3e52d5935ae57406..e7b685d5700cd5338f4895540e98e6b4c4a2d97a 100644 |
--- a/ui/gl/test/gl_image_test_template.h |
+++ b/ui/gl/test/gl_image_test_template.h |
@@ -51,9 +51,51 @@ class GLImageTest : public testing::Test { |
TYPED_TEST_CASE_P(GLImageTest); |
-// Copy image to texture. Support is optional. Texels should be updated if |
-// supported, and left unchanged if not. |
-TYPED_TEST_P(GLImageTest, CopyTexSubImage) { |
+TYPED_TEST_P(GLImageTest, CreateAndDestroy) { |
+ const Size small_image_size(4, 4); |
+ const Size large_image_size(512, 512); |
+ const uint8_t image_color[] = {0, 0xff, 0, 0xff}; |
+ |
+ // Create a small solid color green image of preferred format. This must |
+ // succeed in order for a GLImage to be conformant. |
+ scoped_refptr<GLImage> small_image = this->delegate_.CreateSolidColorImage( |
+ small_image_size, GLImageTestSupport::GetPreferredInternalFormat(), |
+ GLImageTestSupport::GetPreferredBufferFormat(), image_color); |
+ ASSERT_TRUE(small_image); |
+ |
+ // Create a large solid color green image of preferred format. This must |
+ // succeed in order for a GLImage to be conformant. |
+ scoped_refptr<GLImage> large_image = this->delegate_.CreateSolidColorImage( |
+ large_image_size, GLImageTestSupport::GetPreferredInternalFormat(), |
+ GLImageTestSupport::GetPreferredBufferFormat(), image_color); |
+ ASSERT_TRUE(large_image); |
+ |
+ // Verify that image size is correct. |
+ EXPECT_EQ(small_image->GetSize().ToString(), small_image_size.ToString()); |
+ EXPECT_EQ(large_image->GetSize().ToString(), large_image_size.ToString()); |
+ |
+ // Verify that internal format is correct. |
+ EXPECT_EQ(small_image->GetInternalFormat(), |
+ GLImageTestSupport::GetPreferredInternalFormat()); |
+ EXPECT_EQ(large_image->GetInternalFormat(), |
+ GLImageTestSupport::GetPreferredInternalFormat()); |
+ |
+ // Verify that destruction of images work correctly both when we have a |
+ // context and when we don't. |
+ small_image->Destroy(true /* have_context */); |
+ large_image->Destroy(false /* have_context */); |
+} |
+ |
+// The GLImageTest test case verifies the behaviour that is expected from a |
+// GLImage in order to be conformant. |
+REGISTER_TYPED_TEST_CASE_P(GLImageTest, CreateAndDestroy); |
+ |
+template <typename GLImageTestDelegate> |
+class GLImageCopyTest : public GLImageTest<GLImageTestDelegate> {}; |
+ |
+TYPED_TEST_CASE_P(GLImageCopyTest); |
+ |
+TYPED_TEST_P(GLImageCopyTest, CopyTexImage) { |
const Size image_size(256, 256); |
const uint8_t image_color[] = {0, 0xff, 0, 0xff}; |
const uint8_t texture_color[] = {0, 0, 0xff, 0xff}; |
@@ -91,9 +133,9 @@ TYPED_TEST_P(GLImageTest, CopyTexSubImage) { |
GLImageTestSupport::GetPreferredInternalFormat(), |
GL_UNSIGNED_BYTE, pixels.get()); |
- // Attempt to copy |image| to |texture|. |
- // Returns true on success, false on failure. |
- bool rv = image->CopyTexSubImage(GL_TEXTURE_2D, Point(), Rect(image_size)); |
+ // Copy |image| to |texture|. |
+ bool rv = image->CopyTexImage(GL_TEXTURE_2D); |
+ EXPECT_TRUE(rv); |
// clang-format off |
const char kVertexShader[] = STRINGIZE( |
@@ -161,7 +203,7 @@ TYPED_TEST_P(GLImageTest, CopyTexSubImage) { |
// Draw |texture| to viewport and read back pixels to check expectations. |
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
GLTestHelper::CheckPixels(0, 0, image_size.width(), image_size.height(), |
- rv ? image_color : texture_color); |
+ image_color); |
// Clean up. |
glDeleteProgram(program); |
@@ -173,9 +215,9 @@ TYPED_TEST_P(GLImageTest, CopyTexSubImage) { |
image->Destroy(true); |
} |
-// The GLImageTest test case verifies behaviour that is expected from a |
-// GLImage in order to be conformant. |
-REGISTER_TYPED_TEST_CASE_P(GLImageTest, CopyTexSubImage); |
+// The GLImageCopyTest test case verifies that the GLImage implementation |
+// handles CopyTexImage correctly. |
+REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); |
} // namespace gfx |