1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif
#include <stddef.h>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/context_state.h"
#include "gpu/command_buffer/service/gl_surface_mock.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/mocks.h"
#include "gpu/command_buffer/service/program_manager.h"
#include "gpu/command_buffer/service/test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_mock.h"
#include "ui/gl/gl_surface_stub.h"
#if !defined(GL_DEPTH24_STENCIL8)
#define GL_DEPTH24_STENCIL8 0x88F0
#endif
using ::gl::MockGLInterface;
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::MatcherCast;
using ::testing::Mock;
using ::testing::Pointee;
using ::testing::Return;
using ::testing::SaveArg;
using ::testing::SetArrayArgument;
using ::testing::SetArgPointee;
using ::testing::SetArgPointee;
using ::testing::StrEq;
using ::testing::StrictMock;
namespace gpu {
namespace gles2 {
TEST_P(GLES2DecoderTest, DisableVertexAttribArrayValidArgs) {
SetDriverVertexAttribEnabled(1, false);
SpecializedSetup<cmds::DisableVertexAttribArray, 0>(true);
cmds::DisableVertexAttribArray cmd;
cmd.Init(1);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_P(GLES2DecoderTest, EnableVertexAttribArrayValidArgs) {
SetDriverVertexAttribEnabled(1, true);
SpecializedSetup<cmds::EnableVertexAttribArray, 0>(true);
cmds::EnableVertexAttribArray cmd;
cmd.Init(1);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_P(GLES2DecoderWithShaderTest, EnabledVertexAttribArrayIsDisabledIfUnused) {
SetupExpectationsForApplyingDefaultDirtyState();
// Set up and enable attribs 0, 1, 2
SetupAllNeededVertexBuffers();
// Enable attrib 3, and verify it's called in the driver
{
EXPECT_CALL(*gl_, EnableVertexAttribArray(3))
.Times(1)
.RetiresOnSaturation();
cmds::EnableVertexAttribArray cmd;
cmd.Init(3);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
}
DoVertexAttribPointer(3, 2, GL_FLOAT, 0, 0);
// Expect the draw call below causes attrib 3 to be disabled in the driver
EXPECT_CALL(*gl_, DisableVertexAttribArray(3)).Times(1).RetiresOnSaturation();
// Perform a draw which uses only attributes 0, 1, 2 - not attrib 3
{
EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
.Times(1)
.RetiresOnSaturation();
cmds::DrawArrays cmd;
cmd.Init(GL_TRIANGLES, 0, kNumVertices);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
}
TEST_P(GLES2DecoderWithShaderTest, GetVertexAttribPointervSucceeds) {
const GLuint kOffsetToTestFor = sizeof(float) * 4;
const GLuint kIndexToTest = 1;
auto* result = static_cast<cmds::GetVertexAttribPointerv::Result*>(
shared_memory_address_);
result->size = 0;
const GLuint* result_value = result->GetData();
// Test that initial value is 0.
cmds::GetVertexAttribPointerv cmd;
cmd.Init(kIndexToTest,
GL_VERTEX_ATTRIB_ARRAY_POINTER,
shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(sizeof(*result_value), result->size);
EXPECT_EQ(0u, *result_value);
EXPECT_EQ(GL_NO_ERROR, GetGLError());
// Set the value and see that we get it.
SetupVertexBuffer();
DoVertexAttribPointer(kIndexToTest, 2, GL_FLOAT, 0, kOffsetToTestFor);
result->size = 0;
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(sizeof(*result_value), result->size);
EXPECT_EQ(kOffsetToTestFor, *result_value);
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_P(GLES2DecoderWithShaderTest, GetVertexAttribPointervBadArgsFails) {
const GLuint kIndexToTest = 1;
auto* result = static_cast<cmds::GetVertexAttribPointerv::Result*>(
shared_memory_address_);
result->size = 0;
const GLuint* result_value = result->GetData();
// Test pname invalid fails.
cmds::GetVertexAttribPointerv cmd;
cmd.Init(kIndexToTest,
GL_VERTEX_ATTRIB_ARRAY_POINTER + 1,
shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(0u, result->size);
EXPECT_EQ(kInitialResult, *result_value);
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
// Test index out of range fails.
result->size = 0;
cmd.Init(kNumVertexAttribs,
GL_VERTEX_ATTRIB_ARRAY_POINTER,
shared_memory_id_,
shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(0u, result->size);
EXPECT_EQ(kInitialResult, *result_value);
EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
// Test memory id bad fails.
cmd.Init(kIndexToTest,
GL_VERTEX_ATTRIB_ARRAY_POINTER,
kInvalidSharedMemoryId,
shared_memory_offset_);
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
// Test memory offset bad fails.
cmd.Init(kIndexToTest,
GL_VERTEX_ATTRIB_ARRAY_POINTER,
shared_memory_id_,
kInvalidSharedMemoryOffset);
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
}
TEST_P(GLES2DecoderWithShaderTest, BindBufferToDifferentTargetFails) {
// Bind the buffer to GL_ARRAY_BUFFER
DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
// Attempt to rebind to GL_ELEMENT_ARRAY_BUFFER
// NOTE: Real GLES2 does not have this restriction but WebGL and we do.
// This can be restriction can be removed at runtime.
EXPECT_CALL(*gl_, BindBuffer(_, _)).Times(0);
cmds::BindBuffer cmd;
cmd.Init(GL_ELEMENT_ARRAY_BUFFER, client_buffer_id_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
TEST_P(GLES2DecoderWithShaderTest, VertexAttribPointer) {
SetupVertexBuffer();
static const GLenum types[] = {
GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT,
GL_FLOAT, GL_FIXED, GL_INT, GL_UNSIGNED_INT,
};
static const GLsizei sizes[] = {
1, 1, 2, 2, 4, 4, 4, 4,
};
static const GLuint indices[] = {
0, 1, kNumVertexAttribs - 1, kNumVertexAttribs,
};
static const GLsizei offset_mult[] = {
0, 0, 1, 1, 2, 1000,
};
static const GLsizei offset_offset[] = {
0, 1, 0, 1, 0, 0,
};
static const GLsizei stride_mult[] = {
-1, 0, 0, 1, 1, 2, 1000,
};
static const GLsizei stride_offset[] = {
0, 0, 1, 0, 1, 0, 0,
};
for (size_t tt = 0; tt < std::size(types); ++tt) {
GLenum type = types[tt];
GLsizei num_bytes = sizes[tt];
for (size_t ii = 0; ii < std::size(indices); ++ii) {
GLuint index = indices[ii];
for (GLint size = 0; size < 5; ++size) {
for (size_t oo = 0; oo < std::size(offset_mult); ++oo) {
GLuint offset = num_bytes * offset_mult[oo] + offset_offset[oo];
for (size_t ss = 0; ss < std::size(stride_mult); ++ss) {
GLsizei stride = num_bytes * stride_mult[ss] + stride_offset[ss];
for (int normalize = 0; normalize < 2; ++normalize) {
bool index_good = index < static_cast<GLuint>(kNumVertexAttribs);
bool size_good = (size > 0 && size < 5);
bool offset_good = (offset % num_bytes == 0);
bool stride_good =
(stride % num_bytes == 0) && stride >= 0 && stride <= 255;
bool type_good = (type != GL_INT && type != GL_UNSIGNED_INT &&
type != GL_FIXED);
bool good = size_good && offset_good && stride_good &&
type_good && index_good;
bool call = good && (type != GL_FIXED);
if (call) {
EXPECT_CALL(*gl_,
VertexAttribPointer(index,
size,
type,
normalize,
stride,
BufferOffset(offset)));
}
cmds::VertexAttribPointer cmd;
cmd.Init(index, size, type, normalize, stride, offset);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
if (good) {
EXPECT_EQ(GL_NO_ERROR, GetGLError());
} else if (size_good && offset_good && stride_good && type_good &&
!index_good) {
EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
} else if (size_good && offset_good && stride_good &&
!type_good && index_good) {
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
} else if (size_good && offset_good && !stride_good &&
type_good && index_good) {
if (stride < 0 || stride > 255) {
EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
} else {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
} else if (size_good && !offset_good && stride_good &&
type_good && index_good) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
} else if (!size_good && offset_good && stride_good &&
type_good && index_good) {
EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
} else {
EXPECT_NE(GL_NO_ERROR, GetGLError());
}
}
}
}
}
}
}
}
class GLES2DecoderVertexArraysOESTest : public GLES2DecoderWithShaderTest {
public:
GLES2DecoderVertexArraysOESTest() = default;
bool vertex_array_deleted_manually_;
void SetUp() override {
InitState init;
init.gl_version = "OpenGL ES 2.0";
init.bind_generates_resource = true;
InitDecoder(init);
SetupDefaultProgram();
AddExpectationsForGenVertexArraysOES();
GenHelper<cmds::GenVertexArraysOESImmediate>(client_vertexarray_id_);
vertex_array_deleted_manually_ = false;
}
void TearDown() override {
// This should only be set if the test handled deletion of the vertex array
// itself. Necessary because vertex_array_objects are not sharable, and thus
// not managed in the ContextGroup, meaning they will be destroyed during
// test tear down
if (!vertex_array_deleted_manually_) {
AddExpectationsForDeleteVertexArraysOES();
}
GLES2DecoderWithShaderTest::TearDown();
}
void GenVertexArraysOESImmediateValidArgs() {
AddExpectationsForGenVertexArraysOES();
auto* cmd = GetImmediateAs<cmds::GenVertexArraysOESImmediate>();
GLuint temp = kNewClientId;
cmd->Init(1, &temp);
EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(*cmd, sizeof(temp)));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
EXPECT_TRUE(GetVertexArrayInfo(kNewClientId) != nullptr);
AddExpectationsForDeleteVertexArraysOES();
}
void GenVertexArraysOESImmediateDuplicateOrNullIds() {
auto* cmd = GetImmediateAs<cmds::GenVertexArraysOESImmediate>();
GLuint temp[3] = {kNewClientId, kNewClientId + 1, kNewClientId};
cmd->Init(3, temp);
EXPECT_EQ(error::kInvalidArguments,
ExecuteImmediateCmd(*cmd, sizeof(temp)));
EXPECT_TRUE(GetVertexArrayInfo(kNewClientId) == nullptr);
EXPECT_TRUE(GetVertexArrayInfo(kNewClientId + 1) == nullptr);
GLuint null_id[2] = {kNewClientId, 0};
cmd->Init(2, null_id);
EXPECT_EQ(error::kInvalidArguments,
ExecuteImmediateCmd(*cmd, sizeof(temp)));
EXPECT_TRUE(GetVertexArrayInfo(kNewClientId) == nullptr);
}
void GenVertexArraysOESImmediateInvalidArgs() {
EXPECT_CALL(*gl_, GenVertexArraysOES(_, _)).Times(0);
auto* cmd = GetImmediateAs<cmds::GenVertexArraysOESImmediate>();
cmd->Init(1, &client_vertexarray_id_);
EXPECT_EQ(error::kInvalidArguments,
ExecuteImmediateCmd(*cmd, sizeof(&client_vertexarray_id_)));
}
void DeleteVertexArraysOESImmediateValidArgs() {
AddExpectationsForDeleteVertexArraysOES();
auto& cmd = *GetImmediateAs<cmds::DeleteVertexArraysOESImmediate>();
cmd.Init(1, &client_vertexarray_id_);
EXPECT_EQ(error::kNoError,
ExecuteImmediateCmd(cmd, sizeof(client_vertexarray_id_)));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
EXPECT_TRUE(GetVertexArrayInfo(client_vertexarray_id_) == nullptr);
vertex_array_deleted_manually_ = true;
}
void DeleteVertexArraysOESImmediateInvalidArgs() {
auto& cmd = *GetImmediateAs<cmds::DeleteVertexArraysOESImmediate>();
GLuint temp = kInvalidClientId;
cmd.Init(1, &temp);
EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp)));
}
void DeleteBoundVertexArraysOESImmediateValidArgs() {
BindVertexArrayOESValidArgs();
AddExpectationsForDeleteBoundVertexArraysOES();
auto& cmd = *GetImmediateAs<cmds::DeleteVertexArraysOESImmediate>();
cmd.Init(1, &client_vertexarray_id_);
EXPECT_EQ(error::kNoError,
ExecuteImmediateCmd(cmd, sizeof(client_vertexarray_id_)));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
EXPECT_TRUE(GetVertexArrayInfo(client_vertexarray_id_) == nullptr);
vertex_array_deleted_manually_ = true;
}
void IsVertexArrayOESValidArgs() {
cmds::IsVertexArrayOES cmd;
cmd.Init(client_vertexarray_id_, shared_memory_id_, shared_memory_offset_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
void IsVertexArrayOESInvalidArgsBadSharedMemoryId() {
cmds::IsVertexArrayOES cmd;
cmd.Init(
client_vertexarray_id_, kInvalidSharedMemoryId, shared_memory_offset_);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
cmd.Init(
client_vertexarray_id_, shared_memory_id_, kInvalidSharedMemoryOffset);
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
}
void BindVertexArrayOESValidArgs() {
AddExpectationsForBindVertexArrayOES();
cmds::BindVertexArrayOES cmd;
cmd.Init(client_vertexarray_id_);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
void BindVertexArrayOESValidArgsNewId() {
cmds::BindVertexArrayOES cmd;
cmd.Init(kNewClientId);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
};
INSTANTIATE_TEST_SUITE_P(Service,
GLES2DecoderVertexArraysOESTest,
::testing::Bool());
class GLES2DecoderEmulatedVertexArraysOESTest
: public GLES2DecoderVertexArraysOESTest {
public:
GLES2DecoderEmulatedVertexArraysOESTest() = default;
void SetUp() override {
InitState init;
init.bind_generates_resource = true;
init.use_native_vao = false;
InitDecoder(init);
SetupDefaultProgram();
AddExpectationsForGenVertexArraysOES();
GenHelper<cmds::GenVertexArraysOESImmediate>(client_vertexarray_id_);
vertex_array_deleted_manually_ = false;
}
};
INSTANTIATE_TEST_SUITE_P(Service,
GLES2DecoderEmulatedVertexArraysOESTest,
::testing::Bool());
// Test vertex array objects with native support
TEST_P(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESImmediateValidArgs) {
GenVertexArraysOESImmediateValidArgs();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
GenVertexArraysOESImmediateValidArgs) {
GenVertexArraysOESImmediateValidArgs();
}
TEST_P(GLES2DecoderVertexArraysOESTest,
GenVertexArraysOESImmediateDuplicateOrNullIds) {
GenVertexArraysOESImmediateDuplicateOrNullIds();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
GenVertexArraysOESImmediateDuplicateOrNullIds) {
GenVertexArraysOESImmediateDuplicateOrNullIds();
}
TEST_P(GLES2DecoderVertexArraysOESTest,
GenVertexArraysOESImmediateInvalidArgs) {
GenVertexArraysOESImmediateInvalidArgs();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
GenVertexArraysOESImmediateInvalidArgs) {
GenVertexArraysOESImmediateInvalidArgs();
}
TEST_P(GLES2DecoderVertexArraysOESTest,
DeleteVertexArraysOESImmediateValidArgs) {
DeleteVertexArraysOESImmediateValidArgs();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
DeleteVertexArraysOESImmediateValidArgs) {
DeleteVertexArraysOESImmediateValidArgs();
}
TEST_P(GLES2DecoderVertexArraysOESTest,
DeleteVertexArraysOESImmediateInvalidArgs) {
DeleteVertexArraysOESImmediateInvalidArgs();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
DeleteVertexArraysOESImmediateInvalidArgs) {
DeleteVertexArraysOESImmediateInvalidArgs();
}
TEST_P(GLES2DecoderVertexArraysOESTest,
DeleteBoundVertexArraysOESImmediateValidArgs) {
DeleteBoundVertexArraysOESImmediateValidArgs();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
DeleteBoundVertexArraysOESImmediateValidArgs) {
DeleteBoundVertexArraysOESImmediateValidArgs();
}
TEST_P(GLES2DecoderVertexArraysOESTest, IsVertexArrayOESValidArgs) {
IsVertexArrayOESValidArgs();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, IsVertexArrayOESValidArgs) {
IsVertexArrayOESValidArgs();
}
TEST_P(GLES2DecoderVertexArraysOESTest,
IsVertexArrayOESInvalidArgsBadSharedMemoryId) {
IsVertexArrayOESInvalidArgsBadSharedMemoryId();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
IsVertexArrayOESInvalidArgsBadSharedMemoryId) {
IsVertexArrayOESInvalidArgsBadSharedMemoryId();
}
TEST_P(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgs) {
BindVertexArrayOESValidArgs();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, BindVertexArrayOESValidArgs) {
BindVertexArrayOESValidArgs();
}
TEST_P(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) {
BindVertexArrayOESValidArgsNewId();
}
TEST_P(GLES2DecoderEmulatedVertexArraysOESTest,
BindVertexArrayOESValidArgsNewId) {
BindVertexArrayOESValidArgsNewId();
}
TEST_P(GLES2DecoderTest, BufferDataGLError) {
GLenum target = GL_ARRAY_BUFFER;
GLsizeiptr size = 4;
DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
BufferManager* manager = group().buffer_manager();
Buffer* buffer = manager->GetBuffer(client_buffer_id_);
ASSERT_TRUE(buffer != nullptr);
EXPECT_EQ(0, buffer->size());
EXPECT_CALL(*gl_, GetError())
.WillOnce(Return(GL_NO_ERROR))
.WillOnce(Return(GL_OUT_OF_MEMORY))
.RetiresOnSaturation();
EXPECT_CALL(*gl_, BufferData(target, size, _, GL_STREAM_DRAW))
.Times(1)
.RetiresOnSaturation();
cmds::BufferData cmd;
cmd.Init(target, size, 0, 0, GL_STREAM_DRAW);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
EXPECT_EQ(0, buffer->size());
}
// TODO(gman): BufferData
// TODO(gman): BufferDataImmediate
// TODO(gman): BufferSubData
// TODO(gman): BufferSubDataImmediate
} // namespace gles2
} // namespace gpu
|