OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common_decoder.h" | 5 #include "gpu/command_buffer/service/common_decoder.h" |
6 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 6 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace gpu { | 9 namespace gpu { |
10 | 10 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 const int32 MockCommandBufferEngine::kInvalidOffset; | 150 const int32 MockCommandBufferEngine::kInvalidOffset; |
151 | 151 |
152 class CommonDecoderTest : public testing::Test { | 152 class CommonDecoderTest : public testing::Test { |
153 protected: | 153 protected: |
154 void SetUp() override { decoder_.set_engine(&engine_); } | 154 void SetUp() override { decoder_.set_engine(&engine_); } |
155 | 155 |
156 void TearDown() override {} | 156 void TearDown() override {} |
157 | 157 |
158 template <typename T> | 158 template <typename T> |
159 error::Error ExecuteCmd(const T& cmd) { | 159 error::Error ExecuteCmd(const T& cmd) { |
160 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); | 160 static_assert(T::kArgFlags == cmd::kFixed, |
| 161 "T::kArgFlags should equal cmd::kFixed"); |
161 return decoder_.DoCommands( | 162 return decoder_.DoCommands( |
162 1, (const void*)&cmd, ComputeNumEntries(sizeof(cmd)), 0); | 163 1, (const void*)&cmd, ComputeNumEntries(sizeof(cmd)), 0); |
163 } | 164 } |
164 | 165 |
165 template <typename T> | 166 template <typename T> |
166 error::Error ExecuteImmediateCmd(const T& cmd, size_t data_size) { | 167 error::Error ExecuteImmediateCmd(const T& cmd, size_t data_size) { |
167 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 168 static_assert(T::kArgFlags == cmd::kAtLeastN, |
| 169 "T::kArgFlags should equal cmd::kAtLeastN"); |
168 return decoder_.DoCommands( | 170 return decoder_.DoCommands( |
169 1, (const void*)&cmd, ComputeNumEntries(sizeof(cmd) + data_size), 0); | 171 1, (const void*)&cmd, ComputeNumEntries(sizeof(cmd) + data_size), 0); |
170 } | 172 } |
171 | 173 |
172 MockCommandBufferEngine engine_; | 174 MockCommandBufferEngine engine_; |
173 TestCommonDecoder decoder_; | 175 TestCommonDecoder decoder_; |
174 }; | 176 }; |
175 | 177 |
176 TEST_F(CommonDecoderTest, Initialize) { | 178 TEST_F(CommonDecoderTest, Initialize) { |
177 EXPECT_EQ(0, engine_.GetGetOffset()); | 179 EXPECT_EQ(0, engine_.GetGetOffset()); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory); | 497 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory); |
496 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 498 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
497 | 499 |
498 // Check that it fails if the size is invalid | 500 // Check that it fails if the size is invalid |
499 cmd.Init(kBucketId, 0, sizeof(kData) + 1, | 501 cmd.Init(kBucketId, 0, sizeof(kData) + 1, |
500 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory); | 502 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory); |
501 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 503 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
502 } | 504 } |
503 | 505 |
504 } // namespace gpu | 506 } // namespace gpu |
OLD | NEW |