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

Side by Side Diff: gpu/command_buffer/service/context_state_unittest.cc

Issue 2142353002: Validate fbo color image format and fragment shader output variable type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 #include "gpu/command_buffer/service/context_state.h" 5 #include "gpu/command_buffer/service/context_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace gpu { 11 namespace gpu {
12 namespace gles2 { 12 namespace gles2 {
13 13
14 TEST(ContextStateVec4Test, DefaultValues) { 14 TEST(ContextStateVec4Test, DefaultValues) {
15 Vec4 v; 15 Vec4 v;
16 EXPECT_EQ(Vec4::kFloat, v.type()); 16 EXPECT_EQ(SHADER_VARIABLE_FLOAT, v.type());
17 GLfloat f[4]; 17 GLfloat f[4];
18 v.GetValues(f); 18 v.GetValues(f);
19 EXPECT_EQ(0.f, f[0]); 19 EXPECT_EQ(0.f, f[0]);
20 EXPECT_EQ(0.f, f[1]); 20 EXPECT_EQ(0.f, f[1]);
21 EXPECT_EQ(0.f, f[2]); 21 EXPECT_EQ(0.f, f[2]);
22 EXPECT_EQ(1.f, f[3]); 22 EXPECT_EQ(1.f, f[3]);
23 } 23 }
24 24
25 TEST(ContextStateVec4Test, SetGetFloatValues) { 25 TEST(ContextStateVec4Test, SetGetFloatValues) {
26 Vec4 v; 26 Vec4 v;
27 27
28 const GLfloat kFloatValues[4] = { 2.f, 3.f, 4.f, 5.f }; 28 const GLfloat kFloatValues[4] = { 2.f, 3.f, 4.f, 5.f };
29 v.SetValues(kFloatValues); 29 v.SetValues(kFloatValues);
30 EXPECT_EQ(Vec4::kFloat, v.type()); 30 EXPECT_EQ(SHADER_VARIABLE_FLOAT, v.type());
31 GLfloat fv[4]; 31 GLfloat fv[4];
32 v.GetValues(fv); 32 v.GetValues(fv);
33 for (size_t ii = 0; ii < 4; ++ii) { 33 for (size_t ii = 0; ii < 4; ++ii) {
34 EXPECT_EQ(kFloatValues[ii], fv[ii]); 34 EXPECT_EQ(kFloatValues[ii], fv[ii]);
35 } 35 }
36 } 36 }
37 37
38 TEST(ContextStateVec4Test, SetGetIntValues) { 38 TEST(ContextStateVec4Test, SetGetIntValues) {
39 Vec4 v; 39 Vec4 v;
40 40
41 const GLint kIntValues[4] = { 2, 3, -4, 5 }; 41 const GLint kIntValues[4] = { 2, 3, -4, 5 };
42 v.SetValues(kIntValues); 42 v.SetValues(kIntValues);
43 EXPECT_EQ(Vec4::kInt, v.type()); 43 EXPECT_EQ(SHADER_VARIABLE_INT, v.type());
44 GLint iv[4]; 44 GLint iv[4];
45 v.GetValues(iv); 45 v.GetValues(iv);
46 for (size_t ii = 0; ii < 4; ++ii) { 46 for (size_t ii = 0; ii < 4; ++ii) {
47 EXPECT_EQ(kIntValues[ii], iv[ii]); 47 EXPECT_EQ(kIntValues[ii], iv[ii]);
48 } 48 }
49 } 49 }
50 50
51 TEST(ContextStateVec4Test, SetGetUIntValues) { 51 TEST(ContextStateVec4Test, SetGetUIntValues) {
52 Vec4 v; 52 Vec4 v;
53 53
54 const GLuint kUIntValues[4] = { 2, 3, 4, 5 }; 54 const GLuint kUIntValues[4] = { 2, 3, 4, 5 };
55 v.SetValues(kUIntValues); 55 v.SetValues(kUIntValues);
56 EXPECT_EQ(Vec4::kUInt, v.type()); 56 EXPECT_EQ(SHADER_VARIABLE_UINT, v.type());
57 GLuint uiv[4]; 57 GLuint uiv[4];
58 v.GetValues(uiv); 58 v.GetValues(uiv);
59 for (size_t ii = 0; ii < 4; ++ii) { 59 for (size_t ii = 0; ii < 4; ++ii) {
60 EXPECT_EQ(kUIntValues[ii], uiv[ii]); 60 EXPECT_EQ(kUIntValues[ii], uiv[ii]);
61 } 61 }
62 } 62 }
63 63
64 TEST(ContextStateVec4Test, Equal) { 64 TEST(ContextStateVec4Test, Equal) {
65 Vec4 v1, v2; 65 Vec4 v1, v2;
66 66
(...skipping 12 matching lines...) Expand all
79 const GLint kIntValues2[4] = { 2, 3, 4, 6 }; 79 const GLint kIntValues2[4] = { 2, 3, 4, 6 };
80 v2.SetValues(kIntValues2); 80 v2.SetValues(kIntValues2);
81 EXPECT_FALSE(v1.Equal(v2)); 81 EXPECT_FALSE(v1.Equal(v2));
82 EXPECT_FALSE(v2.Equal(v1)); 82 EXPECT_FALSE(v2.Equal(v1));
83 } 83 }
84 84
85 } // namespace gles2 85 } // namespace gles2
86 } // namespace gpu 86 } // namespace gpu
87 87
88 88
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state.cc ('k') | gpu/command_buffer/service/framebuffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698