diff options
-rw-r--r-- | ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc | 37 | ||||
-rw-r--r-- | ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html | 21 |
2 files changed, 42 insertions, 16 deletions
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc index aad9d72..63f1143 100644 --- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc +++ b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.cc @@ -1,13 +1,13 @@ -// Copyright (c) 2011 The Native Client Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Test cases for PPB_Graphics3D functions. // TODO(nfullagar): More comprehensive testing of the PPAPI interface. -#include <string.h> - #include <GLES2/gl2.h> +#include <string.h> +#include <sys/time.h> #include "native_client/src/include/nacl_macros.h" #include "native_client/src/shared/platform/nacl_check.h" @@ -34,7 +34,6 @@ namespace { const int kWidth = 320; const int kHeight = 200; - //////////////////////////////////////////////////////////////////////////////// // Test Cases //////////////////////////////////////////////////////////////////////////////// @@ -91,13 +90,21 @@ void TestIsGraphics3D() { TEST_PASSED; } +// Tests glInitializePPAPI. +void Test_glInitializePPAPI() { + GLboolean init_ppapi = glInitializePPAPI(ppb_get_interface()); + EXPECT(init_ppapi == true); + TEST_PASSED; +} + struct RenderInfo { PP_Resource graphics3d_id; int32_t frame_counter; int32_t frame_end; + int32_t frame_increment; }; -void SwapCallback(void* user_data, int32_t result) { +void TestSwapCallback(void* user_data, int32_t result) { EXPECT(result == PP_OK); RenderInfo* info = static_cast<RenderInfo *>(user_data); // Set graphics3d_id to the main context, so we can use normal gl style calls @@ -107,14 +114,16 @@ void SwapCallback(void* user_data, int32_t result) { float blue = float(info->frame_counter) / float(info->frame_end); glClearColor(0.0f, 0.0f, blue, 1.0f); glClear(GL_COLOR_BUFFER_BIT); - ++info->frame_counter; + info->frame_counter += info->frame_increment; if (info->frame_counter < info->frame_end) { - PP_CompletionCallback cc = PP_MakeCompletionCallback(SwapCallback, info); + PP_CompletionCallback cc = + PP_MakeCompletionCallback(TestSwapCallback, info); int32_t result = PPBGraphics3DDev()->SwapBuffers(info->graphics3d_id, cc); CHECK(PP_OK_COMPLETIONPENDING == result); } else { PPBCore()->ReleaseResource(info->graphics3d_id); delete info; + TEST_PASSED; } glSetCurrentContextPPAPI(0); } @@ -135,10 +144,16 @@ void TestSwapBuffers() { render_info->graphics3d_id = graphics3d_id; render_info->frame_counter = 0; render_info->frame_end = 256; - glInitializePPAPI(ppb_get_interface()); - PP_CompletionCallback cc = MakeTestableCompletionCallback( - "SwapBufferCallback", SwapCallback, render_info); + render_info->frame_increment = 2; + PP_CompletionCallback cc = PP_MakeCompletionCallback( + TestSwapCallback, render_info); PPBCore()->CallOnMainThread(0, cc, PP_OK); +} + +// Tests glTerminatePPAPI. +void Test_glTerminatePPAPI() { + GLboolean terminate = glTerminatePPAPI(); + EXPECT(terminate == true); TEST_PASSED; } @@ -149,7 +164,9 @@ void SetupTests() { RegisterTest("TestOpenGLES2Interface", TestOpenGLES2Interface); RegisterTest("TestCreate", TestCreate); RegisterTest("TestIsGraphics3D", TestIsGraphics3D); + RegisterTest("Test_glInitializePPAPI", Test_glInitializePPAPI); RegisterTest("TestSwapBuffers", TestSwapBuffers); + RegisterTest("Test_glTerminatePPAPI", Test_glTerminatePPAPI); } void SetupPluginInterfaces() { diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html index a3596d8..196747c 100644 --- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html +++ b/ppapi/native_client/tests/ppapi_browser/ppb_graphics3d/ppapi_ppb_graphics3d.html @@ -10,27 +10,36 @@ //<![CDATA[ function setupTests(tester, plugin) { function testAndAssertStatus(test, name, status) { + if (status === undefined) { + status = name + ":PASSED"; + } test.expectEvent(plugin, 'message', function(message) { - test.assertEqual(message.data, name + ':' + status); + test.assertEqual(message.data, status); test.pass(); }); plugin.postMessage(name); } tester.addAsyncTest('PPB_Graphics3D Interface', function(test) { - testAndAssertStatus(test, 'TestGraphics3DInterface', 'PASSED'); + testAndAssertStatus(test, 'TestGraphics3DInterface'); }); tester.addAsyncTest('PPB_OpenGLES2 Interface', function(test) { - testAndAssertStatus(test, 'TestOpenGLES2Interface', 'PASSED'); + testAndAssertStatus(test, 'TestOpenGLES2Interface'); }); tester.addAsyncTest('PPB_Graphics3D::Create', function(test) { - testAndAssertStatus(test, 'TestCreate', 'PASSED'); + testAndAssertStatus(test, 'TestCreate'); }); tester.addAsyncTest('PPB_Graphics3D::IsGraphics3D', function(test) { - testAndAssertStatus(test, 'TestIsGraphics3D', 'PASSED'); + testAndAssertStatus(test, 'TestIsGraphics3D'); + }); + tester.addAsyncTest('glInitializePPAPI', function(test) { + testAndAssertStatus(test, 'Test_glInitializePPAPI'); }); tester.addAsyncTest('PPB_Graphics3D::SwapBuffers', function(test) { - testAndAssertStatus(test, 'TestSwapBuffers', 'PASSED'); + testAndAssertStatus(test, 'TestSwapBuffers', 'TestSwapCallback:PASSED'); + }); + tester.addAsyncTest('glTerminatePPAPI', function(test) { + testAndAssertStatus(test, 'Test_glTerminatePPAPI'); }); } //]]> |