Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_unittest_valuebuffer.cc
blob47e6a6b8a7a4fc4f8d363cb669567043b91da49b
1 // Copyright 2014 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
7 #include "base/command_line.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
11 #include "gpu/command_buffer/service/test_helper.h"
12 #include "gpu/command_buffer/service/valuebuffer_manager.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_mock.h"
16 #include "ui/gl/gl_surface_stub.h"
18 using ::gfx::MockGLInterface;
19 using ::testing::_;
21 namespace gpu {
22 namespace gles2 {
24 using namespace cmds;
26 TEST_P(GLES2DecoderWithShaderTest, ValuebufferBasic) {
27 const uint32 kBufferId = 123;
28 ValueState valuestate;
29 valuestate.int_value[0] = 111;
30 valuestate.int_value[1] = 222;
31 valuebuffer_manager()->CreateValuebuffer(kBufferId);
32 pending_valuebuffer_state()->UpdateState(
33 GL_MOUSE_POSITION_CHROMIUM, valuestate);
34 BindValuebufferCHROMIUM cmd1;
35 cmd1.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, kBufferId);
36 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
37 SubscribeValueCHROMIUM cmd2;
38 cmd2.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, GL_MOUSE_POSITION_CHROMIUM);
39 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
40 PopulateSubscribedValuesCHROMIUM cmd3;
41 cmd3.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
42 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3));
43 EXPECT_CALL(*gl_, Uniform2iv(kUniform2RealLocation, 1, _)).Times(1);
44 UniformValuebufferCHROMIUM cmd4;
45 cmd4.Init(kUniform2FakeLocation, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
46 GL_MOUSE_POSITION_CHROMIUM);
47 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4));
50 TEST_P(GLES2DecoderWithShaderTest, SubscribeValuebufferNotBound) {
51 const uint32 kBufferId = 123;
52 ValueState valuestate;
53 valuestate.int_value[0] = 111;
54 valuestate.int_value[1] = 222;
55 valuebuffer_manager()->CreateValuebuffer(kBufferId);
56 pending_valuebuffer_state()->UpdateState(
57 GL_MOUSE_POSITION_CHROMIUM, valuestate);
58 SubscribeValueCHROMIUM cmd1;
59 cmd1.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, GL_MOUSE_POSITION_CHROMIUM);
60 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
61 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
64 TEST_P(GLES2DecoderWithShaderTest, PopulateValuebufferNoSubscription) {
65 const uint32 kBufferId = 123;
66 ValueState valuestate;
67 valuestate.int_value[0] = 111;
68 valuestate.int_value[1] = 222;
69 valuebuffer_manager()->CreateValuebuffer(kBufferId);
70 pending_valuebuffer_state()->UpdateState(
71 GL_MOUSE_POSITION_CHROMIUM, valuestate);
72 BindValuebufferCHROMIUM cmd1;
73 cmd1.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, kBufferId);
74 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
75 PopulateSubscribedValuesCHROMIUM cmd2;
76 cmd2.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
77 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
78 EXPECT_EQ(GL_NONE, GetGLError());
81 TEST_P(GLES2DecoderWithShaderTest, UniformValuebufferNoState) {
82 const uint32 kBufferId = 123;
83 ValueState valuestate;
84 valuestate.int_value[0] = 111;
85 valuestate.int_value[1] = 222;
86 valuebuffer_manager()->CreateValuebuffer(kBufferId);
87 pending_valuebuffer_state()->UpdateState(
88 GL_MOUSE_POSITION_CHROMIUM, valuestate);
89 BindValuebufferCHROMIUM cmd1;
90 cmd1.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, kBufferId);
91 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
92 SubscribeValueCHROMIUM cmd2;
93 cmd2.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, GL_MOUSE_POSITION_CHROMIUM);
94 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
95 EXPECT_CALL(*gl_, Uniform2iv(kUniform2RealLocation, 1, _)).Times(0);
96 UniformValuebufferCHROMIUM cmd3;
97 cmd3.Init(kUniform2FakeLocation, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
98 GL_MOUSE_POSITION_CHROMIUM);
99 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3));
100 EXPECT_EQ(GL_NONE, GetGLError());
103 TEST_P(GLES2DecoderWithShaderTest, UniformValuebufferInvalidLocation) {
104 const uint32 kBufferId = 123;
105 ValueState valuestate;
106 valuestate.int_value[0] = 111;
107 valuestate.int_value[1] = 222;
108 valuebuffer_manager()->CreateValuebuffer(kBufferId);
109 pending_valuebuffer_state()->UpdateState(
110 GL_MOUSE_POSITION_CHROMIUM, valuestate);
111 BindValuebufferCHROMIUM cmd1;
112 cmd1.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, kBufferId);
113 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
114 SubscribeValueCHROMIUM cmd2;
115 cmd2.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, GL_MOUSE_POSITION_CHROMIUM);
116 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
117 PopulateSubscribedValuesCHROMIUM cmd3;
118 cmd3.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
119 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3));
120 EXPECT_CALL(*gl_, Uniform2iv(kUniform2RealLocation, 1, _)).Times(0);
121 UniformValuebufferCHROMIUM cmd4;
122 cmd4.Init(kUniform1FakeLocation, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
123 GL_MOUSE_POSITION_CHROMIUM);
124 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4));
125 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
128 } // namespace gles2
129 } // namespace gpu