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

Side by Side Diff: gpu/command_buffer/common/command_buffer_shared_test.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 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
« no previous file with comments | « gpu/command_buffer/common/buffer.cc ('k') | gpu/command_buffer/service/buffer_manager.h » ('j') | 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 // 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 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory>
12
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace gpu { 19 namespace gpu {
19 20
20 class CommandBufferSharedTest : public testing::Test { 21 class CommandBufferSharedTest : public testing::Test {
21 protected: 22 protected:
22 void SetUp() override { 23 void SetUp() override {
23 shared_state_.reset(new CommandBufferSharedState()); 24 shared_state_.reset(new CommandBufferSharedState());
24 shared_state_->Initialize(); 25 shared_state_->Initialize();
25 } 26 }
26 27
27 scoped_ptr<CommandBufferSharedState> shared_state_; 28 std::unique_ptr<CommandBufferSharedState> shared_state_;
28 }; 29 };
29 30
30 TEST_F(CommandBufferSharedTest, TestBasic) { 31 TEST_F(CommandBufferSharedTest, TestBasic) {
31 CommandBuffer::State state; 32 CommandBuffer::State state;
32 33
33 shared_state_->Read(&state); 34 shared_state_->Read(&state);
34 35
35 EXPECT_LT(state.generation, 0x80000000); 36 EXPECT_LT(state.generation, 0x80000000);
36 EXPECT_EQ(state.get_offset, 0); 37 EXPECT_EQ(state.get_offset, 0);
37 EXPECT_EQ(state.token, -1); 38 EXPECT_EQ(state.token, -1);
(...skipping 12 matching lines...) Expand all
50 state.error = static_cast<gpu::error::Error>(i + 3); 51 state.error = static_cast<gpu::error::Error>(i + 3);
51 // Ensure that the producer doesn't update the buffer until after the 52 // Ensure that the producer doesn't update the buffer until after the
52 // consumer reads from it. 53 // consumer reads from it.
53 EXPECT_EQ(buffer[i], 0); 54 EXPECT_EQ(buffer[i], 0);
54 55
55 shared_state->Write(state); 56 shared_state->Write(state);
56 } 57 }
57 } 58 }
58 59
59 TEST_F(CommandBufferSharedTest, TestConsistency) { 60 TEST_F(CommandBufferSharedTest, TestConsistency) {
60 scoped_ptr<int32_t[]> buffer; 61 std::unique_ptr<int32_t[]> buffer;
61 buffer.reset(new int32_t[kSize]); 62 buffer.reset(new int32_t[kSize]);
62 base::Thread consumer("Reader Thread"); 63 base::Thread consumer("Reader Thread");
63 64
64 memset(buffer.get(), 0, kSize * sizeof(int32_t)); 65 memset(buffer.get(), 0, kSize * sizeof(int32_t));
65 66
66 consumer.Start(); 67 consumer.Start();
67 consumer.task_runner()->PostTask( 68 consumer.task_runner()->PostTask(
68 FROM_HERE, base::Bind(&WriteToState, buffer.get(), shared_state_.get())); 69 FROM_HERE, base::Bind(&WriteToState, buffer.get(), shared_state_.get()));
69 70
70 CommandBuffer::State last_state; 71 CommandBuffer::State last_state;
(...skipping 17 matching lines...) Expand all
88 EXPECT_EQ(state.error, state.get_offset + 2); 89 EXPECT_EQ(state.error, state.get_offset + 2);
89 90
90 if (state.get_offset == kSize) 91 if (state.get_offset == kSize)
91 break; 92 break;
92 } 93 }
93 } 94 }
94 } 95 }
95 96
96 } // namespace gpu 97 } // namespace gpu
97 98
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/buffer.cc ('k') | gpu/command_buffer/service/buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698