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

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper_test.cc

Issue 465099: Removed command buffer's last dependency on NPAPI.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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
OLDNEW
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 20 matching lines...) Expand all
31 31
32 32
33 // Tests for the Command Buffer Helper. 33 // Tests for the Command Buffer Helper.
34 34
35 #include "base/at_exit.h" 35 #include "base/at_exit.h"
36 #include "base/message_loop.h" 36 #include "base/message_loop.h"
37 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 37 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
38 #include "gpu/command_buffer/service/mocks.h" 38 #include "gpu/command_buffer/service/mocks.h"
39 #include "gpu/command_buffer/service/command_buffer_service.h" 39 #include "gpu/command_buffer/service/command_buffer_service.h"
40 #include "gpu/command_buffer/service/gpu_processor.h" 40 #include "gpu/command_buffer/service/gpu_processor.h"
41 #include "gpu/np_utils/np_object_pointer.h"
42 #include "gpu/np_utils/np_browser_stub.h"
43 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
44 42
45 namespace command_buffer { 43 namespace command_buffer {
46 44
47 using command_buffer::CommandBufferService; 45 using command_buffer::CommandBufferService;
48 using command_buffer::GPUProcessor; 46 using command_buffer::GPUProcessor;
49 using np_utils::NPCreateObject;
50 using np_utils::NPObjectPointer;
51 using testing::Return; 47 using testing::Return;
52 using testing::Mock; 48 using testing::Mock;
53 using testing::Truly; 49 using testing::Truly;
54 using testing::Sequence; 50 using testing::Sequence;
55 using testing::DoAll; 51 using testing::DoAll;
56 using testing::Invoke; 52 using testing::Invoke;
57 using testing::_; 53 using testing::_;
58 54
59 const int32 kNumCommandEntries = 10; 55 const int32 kNumCommandEntries = 10;
60 const int32 kCommandBufferSizeBytes = kNumCommandEntries * sizeof(int32); 56 const int32 kCommandBufferSizeBytes = kNumCommandEntries * sizeof(int32);
61 57
62 // Test fixture for CommandBufferHelper test - Creates a CommandBufferHelper, 58 // Test fixture for CommandBufferHelper test - Creates a CommandBufferHelper,
63 // using a CommandBufferEngine with a mock AsyncAPIInterface for its interface 59 // using a CommandBufferEngine with a mock AsyncAPIInterface for its interface
64 // (calling it directly, not through the RPC mechanism). 60 // (calling it directly, not through the RPC mechanism).
65 class CommandBufferHelperTest : public testing::Test { 61 class CommandBufferHelperTest : public testing::Test {
66 protected: 62 protected:
67 virtual void SetUp() { 63 virtual void SetUp() {
68 api_mock_.reset(new AsyncAPIMock); 64 api_mock_.reset(new AsyncAPIMock);
69 // ignore noops in the mock - we don't want to inspect the internals of the 65 // ignore noops in the mock - we don't want to inspect the internals of the
70 // helper. 66 // helper.
71 EXPECT_CALL(*api_mock_, DoCommand(0, 0, _)) 67 EXPECT_CALL(*api_mock_, DoCommand(0, 0, _))
72 .WillRepeatedly(Return(parse_error::kParseNoError)); 68 .WillRepeatedly(Return(parse_error::kParseNoError));
73 69
74 ::base::SharedMemory* ring_buffer = new ::base::SharedMemory; 70 base::SharedMemory* ring_buffer = new base::SharedMemory;
75 ring_buffer->Create(std::wstring(), false, false, kCommandBufferSizeBytes); 71 ring_buffer->Create(std::wstring(), false, false, kCommandBufferSizeBytes);
76 ring_buffer->Map(1024); 72 ring_buffer->Map(1024);
77 73
78 command_buffer_.reset(new CommandBufferService); 74 command_buffer_.reset(new CommandBufferService);
79 command_buffer_->Initialize(ring_buffer); 75 command_buffer_->Initialize(ring_buffer);
80 76
81 parser_ = new command_buffer::CommandParser(ring_buffer->memory(), 77 parser_ = new command_buffer::CommandParser(ring_buffer->memory(),
82 kCommandBufferSizeBytes, 78 kCommandBufferSizeBytes,
83 0, 79 0,
84 kCommandBufferSizeBytes, 80 kCommandBufferSizeBytes,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // we're on the bottom side, check we are below get. 131 // we're on the bottom side, check we are below get.
136 EXPECT_GT(parser_get, limit); 132 EXPECT_GT(parser_get, limit);
137 } 133 }
138 } 134 }
139 } 135 }
140 136
141 CommandBufferOffset get_helper_put() { return helper_->put_; } 137 CommandBufferOffset get_helper_put() { return helper_->put_; }
142 138
143 base::AtExitManager at_exit_manager_; 139 base::AtExitManager at_exit_manager_;
144 MessageLoop message_loop_; 140 MessageLoop message_loop_;
145 np_utils::StubNPBrowser browser_;
146 scoped_ptr<AsyncAPIMock> api_mock_; 141 scoped_ptr<AsyncAPIMock> api_mock_;
147 scoped_ptr<CommandBufferService> command_buffer_; 142 scoped_ptr<CommandBufferService> command_buffer_;
148 command_buffer::CommandParser* parser_; 143 command_buffer::CommandParser* parser_;
149 scoped_ptr<CommandBufferHelper> helper_; 144 scoped_ptr<CommandBufferHelper> helper_;
150 Sequence sequence_; 145 Sequence sequence_;
151 }; 146 };
152 147
153 // Checks that commands in the buffer are properly executed, and that the 148 // Checks that commands in the buffer are properly executed, and that the
154 // status/error stay valid. 149 // status/error stay valid.
155 TEST_F(CommandBufferHelperTest, TestCommandProcessing) { 150 TEST_F(CommandBufferHelperTest, TestCommandProcessing) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 289
295 // Check that the commands did happen. 290 // Check that the commands did happen.
296 Mock::VerifyAndClearExpectations(api_mock_.get()); 291 Mock::VerifyAndClearExpectations(api_mock_.get());
297 292
298 // Check the error status. 293 // Check the error status.
299 EXPECT_FALSE(command_buffer_->GetErrorStatus()); 294 EXPECT_FALSE(command_buffer_->GetErrorStatus());
300 EXPECT_EQ(parse_error::kParseNoError, command_buffer_->ResetParseError()); 295 EXPECT_EQ(parse_error::kParseNoError, command_buffer_->ResetParseError());
301 } 296 }
302 297
303 } // namespace command_buffer 298 } // namespace command_buffer
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.cc ('k') | gpu/command_buffer/client/fenced_allocator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698