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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 511001: Adds a GLMock object so we can check the code is... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_autogen.h ('k') | gpu/gpu.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc (revision 0)
+++ gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
+#include "gpu/command_buffer/common/gles2_cmd_format.h"
+#include "gpu/command_buffer/service/gl_mock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::SetArgumentPointee;
+
+namespace gpu {
+namespace gles2 {
+
+class GLES2DecoderTest : public testing::Test {
+ protected:
+ virtual void SetUp() {
+ gl_ = new ::gles2::MockGLInterface();
+ ::gles2::GLInterface::SetGLInterface(gl_);
+
+ EXPECT_CALL(*gl_, GetIntegerv(_, _))
+ .WillOnce(SetArgumentPointee<1>(16));
+ EXPECT_CALL(*gl_, GetError())
+ .WillRepeatedly(Return(GL_NO_ERROR));
+
+ decoder_ = GLES2Decoder::Create();
+ decoder_->Initialize();
+ }
+
+ virtual void TearDown() {
+ decoder_->Destroy();
+ delete decoder_;
+ ::gles2::GLInterface::SetGLInterface(NULL);
+ delete gl_;
+ }
+
+ template <typename T>
+ parse_error::ParseError ExecuteCmd(const T& cmd) {
+ COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
+ return decoder_->DoCommand(cmd.kCmdId,
+ ComputeNumEntries(sizeof(cmd)) - 1,
+ &cmd);
+ }
+
+ template <typename T>
+ parse_error::ParseError ExecuteImmediateCmd(const T& cmd, size_t data_size) {
+ COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
+ return decoder_.DoCommand(cmd.kCmdId,
+ ComputeNumEntries(sizeof(cmd) + data_size) - 1,
+ &cmd);
+ }
+
+ ::gles2::MockGLInterface* gl_;
+ GLES2Decoder* decoder_;
+};
+
+TEST_F(GLES2DecoderTest, Enable) {
+ EXPECT_CALL(*gl_, Enable(GL_BLEND));
+
+ Enable cmd;
+ cmd.Init(GL_BLEND);
+ EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd));
+}
+
+} // namespace gles2
+} // namespace gpu
+
+
Property changes on: gpu\command_buffer\service\gles2_cmd_decoder_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_autogen.h ('k') | gpu/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698