summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 16:31:39 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 16:31:39 +0000
commitd44d52b8a787af00a09e7f34f7a606c783782666 (patch)
treec579df76a5c2ee2e12caa951f4698f2d43704787
parentdb88c583c6a810bd87c73d3af0b9bcf82eba6f00 (diff)
downloadchromium_src-d44d52b8a787af00a09e7f34f7a606c783782666.zip
chromium_src-d44d52b8a787af00a09e7f34f7a606c783782666.tar.gz
chromium_src-d44d52b8a787af00a09e7f34f7a606c783782666.tar.bz2
Added a simple smoke test for Graphics3D. It attempts to exercise the entire graphics-3d pipeline modulo compositor.
BUG=93809 Review URL: http://codereview.chromium.org/7818004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99387 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/ppapi_tests.gypi3
-rw-r--r--ppapi/tests/test_graphics_3d.cc60
-rw-r--r--ppapi/tests/test_graphics_3d.h17
3 files changed, 73 insertions, 7 deletions
diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi
index b3dcb05..1f889b4 100644
--- a/ppapi/ppapi_tests.gypi
+++ b/ppapi/ppapi_tests.gypi
@@ -60,6 +60,9 @@
{
'target_name': 'ppapi_tests',
'type': 'loadable_module',
+ 'include_dirs': [
+ 'lib/gl/include',
+ ],
'sources': [
# Common test files.
'tests/test_case.cc',
diff --git a/ppapi/tests/test_graphics_3d.cc b/ppapi/tests/test_graphics_3d.cc
index 3f86e19..3035abf 100644
--- a/ppapi/tests/test_graphics_3d.cc
+++ b/ppapi/tests/test_graphics_3d.cc
@@ -4,20 +4,72 @@
#include "ppapi/tests/test_graphics_3d.h"
-#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
+#include <GLES2/gl2.h>
+
#include "ppapi/c/dev/ppb_opengles_dev.h"
+#include "ppapi/c/dev/ppb_testing_dev.h"
+#include "ppapi/cpp/dev/graphics_3d_dev.h"
#include "ppapi/cpp/module.h"
+#include "ppapi/tests/test_utils.h"
+#include "ppapi/tests/testing_instance.h"
REGISTER_TEST_CASE(Graphics3D);
bool TestGraphics3D::Init() {
- graphics_3d_ = reinterpret_cast<const PPB_Graphics3D_Dev*>(
- pp::Module::Get()->GetBrowserInterface(PPB_GRAPHICS_3D_DEV_INTERFACE));
opengl_es2_ = reinterpret_cast<const PPB_OpenGLES2_Dev*>(
pp::Module::Get()->GetBrowserInterface(PPB_OPENGLES2_DEV_INTERFACE));
- return graphics_3d_ && opengl_es2_ && InitTestingInterface();
+ return opengl_es2_ && InitTestingInterface();
}
void TestGraphics3D::RunTest() {
+ RUN_TEST(Frame);
+}
+
+std::string TestGraphics3D::TestFrame() {
+ const int width = 16;
+ const int height = 16;
+ const int32_t attribs[] = {
+ PP_GRAPHICS3DATTRIB_WIDTH, width,
+ PP_GRAPHICS3DATTRIB_HEIGHT, height,
+ PP_GRAPHICS3DATTRIB_NONE
+ };
+ pp::Graphics3D_Dev context(*instance_, pp::Graphics3D_Dev(), attribs);
+ ASSERT_FALSE(context.is_null());
+
+ // Clear color buffer to opaque red.
+ opengl_es2_->ClearColor(context.pp_resource(), 1.0f, 0.0f, 0.0f, 1.0f);
+ opengl_es2_->Clear(context.pp_resource(), GL_COLOR_BUFFER_BIT);
+ // Check if the color buffer has opaque red.
+ const uint8_t red_color[4] = {255, 0, 0, 255};
+ std::string error = TestPixel(&context, width/2, height/2, red_color);
+ if (!error.empty())
+ return error;
+
+ int32_t rv = SwapBuffersSync(&context);
+ ASSERT_EQ(rv, PP_OK);
+ PASS();
+}
+
+int32_t TestGraphics3D::SwapBuffersSync(pp::Graphics3D_Dev* context) {
+ TestCompletionCallback callback(instance_->pp_instance(), true);
+ int32_t rv = context->SwapBuffers(callback);
+ if (rv != PP_OK_COMPLETIONPENDING)
+ return rv;
+
+ return callback.WaitForResult();
+}
+
+std::string TestGraphics3D::TestPixel(
+ pp::Graphics3D_Dev* context,
+ int x, int y, const uint8_t expected_color[4]) {
+ GLubyte pixel_color[4];
+ opengl_es2_->ReadPixels(context->pp_resource(),
+ x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color);
+
+ ASSERT_EQ(pixel_color[0], expected_color[0]);
+ ASSERT_EQ(pixel_color[1], expected_color[1]);
+ ASSERT_EQ(pixel_color[2], expected_color[2]);
+ ASSERT_EQ(pixel_color[3], expected_color[3]);
+ PASS();
}
diff --git a/ppapi/tests/test_graphics_3d.h b/ppapi/tests/test_graphics_3d.h
index 34eacd0..444716f 100644
--- a/ppapi/tests/test_graphics_3d.h
+++ b/ppapi/tests/test_graphics_3d.h
@@ -5,11 +5,15 @@
#ifndef PAPPI_TESTS_TEST_GRAPHICS_3D_H_
#define PAPPI_TESTS_TEST_GRAPHICS_3D_H_
+#include <string>
#include "ppapi/tests/test_case.h"
-struct PPB_Graphics3D_Dev;
struct PPB_OpenGLES2_Dev;
+namespace pp {
+class Graphics3D_Dev;
+} // namespace pp
+
class TestGraphics3D : public TestCase {
public:
TestGraphics3D(TestingInstance* instance) : TestCase(instance) {}
@@ -19,8 +23,15 @@ class TestGraphics3D : public TestCase {
virtual void RunTest();
private:
- // Used by the tests that access the C API directly.
- const PPB_Graphics3D_Dev* graphics_3d_;
+ // Various tests.
+ std::string TestFrame();
+
+ // Utils used by various tests.
+ int32_t SwapBuffersSync(pp::Graphics3D_Dev* context);
+ std::string TestPixel(pp::Graphics3D_Dev* context,
+ int x, int y, const uint8_t expected_color[4]);
+
+ // OpenGL ES2 interface.
const PPB_OpenGLES2_Dev* opengl_es2_;
};