Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Unified Diff: ui/gl/test/gl_image_test_template.h

Issue 1576353007: gl, ozone: add new GLImageBindTest unittests and make ozone run it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/test/gl_image_test_support.cc ('k') | ui/gl/test/run_all_unittests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 113fb69d53ddf1b89f14b35dc30040efcb9cc077..adcb2588034b4c1d0a4ae35a002d30bc71c9191a 100644
--- a/ui/gl/test/gl_image_test_template.h
+++ b/ui/gl/test/gl_image_test_template.h
@@ -210,6 +210,60 @@ TYPED_TEST_P(GLImageCopyTest, CopyTexImage) {
// handles CopyTexImage correctly.
REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage);
+template <typename GLImageTestDelegate>
+class GLImageBindTest : public GLImageTest<GLImageTestDelegate> {};
+
+TYPED_TEST_CASE_P(GLImageBindTest);
+
+TYPED_TEST_P(GLImageBindTest, BindTexImage) {
+ const gfx::Size image_size(256, 256);
+ const uint8_t image_color[] = {0x10, 0x20, 0, 0xff};
+
+ GLuint framebuffer =
+ GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height());
+ ASSERT_TRUE(framebuffer);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer);
+ glViewport(0, 0, image_size.width(), image_size.height());
+
+ GLuint program = this->CreateSingleTextureProgram();
+ GLuint vertex_buffer = gfx::GLHelper::SetupQuadVertexBuffer();
+
+ for (auto format : gfx::GetBufferFormatsForTesting()) {
+ if (!TypeParam::IsSupported(format)) {
+ continue;
+ }
+
+ // Create a solid color green image of preferred format. This must succeed
+ // in order for a GLImage to be conformant.
+ scoped_refptr<gl::GLImage> image =
+ this->delegate_.CreateSolidColorImage(image_size, format, image_color);
+ ASSERT_TRUE(image);
+
+ GLuint texture = GLTestHelper::CreateTexture(GL_TEXTURE_2D);
+
+ // Bind |image| to |texture|.
+ bool rv = image->BindTexImage(GL_TEXTURE_2D);
+ EXPECT_TRUE(rv);
+
+ // Draw |texture| to viewport and read back pixels to check expectations.
+ gfx::GLHelper::DrawQuad(vertex_buffer);
+
+ GLTestHelper::CheckPixels(0, 0, image_size.width(), image_size.height(),
+ image_color);
+
+ // Clean up.
+ glDeleteTextures(1, &texture);
+ image->Destroy(true);
+ }
+ glDeleteProgram(program);
+ glDeleteBuffersARB(1, &vertex_buffer);
+ glDeleteFramebuffersEXT(1, &framebuffer);
+}
+
+// The GLImageBindTest test case verifies that the GLImage implementation
+// handles BindTexImage correctly.
+REGISTER_TYPED_TEST_CASE_P(GLImageBindTest, BindTexImage);
+
} // namespace gl
#endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_
« no previous file with comments | « ui/gl/test/gl_image_test_support.cc ('k') | ui/gl/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698