OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 7 #include "gpu/command_buffer/service/gl_mock.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 using ::testing::_; |
| 11 using ::testing::Return; |
| 12 using ::testing::SetArgumentPointee; |
| 13 |
| 14 namespace gpu { |
| 15 namespace gles2 { |
| 16 |
| 17 class GLES2DecoderTest : public testing::Test { |
| 18 protected: |
| 19 virtual void SetUp() { |
| 20 gl_ = new ::gles2::MockGLInterface(); |
| 21 ::gles2::GLInterface::SetGLInterface(gl_); |
| 22 |
| 23 EXPECT_CALL(*gl_, GetIntegerv(_, _)) |
| 24 .WillOnce(SetArgumentPointee<1>(16)); |
| 25 EXPECT_CALL(*gl_, GetError()) |
| 26 .WillRepeatedly(Return(GL_NO_ERROR)); |
| 27 |
| 28 decoder_ = GLES2Decoder::Create(); |
| 29 decoder_->Initialize(); |
| 30 } |
| 31 |
| 32 virtual void TearDown() { |
| 33 decoder_->Destroy(); |
| 34 delete decoder_; |
| 35 ::gles2::GLInterface::SetGLInterface(NULL); |
| 36 delete gl_; |
| 37 } |
| 38 |
| 39 template <typename T> |
| 40 parse_error::ParseError ExecuteCmd(const T& cmd) { |
| 41 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); |
| 42 return decoder_->DoCommand(cmd.kCmdId, |
| 43 ComputeNumEntries(sizeof(cmd)) - 1, |
| 44 &cmd); |
| 45 } |
| 46 |
| 47 template <typename T> |
| 48 parse_error::ParseError ExecuteImmediateCmd(const T& cmd, size_t data_size) { |
| 49 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); |
| 50 return decoder_.DoCommand(cmd.kCmdId, |
| 51 ComputeNumEntries(sizeof(cmd) + data_size) - 1, |
| 52 &cmd); |
| 53 } |
| 54 |
| 55 ::gles2::MockGLInterface* gl_; |
| 56 GLES2Decoder* decoder_; |
| 57 }; |
| 58 |
| 59 TEST_F(GLES2DecoderTest, Enable) { |
| 60 EXPECT_CALL(*gl_, Enable(GL_BLEND)); |
| 61 |
| 62 Enable cmd; |
| 63 cmd.Init(GL_BLEND); |
| 64 EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); |
| 65 } |
| 66 |
| 67 } // namespace gles2 |
| 68 } // namespace gpu |
| 69 |
| 70 |
OLD | NEW |