| 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 // This file contains the tests for the CommandBufferSharedState class. | 5 // This file contains the tests for the CommandBufferSharedState class. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/common/command_buffer_shared.h" | 7 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 state.error = static_cast<gpu::error::Error>(i + 3); | 48 state.error = static_cast<gpu::error::Error>(i + 3); |
| 49 // Ensure that the producer doesn't update the buffer until after the | 49 // Ensure that the producer doesn't update the buffer until after the |
| 50 // consumer reads from it. | 50 // consumer reads from it. |
| 51 EXPECT_EQ(buffer[i], 0); | 51 EXPECT_EQ(buffer[i], 0); |
| 52 | 52 |
| 53 shared_state->Write(state); | 53 shared_state->Write(state); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 TEST_F(CommandBufferSharedTest, TestConsistency) { | 57 TEST_F(CommandBufferSharedTest, TestConsistency) { |
| 58 scoped_array<int32> buffer; | 58 scoped_ptr<int32[]> buffer; |
| 59 buffer.reset(new int32[kSize]); | 59 buffer.reset(new int32[kSize]); |
| 60 base::Thread consumer("Reader Thread"); | 60 base::Thread consumer("Reader Thread"); |
| 61 | 61 |
| 62 memset(buffer.get(), 0, kSize * sizeof(int32)); | 62 memset(buffer.get(), 0, kSize * sizeof(int32)); |
| 63 | 63 |
| 64 consumer.Start(); | 64 consumer.Start(); |
| 65 consumer.message_loop()->PostTask( | 65 consumer.message_loop()->PostTask( |
| 66 FROM_HERE, base::Bind(&WriteToState, buffer.get(), | 66 FROM_HERE, base::Bind(&WriteToState, buffer.get(), |
| 67 shared_state_.get())); | 67 shared_state_.get())); |
| 68 | 68 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 87 EXPECT_EQ(state.error, state.get_offset + 2); | 87 EXPECT_EQ(state.error, state.get_offset + 2); |
| 88 | 88 |
| 89 if (state.get_offset == kSize) | 89 if (state.get_offset == kSize) |
| 90 break; | 90 break; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace gpu | 95 } // namespace gpu |
| 96 | 96 |
| OLD | NEW |