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

Side by Side Diff: o3d/gpu_plugin/command_buffer_unittest.cc

Issue 216043: Added support for registering additional shared memory objects (textures and ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « o3d/gpu_plugin/command_buffer_mock.h ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "base/thread.h"
5 #include "o3d/gpu_plugin/command_buffer.h" 6 #include "o3d/gpu_plugin/command_buffer.h"
6 #include "o3d/gpu_plugin/np_utils/dynamic_np_object.h" 7 #include "o3d/gpu_plugin/np_utils/dynamic_np_object.h"
7 #include "o3d/gpu_plugin/np_utils/np_browser_mock.h" 8 #include "o3d/gpu_plugin/np_utils/np_browser_mock.h"
8 #include "o3d/gpu_plugin/np_utils/np_object_mock.h" 9 #include "o3d/gpu_plugin/np_utils/np_object_mock.h"
9 #include "o3d/gpu_plugin/np_utils/np_object_pointer.h" 10 #include "o3d/gpu_plugin/np_utils/np_object_pointer.h"
10 #include "o3d/gpu_plugin/system_services/shared_memory_mock.h" 11 #include "o3d/gpu_plugin/system_services/shared_memory_mock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 14
14 using testing::_; 15 using testing::_;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 152
152 command_buffer_->SetGetOffset(2); 153 command_buffer_->SetGetOffset(2);
153 EXPECT_EQ(2, command_buffer_->GetGetOffset()); 154 EXPECT_EQ(2, command_buffer_->GetGetOffset());
154 EXPECT_CALL(*put_offset_change_callback, RunWithParams(_)); 155 EXPECT_CALL(*put_offset_change_callback, RunWithParams(_));
155 EXPECT_EQ(2, command_buffer_->SyncOffsets(6)); 156 EXPECT_EQ(2, command_buffer_->SyncOffsets(6));
156 157
157 EXPECT_EQ(-1, command_buffer_->SyncOffsets(-1)); 158 EXPECT_EQ(-1, command_buffer_->SyncOffsets(-1));
158 EXPECT_EQ(-1, command_buffer_->SyncOffsets(1024)); 159 EXPECT_EQ(-1, command_buffer_->SyncOffsets(1024));
159 } 160 }
160 161
162 TEST_F(CommandBufferTest, ZeroHandleMapsToNull) {
163 EXPECT_TRUE(NULL == command_buffer_->GetRegisteredObject(0).Get());
164 }
165
166 TEST_F(CommandBufferTest, RegisteringNullObjectReturnsZero) {
167 EXPECT_EQ(0, command_buffer_->RegisterObject(NPObjectPointer<NPObject>()));
168 }
169
170 TEST_F(CommandBufferTest, RegistersDistinctNonZeroHandlesForObject) {
171 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
172 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
173 EXPECT_EQ(2, command_buffer_->RegisterObject(window_object_));
174 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(2));
175 }
176
177 TEST_F(CommandBufferTest, RegisterObjectReusesUnregisteredHandles) {
178 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
179 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
180 EXPECT_EQ(2, command_buffer_->RegisterObject(window_object_));
181 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(2));
182 command_buffer_->UnregisterObject(window_object_, 1);
183 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
184 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
185 EXPECT_EQ(3, command_buffer_->RegisterObject(window_object_));
186 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(3));
187 }
188
189 TEST_F(CommandBufferTest, CannotUnregisterHandleZero) {
190 command_buffer_->UnregisterObject(window_object_, 0);
191 EXPECT_TRUE(NULL == command_buffer_->GetRegisteredObject(0).Get());
192 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
193 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
194 }
195
196 TEST_F(CommandBufferTest, CannotUnregisterNegativeHandles) {
197 command_buffer_->UnregisterObject(window_object_, -1);
198 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
199 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
200 }
201
202 TEST_F(CommandBufferTest, CannotUnregisterUnregisteredHandles) {
203 command_buffer_->UnregisterObject(window_object_, 1);
204 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
205 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
206 }
207
208 TEST_F(CommandBufferTest,
209 CannotUnregisterHandleWithoutDemonstratingAccessToObject) {
210 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
211 command_buffer_->UnregisterObject(chromium_object_, 1);
212 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
213 EXPECT_EQ(2, command_buffer_->RegisterObject(window_object_));
214 }
215
216 // Testing this case specifically because there is an optimization that takes
217 // a different code path in this case.
218 TEST_F(CommandBufferTest, UnregistersLastRegisteredHandle) {
219 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
220 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
221 command_buffer_->UnregisterObject(window_object_, 1);
222 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
223 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
224 }
225
226 // Testing this case specifically because there is an optimization that takes
227 // a different code path in this case.
228 TEST_F(CommandBufferTest, UnregistersTwoLastRegisteredHandles) {
229 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
230 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
231 EXPECT_EQ(2, command_buffer_->RegisterObject(window_object_));
232 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(2));
233 command_buffer_->UnregisterObject(window_object_, 2);
234 command_buffer_->UnregisterObject(window_object_, 1);
235 EXPECT_EQ(1, command_buffer_->RegisterObject(window_object_));
236 EXPECT_EQ(window_object_, command_buffer_->GetRegisteredObject(1));
237 }
238
161 } // namespace gpu_plugin 239 } // namespace gpu_plugin
162 } // namespace o3d 240 } // namespace o3d
OLDNEW
« no previous file with comments | « o3d/gpu_plugin/command_buffer_mock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698