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

Side by Side Diff: ppapi/tests/test_graphics_3d.cc

Issue 14139012: PPAPI: More test cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Provide a message loop for "background thread" test so we can use a REQUIRED callback Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_graphics_2d.cc ('k') | ppapi/tests/test_host_resolver_private.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ppapi/tests/test_graphics_3d.h" 5 #include "ppapi/tests/test_graphics_3d.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 glSetCurrentContextPPAPI(kInvalidContext); 130 glSetCurrentContextPPAPI(kInvalidContext);
131 131
132 int32_t rv = SwapBuffersSync(&context); 132 int32_t rv = SwapBuffersSync(&context);
133 ASSERT_EQ(rv, PP_OK); 133 ASSERT_EQ(rv, PP_OK);
134 134
135 PASS(); 135 PASS();
136 } 136 }
137 137
138 int32_t TestGraphics3D::SwapBuffersSync(pp::Graphics3D* context) { 138 int32_t TestGraphics3D::SwapBuffersSync(pp::Graphics3D* context) {
139 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 139 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
140 int32_t rv = context->SwapBuffers(callback.GetCallback()); 140 callback.WaitForResult(context->SwapBuffers(callback.GetCallback()));
141 if (rv != PP_OK_COMPLETIONPENDING) 141 return callback.result();
142 return rv;
143
144 return callback.WaitForResult();
145 } 142 }
146 143
147 std::string TestGraphics3D::CheckPixelPPAPI( 144 std::string TestGraphics3D::CheckPixelPPAPI(
148 pp::Graphics3D* context, 145 pp::Graphics3D* context,
149 int x, int y, const uint8_t expected_color[4]) { 146 int x, int y, const uint8_t expected_color[4]) {
150 GLubyte pixel_color[4]; 147 GLubyte pixel_color[4];
151 opengl_es2_->ReadPixels(context->pp_resource(), 148 opengl_es2_->ReadPixels(context->pp_resource(),
152 x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); 149 x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color);
153 150
154 ASSERT_EQ(pixel_color[0], expected_color[0]); 151 ASSERT_EQ(pixel_color[0], expected_color[0]);
155 ASSERT_EQ(pixel_color[1], expected_color[1]); 152 ASSERT_EQ(pixel_color[1], expected_color[1]);
156 ASSERT_EQ(pixel_color[2], expected_color[2]); 153 ASSERT_EQ(pixel_color[2], expected_color[2]);
157 ASSERT_EQ(pixel_color[3], expected_color[3]); 154 ASSERT_EQ(pixel_color[3], expected_color[3]);
158 PASS(); 155 PASS();
159 } 156 }
160 157
161 std::string TestGraphics3D::CheckPixelGL( 158 std::string TestGraphics3D::CheckPixelGL(
162 int x, int y, const uint8_t expected_color[4]) { 159 int x, int y, const uint8_t expected_color[4]) {
163 GLubyte pixel_color[4]; 160 GLubyte pixel_color[4];
164 glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); 161 glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color);
165 162
166 ASSERT_EQ(pixel_color[0], expected_color[0]); 163 ASSERT_EQ(pixel_color[0], expected_color[0]);
167 ASSERT_EQ(pixel_color[1], expected_color[1]); 164 ASSERT_EQ(pixel_color[1], expected_color[1]);
168 ASSERT_EQ(pixel_color[2], expected_color[2]); 165 ASSERT_EQ(pixel_color[2], expected_color[2]);
169 ASSERT_EQ(pixel_color[3], expected_color[3]); 166 ASSERT_EQ(pixel_color[3], expected_color[3]);
170 PASS(); 167 PASS();
171 } 168 }
172 169
OLDNEW
« no previous file with comments | « ppapi/tests/test_graphics_2d.cc ('k') | ppapi/tests/test_host_resolver_private.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698