1 // Copyright (c) 2011 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.
5 // This file contains unit tests for gles2 commmands
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
13 class GLES2FormatTest
: public testing::Test
{
15 static const unsigned char kInitialValue
= 0xBD;
17 virtual void SetUp() {
18 memset(buffer_
, kInitialValue
, sizeof(buffer_
));
21 virtual void TearDown() {
26 return static_cast<T
*>(static_cast<void*>(&buffer_
));
29 void CheckBytesWritten(
30 const void* end
, size_t expected_size
, size_t written_size
) {
31 size_t actual_size
= static_cast<const unsigned char*>(end
) -
32 GetBufferAs
<const unsigned char>();
33 EXPECT_LT(actual_size
, sizeof(buffer_
));
34 EXPECT_GT(actual_size
, 0u);
35 EXPECT_EQ(expected_size
, actual_size
);
36 EXPECT_EQ(kInitialValue
, buffer_
[written_size
]);
37 EXPECT_NE(kInitialValue
, buffer_
[written_size
- 1]);
40 void CheckBytesWrittenMatchesExpectedSize(
41 const void* end
, size_t expected_size
) {
42 CheckBytesWritten(end
, expected_size
, expected_size
);
46 unsigned char buffer_
[1024];
49 // GCC requires these declarations, but MSVC requires they not be present
51 const unsigned char GLES2FormatTest::kInitialValue
;
54 #include "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h"