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

Side by Side Diff: gpu/command_buffer/service/test_helper.cc

Issue 2291753002: Prevent crash when using getExtension while a PBO is bound. (Closed)
Patch Set: work around the fact that a bunch of mocking tests pretend to test ES3 but don't Created 4 years, 3 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
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 "gpu/command_buffer/service/test_helper.h" 5 #include "gpu/command_buffer/service/test_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 16 matching lines...) Expand all
27 27
28 using ::testing::_; 28 using ::testing::_;
29 using ::testing::DoAll; 29 using ::testing::DoAll;
30 using ::testing::InSequence; 30 using ::testing::InSequence;
31 using ::testing::MatcherCast; 31 using ::testing::MatcherCast;
32 using ::testing::Pointee; 32 using ::testing::Pointee;
33 using ::testing::NotNull; 33 using ::testing::NotNull;
34 using ::testing::Return; 34 using ::testing::Return;
35 using ::testing::SetArrayArgument; 35 using ::testing::SetArrayArgument;
36 using ::testing::SetArgumentPointee; 36 using ::testing::SetArgumentPointee;
37 using ::testing::SetArgPointee;
37 using ::testing::StrEq; 38 using ::testing::StrEq;
38 using ::testing::StrictMock; 39 using ::testing::StrictMock;
39 40
40 namespace gpu { 41 namespace gpu {
41 namespace gles2 { 42 namespace gles2 {
42 43
43 namespace { 44 namespace {
44 45
45 template<typename T> 46 template<typename T>
46 T ConstructShaderVariable( 47 T ConstructShaderVariable(
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 EXPECT_CALL(*gl, DeleteTextures(TextureManager::kNumDefaultTextures, _)) 325 EXPECT_CALL(*gl, DeleteTextures(TextureManager::kNumDefaultTextures, _))
325 .Times(1) 326 .Times(1)
326 .RetiresOnSaturation(); 327 .RetiresOnSaturation();
327 } 328 }
328 329
329 void TestHelper::SetupContextGroupInitExpectations( 330 void TestHelper::SetupContextGroupInitExpectations(
330 ::gl::MockGLInterface* gl, 331 ::gl::MockGLInterface* gl,
331 const DisallowedFeatures& disallowed_features, 332 const DisallowedFeatures& disallowed_features,
332 const char* extensions, 333 const char* extensions,
333 const char* gl_version, 334 const char* gl_version,
335 ContextType context_type,
334 bool bind_generates_resource) { 336 bool bind_generates_resource) {
335 InSequence sequence; 337 InSequence sequence;
336 338
337 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version); 339 gl::GLVersionInfo gl_info(gl_version, "", extensions);
338 340
339 gl::GLVersionInfo gl_info(gl_version, "", extensions); 341 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version,
342 context_type, gl_info.is_es3);
Zhenyao Mo 2016/08/31 00:15:19 gl_info.is_es3 looks incorrect. It indicates whet
Kai Ninomiya 2016/08/31 00:47:59 Hm... okay. I can pass in that extra parameter eas
Zhenyao Mo 2016/08/31 00:51:40 Yeah that should be fine. In testing, if we specif
Kai Ninomiya 2016/08/31 01:11:17 Okay. I also quickly simulated removing `enable_es
Zhenyao Mo 2016/08/31 01:18:30 I am sorry you stepped on these issues. Such inco
340 343
341 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) 344 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _))
342 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) 345 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize))
343 .RetiresOnSaturation(); 346 .RetiresOnSaturation();
344 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || 347 if (strstr(extensions, "GL_EXT_framebuffer_multisample") ||
345 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || 348 strstr(extensions, "GL_EXT_multisampled_render_to_texture") ||
346 gl_info.is_es3 || gl_info.is_desktop_core_profile) { 349 gl_info.is_es3 || gl_info.is_desktop_core_profile) {
347 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) 350 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _))
348 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) 351 .WillOnce(SetArgumentPointee<1>(kMaxSamples))
349 .RetiresOnSaturation(); 352 .RetiresOnSaturation();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 .RetiresOnSaturation(); 464 .RetiresOnSaturation();
462 465
463 bool use_default_textures = bind_generates_resource; 466 bool use_default_textures = bind_generates_resource;
464 SetupTextureManagerInitExpectations( 467 SetupTextureManagerInitExpectations(
465 gl, false, gl_info.is_desktop_core_profile, extensions, 468 gl, false, gl_info.is_desktop_core_profile, extensions,
466 use_default_textures); 469 use_default_textures);
467 } 470 }
468 471
469 void TestHelper::SetupFeatureInfoInitExpectations(::gl::MockGLInterface* gl, 472 void TestHelper::SetupFeatureInfoInitExpectations(::gl::MockGLInterface* gl,
470 const char* extensions) { 473 const char* extensions) {
471 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", ""); 474 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", "",
475 CONTEXT_TYPE_OPENGLES2);
472 } 476 }
473 477
474 void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( 478 void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
475 ::gl::MockGLInterface* gl, 479 ::gl::MockGLInterface* gl,
476 const char* extensions, 480 const char* extensions,
477 const char* gl_renderer, 481 const char* gl_renderer,
478 const char* gl_version, 482 const char* gl_version,
483 ContextType context_type,
479 bool enable_es3) { 484 bool enable_es3) {
480 InSequence sequence; 485 InSequence sequence;
481 486
482 EXPECT_CALL(*gl, GetString(GL_VERSION)) 487 EXPECT_CALL(*gl, GetString(GL_VERSION))
483 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) 488 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version)))
484 .RetiresOnSaturation(); 489 .RetiresOnSaturation();
485 490
486 // Persistent storage is needed for the split extension string. 491 // Persistent storage is needed for the split extension string.
487 split_extensions_.clear(); 492 split_extensions_.clear();
488 if (extensions) { 493 if (extensions) {
(...skipping 18 matching lines...) Expand all
507 .RetiresOnSaturation(); 512 .RetiresOnSaturation();
508 } 513 }
509 514
510 EXPECT_CALL(*gl, GetString(GL_VERSION)) 515 EXPECT_CALL(*gl, GetString(GL_VERSION))
511 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) 516 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version)))
512 .RetiresOnSaturation(); 517 .RetiresOnSaturation();
513 EXPECT_CALL(*gl, GetString(GL_RENDERER)) 518 EXPECT_CALL(*gl, GetString(GL_RENDERER))
514 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_renderer))) 519 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_renderer)))
515 .RetiresOnSaturation(); 520 .RetiresOnSaturation();
516 521
522 if (!(context_type == CONTEXT_TYPE_WEBGL1 ||
523 context_type == CONTEXT_TYPE_OPENGLES2) &&
524 gl_info.is_es3_capable && enable_es3) {
525 EXPECT_CALL(*gl, GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, _))
526 .WillOnce(SetArgPointee<1>(0))
527 .RetiresOnSaturation();
528 }
529
517 if ((strstr(extensions, "GL_ARB_texture_float") || 530 if ((strstr(extensions, "GL_ARB_texture_float") ||
518 gl_info.is_desktop_core_profile) || 531 gl_info.is_desktop_core_profile) ||
519 (gl_info.is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) { 532 (gl_info.is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) {
520 static const GLuint tx_ids[] = {101, 102}; 533 static const GLuint tx_ids[] = {101, 102};
521 static const GLuint fb_ids[] = {103, 104}; 534 static const GLuint fb_ids[] = {103, 104};
522 const GLsizei width = 16; 535 const GLsizei width = 16;
523 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _)) 536 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _))
524 .WillOnce(SetArgumentPointee<1>(fb_ids[0])) 537 .WillOnce(SetArgumentPointee<1>(fb_ids[0]))
525 .RetiresOnSaturation(); 538 .RetiresOnSaturation();
526 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _)) 539 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _))
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 GLenum precision, 1193 GLenum precision,
1181 bool static_use, 1194 bool static_use,
1182 const std::string& name) { 1195 const std::string& name) {
1183 return ConstructShaderVariable<sh::OutputVariable>( 1196 return ConstructShaderVariable<sh::OutputVariable>(
1184 type, array_size, precision, static_use, name); 1197 type, array_size, precision, static_use, name);
1185 } 1198 }
1186 1199
1187 } // namespace gles2 1200 } // namespace gles2
1188 } // namespace gpu 1201 } // namespace gpu
1189 1202
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698