| Index: gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| index f57d07a8ded8be41387f469e42477697ed149271..a280e4f3ced05eeb2f59de94480bb09e5c2a7e3b 100644
|
| --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| @@ -392,11 +392,12 @@ class GLES2ImplementationTest : public testing::Test {
|
| public:
|
| TestContext() : commands_(NULL), token_(0) {}
|
|
|
| - void Initialize(ShareGroup* share_group,
|
| + bool Initialize(ShareGroup* share_group,
|
| bool bind_generates_resource,
|
| bool lose_context_when_out_of_memory) {
|
| command_buffer_.reset(new StrictMock<MockClientCommandBuffer>());
|
| - ASSERT_TRUE(command_buffer_->Initialize());
|
| + if (!command_buffer_->Initialize())
|
| + return false;
|
|
|
| transfer_buffer_.reset(
|
| new MockTransferBuffer(command_buffer_.get(),
|
| @@ -426,6 +427,8 @@ class GLES2ImplementationTest : public testing::Test {
|
| int_state.max_vertex_uniform_vectors = kMaxVertexUniformVectors;
|
| int_state.num_compressed_texture_formats = kNumCompressedTextureFormats;
|
| int_state.num_shader_binary_formats = kNumShaderBinaryFormats;
|
| + int_state.bind_generates_resource_chromium =
|
| + bind_generates_resource ? 1 : 0;
|
|
|
| // This just happens to work for now because IntState has 1 GLint per
|
| // state.
|
| @@ -449,10 +452,12 @@ class GLES2ImplementationTest : public testing::Test {
|
| bind_generates_resource,
|
| lose_context_when_out_of_memory,
|
| gpu_control_.get()));
|
| - ASSERT_TRUE(gl_->Initialize(kTransferBufferSize,
|
| - kTransferBufferSize,
|
| - kTransferBufferSize,
|
| - GLES2Implementation::kNoLimit));
|
| +
|
| + if (!gl_->Initialize(kTransferBufferSize,
|
| + kTransferBufferSize,
|
| + kTransferBufferSize,
|
| + GLES2Implementation::kNoLimit))
|
| + return false;
|
| }
|
|
|
| EXPECT_CALL(*command_buffer_, OnFlush()).Times(1).RetiresOnSaturation();
|
| @@ -466,6 +471,7 @@ class GLES2ImplementationTest : public testing::Test {
|
| EXPECT_TRUE(transfer_buffer_->InSync());
|
|
|
| ::testing::Mock::VerifyAndClearExpectations(command_buffer());
|
| + return true;
|
| }
|
|
|
| void TearDown() {
|
| @@ -518,14 +524,28 @@ class GLES2ImplementationTest : public testing::Test {
|
| return gl_->query_tracker_->GetQuery(id);
|
| }
|
|
|
| - void Initialize(bool bind_generates_resource,
|
| - bool lose_context_when_out_of_memory) {
|
| - share_group_ = new ShareGroup(bind_generates_resource);
|
| + struct ContextInitOptions {
|
| + ContextInitOptions()
|
| + : bind_generates_resource_client(true),
|
| + bind_generates_resource_service(true),
|
| + lose_context_when_out_of_memory(false) {}
|
| +
|
| + bool bind_generates_resource_client;
|
| + bool bind_generates_resource_service;
|
| + bool lose_context_when_out_of_memory;
|
| + };
|
| +
|
| + bool Initialize(const ContextInitOptions& init_options) {
|
| + bool success = true;
|
| + share_group_ = new ShareGroup(init_options.bind_generates_resource_service);
|
|
|
| - for (int i = 0; i < kNumTestContexts; i++)
|
| - test_contexts_[i].Initialize(share_group_.get(),
|
| - bind_generates_resource,
|
| - lose_context_when_out_of_memory);
|
| + for (int i = 0; i < kNumTestContexts; i++) {
|
| + if (!test_contexts_[i].Initialize(
|
| + share_group_.get(),
|
| + init_options.bind_generates_resource_client,
|
| + init_options.lose_context_when_out_of_memory))
|
| + success = false;
|
| + }
|
|
|
| // Default to test context 0.
|
| gpu_control_ = test_contexts_[0].gpu_control_.get();
|
| @@ -533,6 +553,7 @@ class GLES2ImplementationTest : public testing::Test {
|
| transfer_buffer_ = test_contexts_[0].transfer_buffer_.get();
|
| gl_ = test_contexts_[0].gl_.get();
|
| commands_ = test_contexts_[0].commands_;
|
| + return success;
|
| }
|
|
|
| MockClientCommandBuffer* command_buffer() const {
|
| @@ -592,9 +613,8 @@ class GLES2ImplementationTest : public testing::Test {
|
| };
|
|
|
| void GLES2ImplementationTest::SetUp() {
|
| - bool bind_generates_resource = true;
|
| - bool lose_context_when_out_of_memory = false;
|
| - Initialize(bind_generates_resource, lose_context_when_out_of_memory);
|
| + ContextInitOptions init_options;
|
| + ASSERT_TRUE(Initialize(init_options));
|
| }
|
|
|
| void GLES2ImplementationTest::TearDown() {
|
| @@ -697,9 +717,10 @@ class GLES2ImplementationStrictSharedTest : public GLES2ImplementationTest {
|
| };
|
|
|
| void GLES2ImplementationStrictSharedTest::SetUp() {
|
| - bool bind_generates_resource = false;
|
| - bool lose_context_when_out_of_memory = false;
|
| - Initialize(bind_generates_resource, lose_context_when_out_of_memory);
|
| + ContextInitOptions init_options;
|
| + init_options.bind_generates_resource_client = false;
|
| + init_options.bind_generates_resource_service = false;
|
| + ASSERT_TRUE(Initialize(init_options));
|
| }
|
|
|
| // GCC requires these declarations, but MSVC requires they not be present
|
| @@ -3117,9 +3138,9 @@ TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) {
|
| }
|
|
|
| TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) {
|
| - bool bind_generates_resource = false;
|
| - bool lose_context_when_out_of_memory = true;
|
| - Initialize(bind_generates_resource, lose_context_when_out_of_memory);
|
| + ContextInitOptions init_options;
|
| + init_options.lose_context_when_out_of_memory = true;
|
| + ASSERT_TRUE(Initialize(init_options));
|
|
|
| struct Cmds {
|
| cmds::LoseContextCHROMIUM cmd;
|
| @@ -3136,9 +3157,8 @@ TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) {
|
| }
|
|
|
| TEST_F(GLES2ImplementationManualInitTest, NoLoseContextOnOOM) {
|
| - bool bind_generates_resource = false;
|
| - bool lose_context_when_out_of_memory = false;
|
| - Initialize(bind_generates_resource, lose_context_when_out_of_memory);
|
| + ContextInitOptions init_options;
|
| + ASSERT_TRUE(Initialize(init_options));
|
|
|
| struct Cmds {
|
| cmds::LoseContextCHROMIUM cmd;
|
| @@ -3152,6 +3172,20 @@ TEST_F(GLES2ImplementationManualInitTest, NoLoseContextOnOOM) {
|
| EXPECT_TRUE(NoCommandsWritten());
|
| }
|
|
|
| +TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch1) {
|
| + ContextInitOptions init_options;
|
| + init_options.bind_generates_resource_client = false;
|
| + init_options.bind_generates_resource_service = true;
|
| + EXPECT_FALSE(Initialize(init_options));
|
| +}
|
| +
|
| +TEST_F(GLES2ImplementationManualInitTest, FailInitOnBGRMismatch2) {
|
| + ContextInitOptions init_options;
|
| + init_options.bind_generates_resource_client = true;
|
| + init_options.bind_generates_resource_service = false;
|
| + EXPECT_FALSE(Initialize(init_options));
|
| +}
|
| +
|
| #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
|
|
|
| } // namespace gles2
|
|
|