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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_format_test.cc

Issue 7789021: Fix GPU cmd tests so they pass ASAN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 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 // This file contains unit tests for gles2 commmands 5 // This file contains unit tests for gles2 commmands
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" 8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 9
10 namespace gpu { 10 namespace gpu {
11 namespace gles2 { 11 namespace gles2 {
12 12
13 class GLES2FormatTest : public testing::Test {
14 protected:
15 static const unsigned char kInitialValue = 0xBD;
16
17 virtual void SetUp() {
18 memset(buffer_, kInitialValue, sizeof(buffer_));
19 }
20
21 virtual void TearDown() {
22 }
23
24 template <typename T>
25 T* GetBufferAs() {
26 return static_cast<T*>(static_cast<void*>(&buffer_));
27 }
28
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]);
38 }
39
40 void CheckBytesWrittenMatchesExpectedSize(
41 const void* end, size_t expected_size) {
42 CheckBytesWritten(end, expected_size, expected_size);
43 }
44
45 private:
46 unsigned char buffer_[1024];
47 };
48
49 // GCC requires these declarations, but MSVC requires they not be present
50 #ifndef _MSC_VER
51 const unsigned char GLES2FormatTest::kInitialValue;
52 #endif
53
13 #include "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h" 54 #include "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h"
14 55
15 } // namespace gles2 56 } // namespace gles2
16 } // namespace gpu 57 } // namespace gpu
17 58
OLDNEW
« no previous file with comments | « gpu/command_buffer/build_gles2_cmd_buffer.py ('k') | gpu/command_buffer/common/gles2_cmd_format_test_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698