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

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

Issue 11613021: Removing the JumpRelative, Call, CallRelative and Return commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use Noops instead of Jump; Remove Jump command. Created 7 years, 11 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
« no previous file with comments | « gpu/command_buffer/service/common_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 TEST_F(CommonDecoderTest, SetToken) { 206 TEST_F(CommonDecoderTest, SetToken) {
207 cmd::SetToken cmd; 207 cmd::SetToken cmd;
208 const int32 kTokenId = 123; 208 const int32 kTokenId = 123;
209 EXPECT_EQ(0, engine_.token()); 209 EXPECT_EQ(0, engine_.token());
210 cmd.Init(kTokenId); 210 cmd.Init(kTokenId);
211 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 211 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
212 EXPECT_EQ(kTokenId, engine_.token()); 212 EXPECT_EQ(kTokenId, engine_.token());
213 } 213 }
214 214
215 TEST_F(CommonDecoderTest, Jump) {
216 cmd::Jump cmd;
217 // Check valid args succeed.
218 cmd.Init(MockCommandBufferEngine::kValidOffset);
219 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
220 EXPECT_EQ(MockCommandBufferEngine::kValidOffset,
221 engine_.GetGetOffset());
222 // Check invalid offset fails.
223 cmd.Init(MockCommandBufferEngine::kInvalidOffset);
224 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
225 EXPECT_EQ(MockCommandBufferEngine::kValidOffset,
226 engine_.GetGetOffset());
227 // Check negative offset fails
228 cmd.Init(-1);
229 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
230 }
231
232 // NOTE: The read_pointer checks for relative commands do not take into account
233 // that the actual implementation of CommandBufferEngine uses the parse
234 // which will advance the read pointer to the start of the next command.
235
236 TEST_F(CommonDecoderTest, JumpRelative) {
237 cmd::JumpRelative cmd;
238 // Check valid positive offset succeeds.
239 const int32 kPositiveOffset = 16;
240 cmd.Init(kPositiveOffset);
241 int32 read_pointer = engine_.GetGetOffset();
242 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
243 // See note above.
244 EXPECT_EQ(read_pointer + kPositiveOffset, engine_.GetGetOffset());
245 // Check valid negative offset succeeds.
246 const int32 kNegativeOffset = -8;
247 read_pointer = engine_.GetGetOffset();
248 cmd.Init(kNegativeOffset);
249 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
250 // See note above.
251 EXPECT_EQ(read_pointer + kNegativeOffset, engine_.GetGetOffset());
252 // Check invalid offset fails.
253 cmd.Init(MockCommandBufferEngine::kInvalidOffset);
254 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
255 // See note above.
256 EXPECT_EQ(read_pointer + kNegativeOffset, engine_.GetGetOffset());
257 // Check invalid negative offset fails.
258 const int32 kInvalidNegativeOffset = -kPositiveOffset + kNegativeOffset - 1;
259 cmd.Init(kInvalidNegativeOffset);
260 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
261 }
262
263 TEST_F(CommonDecoderTest, Call) {
264 cmd::Call cmd;
265 // Check valid args succeed.
266 cmd.Init(MockCommandBufferEngine::kValidOffset);
267 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
268 EXPECT_EQ(MockCommandBufferEngine::kValidOffset,
269 engine_.GetGetOffset());
270 // Check invalid offset fails.
271 cmd.Init(MockCommandBufferEngine::kInvalidOffset);
272 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
273 EXPECT_EQ(MockCommandBufferEngine::kValidOffset,
274 engine_.GetGetOffset());
275 // Check negative offset fails
276 cmd.Init(-1);
277 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
278 // Check that the call values are on the stack.
279 cmd::Return return_cmd;
280 return_cmd.Init();
281 EXPECT_EQ(error::kNoError, ExecuteCmd(return_cmd));
282 EXPECT_EQ(0, engine_.GetGetOffset());
283 // Check that stack overflow fails.
284 cmd.Init(MockCommandBufferEngine::kValidOffset);
285 for (unsigned int ii = 0; ii < CommonDecoder::kMaxStackDepth; ++ii) {
286 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
287 }
288 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
289 }
290
291 TEST_F(CommonDecoderTest, CallRelative) {
292 cmd::CallRelative cmd;
293 // Check valid positive offset succeeds.
294 const int32 kPositiveOffset = 16;
295 cmd.Init(kPositiveOffset);
296 int32 read_pointer_1 = engine_.GetGetOffset();
297 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
298 // See note above.
299 EXPECT_EQ(read_pointer_1 + kPositiveOffset, engine_.GetGetOffset());
300 // Check valid negative offset succeeds.
301 const int32 kNegativeOffset = -8;
302 int32 read_pointer_2 = engine_.GetGetOffset();
303 cmd.Init(kNegativeOffset);
304 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
305 // See note above.
306 EXPECT_EQ(read_pointer_2 + kNegativeOffset, engine_.GetGetOffset());
307 // Check invalid offset fails.
308 cmd.Init(MockCommandBufferEngine::kInvalidOffset);
309 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
310 // See note above.
311 EXPECT_EQ(read_pointer_2 + kNegativeOffset, engine_.GetGetOffset());
312 // Check invalid negative offset fails.
313 const int32 kInvalidNegativeOffset = -kPositiveOffset + kNegativeOffset - 1;
314 cmd.Init(kInvalidNegativeOffset);
315 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
316
317 // Check that the call values are on the stack.
318 cmd::Return return_cmd;
319 return_cmd.Init();
320 EXPECT_EQ(error::kNoError, ExecuteCmd(return_cmd));
321 // See note above.
322 EXPECT_EQ(read_pointer_1 + kPositiveOffset, engine_.GetGetOffset());
323
324 EXPECT_EQ(error::kNoError, ExecuteCmd(return_cmd));
325 // See note above.
326 EXPECT_EQ(0, engine_.GetGetOffset());
327 // Check that stack overflow fails.
328 cmd.Init(kPositiveOffset);
329 for (unsigned int ii = 0; ii < CommonDecoder::kMaxStackDepth; ++ii) {
330 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
331 }
332 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
333 }
334
335 TEST_F(CommonDecoderTest, Return) {
336 // Success is tested by Call and CallRelative
337 // Test that an empty stack fails.
338 cmd::Return cmd;
339 cmd.Init();
340 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
341 }
342
343 TEST_F(CommonDecoderTest, SetBucketSize) { 215 TEST_F(CommonDecoderTest, SetBucketSize) {
344 cmd::SetBucketSize cmd; 216 cmd::SetBucketSize cmd;
345 const uint32 kBucketId = 123; 217 const uint32 kBucketId = 123;
346 const uint32 kBucketLength1 = 1234; 218 const uint32 kBucketLength1 = 1234;
347 const uint32 kBucketLength2 = 78; 219 const uint32 kBucketLength2 = 78;
348 // Check the bucket does not exist. 220 // Check the bucket does not exist.
349 EXPECT_TRUE(NULL == decoder_.GetBucket(kBucketId)); 221 EXPECT_TRUE(NULL == decoder_.GetBucket(kBucketId));
350 // Check we can create one. 222 // Check we can create one.
351 cmd.Init(kBucketId, kBucketLength1); 223 cmd.Init(kBucketId, kBucketLength1);
352 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 224 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory); 503 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory);
632 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 504 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
633 505
634 // Check that it fails if the size is invalid 506 // Check that it fails if the size is invalid
635 cmd.Init(kBucketId, 0, sizeof(kData) + 1, 507 cmd.Init(kBucketId, 0, sizeof(kData) + 1,
636 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory); 508 MockCommandBufferEngine::kValidShmId, kSomeOffsetInSharedMemory);
637 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 509 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
638 } 510 }
639 511
640 } // namespace gpu 512 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/common_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698