OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 using testing::Return; | 43 using testing::Return; |
44 using testing::Mock; | 44 using testing::Mock; |
45 using testing::Truly; | 45 using testing::Truly; |
46 using testing::Sequence; | 46 using testing::Sequence; |
47 using testing::DoAll; | 47 using testing::DoAll; |
48 using testing::Invoke; | 48 using testing::Invoke; |
49 using testing::_; | 49 using testing::_; |
50 | 50 |
51 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a | 51 // Test fixture for FencedAllocator test - Creates a FencedAllocator, using a |
52 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling | 52 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling |
53 // it directly, not through the RPC mechanism), making sure NOOPs are ignored | 53 // it directly, not through the RPC mechanism), making sure Noops are ignored |
54 // and SET_TOKEN are properly forwarded to the engine. | 54 // and SetToken are properly forwarded to the engine. |
55 class FencedAllocatorTest : public testing::Test { | 55 class FencedAllocatorTest : public testing::Test { |
56 public: | 56 public: |
57 static const unsigned int kBufferSize = 1024; | 57 static const unsigned int kBufferSize = 1024; |
58 | 58 |
59 protected: | 59 protected: |
60 virtual void SetUp() { | 60 virtual void SetUp() { |
61 api_mock_.reset(new AsyncAPIMock); | 61 api_mock_.reset(new AsyncAPIMock); |
62 // ignore noops in the mock - we don't want to inspect the internals of the | 62 // ignore noops in the mock - we don't want to inspect the internals of the |
63 // helper. | 63 // helper. |
64 EXPECT_CALL(*api_mock_, DoCommand(NOOP, 0, _)) | 64 EXPECT_CALL(*api_mock_, DoCommand(kNoop, 0, _)) |
65 .WillRepeatedly(Return(BufferSyncInterface::PARSE_NO_ERROR)); | 65 .WillRepeatedly(Return(BufferSyncInterface::kParseNoError)); |
66 // Forward the SetToken calls to the engine | 66 // Forward the SetToken calls to the engine |
67 EXPECT_CALL(*api_mock(), DoCommand(SET_TOKEN, 1, _)) | 67 EXPECT_CALL(*api_mock(), DoCommand(kSetToken, 1, _)) |
68 .WillRepeatedly(DoAll(Invoke(api_mock(), &AsyncAPIMock::SetToken), | 68 .WillRepeatedly(DoAll(Invoke(api_mock(), &AsyncAPIMock::SetToken), |
69 Return(BufferSyncInterface::PARSE_NO_ERROR))); | 69 Return(BufferSyncInterface::kParseNoError))); |
70 engine_.reset(new CommandBufferEngine(api_mock_.get())); | 70 engine_.reset(new CommandBufferEngine(api_mock_.get())); |
71 api_mock_->set_engine(engine_.get()); | 71 api_mock_->set_engine(engine_.get()); |
72 | 72 |
73 nacl::SocketAddress client_address = { "test-socket" }; | 73 nacl::SocketAddress client_address = { "test-socket" }; |
74 client_socket_ = nacl::BoundSocket(&client_address); | 74 client_socket_ = nacl::BoundSocket(&client_address); |
75 engine_->InitConnection(); | 75 engine_->InitConnection(); |
76 helper_.reset(new CommandBufferHelper(engine_.get())); | 76 helper_.reset(new CommandBufferHelper(engine_.get())); |
77 helper_->Init(100); | 77 helper_->Init(100); |
78 | 78 |
79 allocator_.reset(new FencedAllocator(kBufferSize, helper_.get())); | 79 allocator_.reset(new FencedAllocator(kBufferSize, helper_.get())); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 // Everything now has been freed... | 306 // Everything now has been freed... |
307 EXPECT_EQ(kBufferSize, allocator()->GetLargestFreeOrPendingSize()); | 307 EXPECT_EQ(kBufferSize, allocator()->GetLargestFreeOrPendingSize()); |
308 // ... for real. | 308 // ... for real. |
309 EXPECT_EQ(kBufferSize, allocator()->GetLargestFreeSize()); | 309 EXPECT_EQ(kBufferSize, allocator()->GetLargestFreeSize()); |
310 } | 310 } |
311 | 311 |
312 // Test fixture for FencedAllocatorWrapper test - Creates a | 312 // Test fixture for FencedAllocatorWrapper test - Creates a |
313 // FencedAllocatorWrapper, using a CommandBufferHelper with a mock | 313 // FencedAllocatorWrapper, using a CommandBufferHelper with a mock |
314 // AsyncAPIInterface for its interface (calling it directly, not through the | 314 // AsyncAPIInterface for its interface (calling it directly, not through the |
315 // RPC mechanism), making sure NOOPs are ignored and SET_TOKEN are properly | 315 // RPC mechanism), making sure Noops are ignored and SetToken are properly |
316 // forwarded to the engine. | 316 // forwarded to the engine. |
317 class FencedAllocatorWrapperTest : public testing::Test { | 317 class FencedAllocatorWrapperTest : public testing::Test { |
318 public: | 318 public: |
319 static const unsigned int kBufferSize = 1024; | 319 static const unsigned int kBufferSize = 1024; |
320 | 320 |
321 protected: | 321 protected: |
322 virtual void SetUp() { | 322 virtual void SetUp() { |
323 api_mock_.reset(new AsyncAPIMock); | 323 api_mock_.reset(new AsyncAPIMock); |
324 // ignore noops in the mock - we don't want to inspect the internals of the | 324 // ignore noops in the mock - we don't want to inspect the internals of the |
325 // helper. | 325 // helper. |
326 EXPECT_CALL(*api_mock_, DoCommand(NOOP, 0, _)) | 326 EXPECT_CALL(*api_mock_, DoCommand(kNoop, 0, _)) |
327 .WillRepeatedly(Return(BufferSyncInterface::PARSE_NO_ERROR)); | 327 .WillRepeatedly(Return(BufferSyncInterface::kParseNoError)); |
328 // Forward the SetToken calls to the engine | 328 // Forward the SetToken calls to the engine |
329 EXPECT_CALL(*api_mock(), DoCommand(SET_TOKEN, 1, _)) | 329 EXPECT_CALL(*api_mock(), DoCommand(kSetToken, 1, _)) |
330 .WillRepeatedly(DoAll(Invoke(api_mock(), &AsyncAPIMock::SetToken), | 330 .WillRepeatedly(DoAll(Invoke(api_mock(), &AsyncAPIMock::SetToken), |
331 Return(BufferSyncInterface::PARSE_NO_ERROR))); | 331 Return(BufferSyncInterface::kParseNoError))); |
332 engine_.reset(new CommandBufferEngine(api_mock_.get())); | 332 engine_.reset(new CommandBufferEngine(api_mock_.get())); |
333 api_mock_->set_engine(engine_.get()); | 333 api_mock_->set_engine(engine_.get()); |
334 | 334 |
335 nacl::SocketAddress client_address = { "test-socket" }; | 335 nacl::SocketAddress client_address = { "test-socket" }; |
336 client_socket_ = nacl::BoundSocket(&client_address); | 336 client_socket_ = nacl::BoundSocket(&client_address); |
337 engine_->InitConnection(); | 337 engine_->InitConnection(); |
338 helper_.reset(new CommandBufferHelper(engine_.get())); | 338 helper_.reset(new CommandBufferHelper(engine_.get())); |
339 helper_->Init(100); | 339 helper_->Init(100); |
340 | 340 |
341 // Though allocating this buffer isn't strictly necessary, it makes | 341 // Though allocating this buffer isn't strictly necessary, it makes |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // Free up everything. | 489 // Free up everything. |
490 for (unsigned int i = 0; i < kAllocCount; ++i) { | 490 for (unsigned int i = 0; i < kAllocCount; ++i) { |
491 allocator()->Free(pointers[i]); | 491 allocator()->Free(pointers[i]); |
492 EXPECT_TRUE(allocator()->CheckConsistency()); | 492 EXPECT_TRUE(allocator()->CheckConsistency()); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 | 496 |
497 } // namespace command_buffer | 497 } // namespace command_buffer |
498 } // namespace o3d | 498 } // namespace o3d |
OLD | NEW |