OLD | NEW |
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 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 InSequence sequence; | 484 InSequence sequence; |
485 | 485 |
486 const bool support_client_side_arrays = true; | 486 const bool support_client_side_arrays = true; |
487 gl_.reset(new GLES2Implementation(helper_.get(), | 487 gl_.reset(new GLES2Implementation(helper_.get(), |
488 share_group, | 488 share_group, |
489 transfer_buffer_.get(), | 489 transfer_buffer_.get(), |
490 bind_generates_resource_client, | 490 bind_generates_resource_client, |
491 lose_context_when_out_of_memory, | 491 lose_context_when_out_of_memory, |
492 support_client_side_arrays, | 492 support_client_side_arrays, |
493 gpu_control_.get())); | 493 gpu_control_.get())); |
| 494 |
| 495 if (!gl_->Initialize(kTransferBufferSize, |
| 496 kTransferBufferSize, |
| 497 kTransferBufferSize, |
| 498 GLES2Implementation::kNoLimit)) |
| 499 return false; |
494 } | 500 } |
495 | 501 |
496 // The client should be set to something non-null. | |
497 EXPECT_CALL(*gpu_control_, SetGpuControlClient(gl_.get())).Times(1); | |
498 | |
499 if (!gl_->Initialize(kTransferBufferSize, kTransferBufferSize, | |
500 kTransferBufferSize, GLES2Implementation::kNoLimit)) | |
501 return false; | |
502 | |
503 helper_->CommandBufferHelper::Finish(); | 502 helper_->CommandBufferHelper::Finish(); |
504 ::testing::Mock::VerifyAndClearExpectations(gl_.get()); | 503 ::testing::Mock::VerifyAndClearExpectations(gl_.get()); |
505 | 504 |
506 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); | 505 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); |
507 commands_ = static_cast<CommandBufferEntry*>(ring_buffer->memory()) + | 506 commands_ = static_cast<CommandBufferEntry*>(ring_buffer->memory()) + |
508 command_buffer()->GetPutOffset(); | 507 command_buffer()->GetPutOffset(); |
509 ClearCommands(); | 508 ClearCommands(); |
510 EXPECT_TRUE(transfer_buffer_->InSync()); | 509 EXPECT_TRUE(transfer_buffer_->InSync()); |
511 | 510 |
512 ::testing::Mock::VerifyAndClearExpectations(command_buffer()); | 511 ::testing::Mock::VerifyAndClearExpectations(command_buffer()); |
513 return true; | 512 return true; |
514 } | 513 } |
515 | 514 |
516 void TearDown() { | 515 void TearDown() { |
517 Mock::VerifyAndClear(gl_.get()); | 516 Mock::VerifyAndClear(gl_.get()); |
518 EXPECT_CALL(*command_buffer(), OnFlush()).Times(AnyNumber()); | 517 EXPECT_CALL(*command_buffer(), OnFlush()).Times(AnyNumber()); |
519 // For command buffer. | 518 // For command buffer. |
520 EXPECT_CALL(*command_buffer(), DestroyTransferBuffer(_)) | 519 EXPECT_CALL(*command_buffer(), DestroyTransferBuffer(_)) |
521 .Times(AtLeast(1)); | 520 .Times(AtLeast(1)); |
522 // The client should be unset. | |
523 EXPECT_CALL(*gpu_control_, SetGpuControlClient(nullptr)).Times(1); | |
524 gl_.reset(); | 521 gl_.reset(); |
525 } | 522 } |
526 | 523 |
527 MockClientCommandBuffer* command_buffer() const { | 524 MockClientCommandBuffer* command_buffer() const { |
528 return command_buffer_.get(); | 525 return command_buffer_.get(); |
529 } | 526 } |
530 | 527 |
531 int GetNextToken() { return ++token_; } | 528 int GetNextToken() { return ++token_; } |
532 | 529 |
533 void ClearCommands() { | 530 void ClearCommands() { |
(...skipping 3968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4502 ContextInitOptions init_options; | 4499 ContextInitOptions init_options; |
4503 init_options.transfer_buffer_initialize_fail = true; | 4500 init_options.transfer_buffer_initialize_fail = true; |
4504 EXPECT_FALSE(Initialize(init_options)); | 4501 EXPECT_FALSE(Initialize(init_options)); |
4505 } | 4502 } |
4506 | 4503 |
4507 #include "base/macros.h" | 4504 #include "base/macros.h" |
4508 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 4505 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
4509 | 4506 |
4510 } // namespace gles2 | 4507 } // namespace gles2 |
4511 } // namespace gpu | 4508 } // namespace gpu |
OLD | NEW |