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

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

Issue 1129903002: gpu: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 5 years, 7 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 | « no previous file | gpu/command_buffer/common/gles2_cmd_format_test.cc » ('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 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 namespace gpu { 16 namespace gpu {
14 17
15 class CommandBufferSharedTest : public testing::Test { 18 class CommandBufferSharedTest : public testing::Test {
16 protected: 19 protected:
17 void SetUp() override { 20 void SetUp() override {
18 shared_state_.reset(new CommandBufferSharedState()); 21 shared_state_.reset(new CommandBufferSharedState());
19 shared_state_->Initialize(); 22 shared_state_->Initialize();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 56 }
54 57
55 TEST_F(CommandBufferSharedTest, TestConsistency) { 58 TEST_F(CommandBufferSharedTest, TestConsistency) {
56 scoped_ptr<int32[]> buffer; 59 scoped_ptr<int32[]> buffer;
57 buffer.reset(new int32[kSize]); 60 buffer.reset(new int32[kSize]);
58 base::Thread consumer("Reader Thread"); 61 base::Thread consumer("Reader Thread");
59 62
60 memset(buffer.get(), 0, kSize * sizeof(int32)); 63 memset(buffer.get(), 0, kSize * sizeof(int32));
61 64
62 consumer.Start(); 65 consumer.Start();
63 consumer.message_loop()->PostTask( 66 consumer.task_runner()->PostTask(
64 FROM_HERE, base::Bind(&WriteToState, buffer.get(), 67 FROM_HERE, base::Bind(&WriteToState, buffer.get(), shared_state_.get()));
65 shared_state_.get()));
66 68
67 CommandBuffer::State last_state; 69 CommandBuffer::State last_state;
68 while (1) { 70 while (1) {
69 CommandBuffer::State state = last_state; 71 CommandBuffer::State state = last_state;
70 72
71 shared_state_->Read(&state); 73 shared_state_->Read(&state);
72 74
73 if (state.generation < last_state.generation) 75 if (state.generation < last_state.generation)
74 continue; 76 continue;
75 77
76 if (state.get_offset >= 1) { 78 if (state.get_offset >= 1) {
77 buffer[state.get_offset - 1] = 1; 79 buffer[state.get_offset - 1] = 1;
78 // Check that the state is consistent 80 // Check that the state is consistent
79 EXPECT_LE(last_state.token, state.token); 81 EXPECT_LE(last_state.token, state.token);
80 EXPECT_LE(last_state.generation, state.generation); 82 EXPECT_LE(last_state.generation, state.generation);
81 last_state = state; 83 last_state = state;
82 EXPECT_EQ(state.token, state.get_offset - 2); 84 EXPECT_EQ(state.token, state.get_offset - 2);
83 EXPECT_EQ(state.generation, 85 EXPECT_EQ(state.generation,
84 static_cast<unsigned int>(state.get_offset) + 1); 86 static_cast<unsigned int>(state.get_offset) + 1);
85 EXPECT_EQ(state.error, state.get_offset + 2); 87 EXPECT_EQ(state.error, state.get_offset + 2);
86 88
87 if (state.get_offset == kSize) 89 if (state.get_offset == kSize)
88 break; 90 break;
89 } 91 }
90 } 92 }
91 } 93 }
92 94
93 } // namespace gpu 95 } // namespace gpu
94 96
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_format_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698