OLD | NEW |
1 // Copyright (c) 2011 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 // Tests for the command parser. | 5 // Tests for the command parser. |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "gpu/command_buffer/service/cmd_parser.h" | 9 #include "gpu/command_buffer/service/cmd_parser.h" |
10 #include "gpu/command_buffer/service/mocks.h" | 10 #include "gpu/command_buffer/service/mocks.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 parser->SetBuffer(buffer(), shm_size, 0, command_buffer_size); | 53 parser->SetBuffer(buffer(), shm_size, 0, command_buffer_size); |
54 return parser; | 54 return parser; |
55 } | 55 } |
56 | 56 |
57 unsigned int buffer_entry_count() { return 20; } | 57 unsigned int buffer_entry_count() { return 20; } |
58 AsyncAPIMock *api_mock() { return api_mock_.get(); } | 58 AsyncAPIMock *api_mock() { return api_mock_.get(); } |
59 CommandBufferEntry *buffer() { return buffer_.get(); } | 59 CommandBufferEntry *buffer() { return buffer_.get(); } |
60 private: | 60 private: |
61 unsigned int buffer_entry_count_; | 61 unsigned int buffer_entry_count_; |
62 scoped_ptr<AsyncAPIMock> api_mock_; | 62 scoped_ptr<AsyncAPIMock> api_mock_; |
63 scoped_array<CommandBufferEntry> buffer_; | 63 scoped_ptr<CommandBufferEntry[]> buffer_; |
64 Sequence sequence_; | 64 Sequence sequence_; |
65 }; | 65 }; |
66 | 66 |
67 // Tests initialization conditions. | 67 // Tests initialization conditions. |
68 TEST_F(CommandParserTest, TestInit) { | 68 TEST_F(CommandParserTest, TestInit) { |
69 scoped_ptr<CommandParser> parser(MakeParser(10)); | 69 scoped_ptr<CommandParser> parser(MakeParser(10)); |
70 EXPECT_EQ(0, parser->get()); | 70 EXPECT_EQ(0, parser->get()); |
71 EXPECT_EQ(0, parser->put()); | 71 EXPECT_EQ(0, parser->put()); |
72 EXPECT_TRUE(parser->IsEmpty()); | 72 EXPECT_TRUE(parser->IsEmpty()); |
73 } | 73 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 CommandBufferEntry param_array[1]; | 300 CommandBufferEntry param_array[1]; |
301 param_array[0].value_int32 = 456; | 301 param_array[0].value_int32 = 456; |
302 | 302 |
303 parser->set_put(put); | 303 parser->set_put(put); |
304 AddDoCommandExpect(error::kNoError, 123, 1, param_array); | 304 AddDoCommandExpect(error::kNoError, 123, 1, param_array); |
305 EXPECT_EQ(error::kNoError, parser->ProcessAllCommands()); | 305 EXPECT_EQ(error::kNoError, parser->ProcessAllCommands()); |
306 // We should have advanced 2 entries | 306 // We should have advanced 2 entries |
307 EXPECT_EQ(2, parser->get()); | 307 EXPECT_EQ(2, parser->get()); |
308 Mock::VerifyAndClearExpectations(api_mock()); | 308 Mock::VerifyAndClearExpectations(api_mock()); |
309 | 309 |
310 scoped_array<CommandBufferEntry> buffer2(new CommandBufferEntry[2]); | 310 scoped_ptr<CommandBufferEntry[]> buffer2(new CommandBufferEntry[2]); |
311 parser->SetBuffer( | 311 parser->SetBuffer( |
312 buffer2.get(), sizeof(CommandBufferEntry) * 2, 0, | 312 buffer2.get(), sizeof(CommandBufferEntry) * 2, 0, |
313 sizeof(CommandBufferEntry) * 2); | 313 sizeof(CommandBufferEntry) * 2); |
314 // The put and get should have reset to 0. | 314 // The put and get should have reset to 0. |
315 EXPECT_EQ(0, parser->get()); | 315 EXPECT_EQ(0, parser->get()); |
316 EXPECT_EQ(0, parser->put()); | 316 EXPECT_EQ(0, parser->put()); |
317 } | 317 } |
318 | 318 |
319 } // namespace gpu | 319 } // namespace gpu |
OLD | NEW |