| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Test cases for PPB_Graphics3D functions. | 5 // Test cases for PPB_Graphics3D functions. |
| 6 // TODO(nfullagar): More comprehensive testing of the PPAPI interface. | 6 // TODO(nfullagar): More comprehensive testing of the PPAPI interface. |
| 7 | 7 |
| 8 #include <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
| 9 #include <GLES2/gl2ext.h> |
| 9 #include <string.h> | 10 #include <string.h> |
| 10 #include <sys/time.h> | 11 #include <sys/time.h> |
| 11 | 12 |
| 12 #include "native_client/src/include/nacl_macros.h" | 13 #include "native_client/src/include/nacl_macros.h" |
| 13 #include "native_client/src/shared/platform/nacl_check.h" | 14 #include "native_client/src/shared/platform/nacl_check.h" |
| 14 #include "native_client/tests/ppapi_test_lib/get_browser_interface.h" | 15 #include "native_client/tests/ppapi_test_lib/get_browser_interface.h" |
| 15 #include "native_client/tests/ppapi_test_lib/internal_utils.h" | 16 #include "native_client/tests/ppapi_test_lib/internal_utils.h" |
| 16 #include "native_client/tests/ppapi_test_lib/test_interface.h" | 17 #include "native_client/tests/ppapi_test_lib/test_interface.h" |
| 17 #include "ppapi/c/dev/ppb_testing_dev.h" | 18 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 18 #include "ppapi/c/pp_bool.h" | 19 #include "ppapi/c/pp_bool.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 GLenum lastError = glGetError(); | 123 GLenum lastError = glGetError(); |
| 123 EXPECT(lastError == GL_NO_ERROR); | 124 EXPECT(lastError == GL_NO_ERROR); |
| 124 glEnable(GL_LINE_LOOP); | 125 glEnable(GL_LINE_LOOP); |
| 125 lastError = glGetError(); | 126 lastError = glGetError(); |
| 126 EXPECT(lastError == GL_INVALID_ENUM); | 127 EXPECT(lastError == GL_INVALID_ENUM); |
| 127 glSetCurrentContextPPAPI(0); | 128 glSetCurrentContextPPAPI(0); |
| 128 PPBCore()->ReleaseResource(graphics3d_id); | 129 PPBCore()->ReleaseResource(graphics3d_id); |
| 129 TEST_PASSED; | 130 TEST_PASSED; |
| 130 } | 131 } |
| 131 | 132 |
| 133 // Test basic extensions. |
| 134 // Simple test, mostly to see if extensions can compile, link, and return |
| 135 // something that makes sense without crashing. The build environment must |
| 136 // define GL_GLEXT_PROTOTYPES to enable this test. |
| 137 void TestBasicExtensions() { |
| 138 #if defined(GL_GLEXT_PROTOTYPES) |
| 139 int32_t attribs[] = { |
| 140 PP_GRAPHICS3DATTRIB_WIDTH, kWidth, |
| 141 PP_GRAPHICS3DATTRIB_HEIGHT, kHeight, |
| 142 PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 32, |
| 143 PP_GRAPHICS3DATTRIB_NONE}; |
| 144 PP_Resource graphics3d_id = PPBGraphics3D()-> |
| 145 Create(pp_instance(), kInvalidResource, attribs); |
| 146 EXPECT(graphics3d_id != kInvalidResource); |
| 147 glSetCurrentContextPPAPI(graphics3d_id); |
| 148 EXPECT(glGetString(GL_VERSION) != NULL); |
| 149 const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); |
| 150 if (strstr(ext, "GL_EXT_occlusion_query_boolean")) { |
| 151 GLuint a_query; |
| 152 glGenQueriesEXT(1, &a_query); |
| 153 EXPECT(0 != a_query); |
| 154 } |
| 155 if (strstr(ext, "GL_ANGLE_instanced_arrays")) { |
| 156 glDrawArraysInstancedANGLE(GL_TRIANGLE_STRIP, 0, 0, 0); |
| 157 } |
| 158 glSetCurrentContextPPAPI(0); |
| 159 PPBCore()->ReleaseResource(graphics3d_id); |
| 160 #endif |
| 161 TEST_PASSED; |
| 162 } |
| 163 |
| 164 |
| 132 struct RenderInfo { | 165 struct RenderInfo { |
| 133 PP_Resource graphics3d_id; | 166 PP_Resource graphics3d_id; |
| 134 int32_t frame_counter; | 167 int32_t frame_counter; |
| 135 int32_t frame_end; | 168 int32_t frame_end; |
| 136 int32_t frame_increment; | 169 int32_t frame_increment; |
| 137 }; | 170 }; |
| 138 | 171 |
| 139 void TestSwapCallback(void* user_data, int32_t result) { | 172 void TestSwapCallback(void* user_data, int32_t result) { |
| 140 EXPECT(result == PP_OK); | 173 EXPECT(result == PP_OK); |
| 141 RenderInfo* info = static_cast<RenderInfo *>(user_data); | 174 RenderInfo* info = static_cast<RenderInfo *>(user_data); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 301 |
| 269 } // namespace | 302 } // namespace |
| 270 | 303 |
| 271 void SetupTests() { | 304 void SetupTests() { |
| 272 RegisterTest("TestGraphics3DInterface", TestGraphics3DInterface); | 305 RegisterTest("TestGraphics3DInterface", TestGraphics3DInterface); |
| 273 RegisterTest("TestOpenGLES2Interface", TestOpenGLES2Interface); | 306 RegisterTest("TestOpenGLES2Interface", TestOpenGLES2Interface); |
| 274 RegisterTest("TestCreate", TestCreate); | 307 RegisterTest("TestCreate", TestCreate); |
| 275 RegisterTest("TestIsGraphics3D", TestIsGraphics3D); | 308 RegisterTest("TestIsGraphics3D", TestIsGraphics3D); |
| 276 RegisterTest("Test_glInitializePPAPI", Test_glInitializePPAPI); | 309 RegisterTest("Test_glInitializePPAPI", Test_glInitializePPAPI); |
| 277 RegisterTest("TestBasicSetup", TestBasicSetup); | 310 RegisterTest("TestBasicSetup", TestBasicSetup); |
| 311 RegisterTest("TestBasicExtensions", TestBasicExtensions); |
| 278 RegisterTest("TestSwapBuffers", TestSwapBuffers); | 312 RegisterTest("TestSwapBuffers", TestSwapBuffers); |
| 279 RegisterTest("TestResizeBuffersWithoutDepthBuffer", | 313 RegisterTest("TestResizeBuffersWithoutDepthBuffer", |
| 280 TestResizeBuffersWithoutDepthBuffer); | 314 TestResizeBuffersWithoutDepthBuffer); |
| 281 RegisterTest("TestResizeBuffersWithDepthBuffer", | 315 RegisterTest("TestResizeBuffersWithDepthBuffer", |
| 282 TestResizeBuffersWithDepthBuffer); | 316 TestResizeBuffersWithDepthBuffer); |
| 283 RegisterTest("Test_glTerminatePPAPI", Test_glTerminatePPAPI); | 317 RegisterTest("Test_glTerminatePPAPI", Test_glTerminatePPAPI); |
| 284 } | 318 } |
| 285 | 319 |
| 286 void SetupPluginInterfaces() { | 320 void SetupPluginInterfaces() { |
| 287 // none | 321 // none |
| 288 } | 322 } |
| OLD | NEW |