| 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 definitions for mock objects, used for testing. | 5 // This file contains definitions for mock objects, used for testing. |
| 6 | 6 |
| 7 // TODO(apatrick): This file "manually" defines some mock objects. Using gMock | 7 // TODO(apatrick): This file "manually" defines some mock objects. Using gMock |
| 8 // would be definitely preferable, unfortunately it doesn't work on Windows yet. | 8 // would be definitely preferable, unfortunately it doesn't work on Windows yet. |
| 9 | 9 |
| 10 #ifndef GPU_COMMAND_BUFFER_SERVICE_MOCKS_H_ | 10 #ifndef GPU_COMMAND_BUFFER_SERVICE_MOCKS_H_ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace gpu { | 27 namespace gpu { |
| 28 | 28 |
| 29 // Mocks an AsyncAPIInterface, using GMock. | 29 // Mocks an AsyncAPIInterface, using GMock. |
| 30 class AsyncAPIMock : public AsyncAPIInterface { | 30 class AsyncAPIMock : public AsyncAPIInterface { |
| 31 public: | 31 public: |
| 32 explicit AsyncAPIMock(bool default_do_commands); | 32 explicit AsyncAPIMock(bool default_do_commands); |
| 33 virtual ~AsyncAPIMock(); | 33 virtual ~AsyncAPIMock(); |
| 34 | 34 |
| 35 error::Error FakeDoCommands(unsigned int num_commands, | 35 error::Error FakeDoCommands(unsigned int num_commands, |
| 36 const void* buffer, | 36 const volatile void* buffer, |
| 37 int num_entries, | 37 int num_entries, |
| 38 int* entries_processed); | 38 int* entries_processed); |
| 39 | 39 |
| 40 // Predicate that matches args passed to DoCommand, by looking at the values. | 40 // Predicate that matches args passed to DoCommand, by looking at the values. |
| 41 class IsArgs { | 41 class IsArgs { |
| 42 public: | 42 public: |
| 43 IsArgs(unsigned int arg_count, const void* args) | 43 IsArgs(unsigned int arg_count, const volatile void* args) |
| 44 : arg_count_(arg_count), | 44 : arg_count_(arg_count), |
| 45 args_(static_cast<CommandBufferEntry*>(const_cast<void*>(args))) { | 45 args_(static_cast<volatile CommandBufferEntry*>( |
| 46 } | 46 const_cast<volatile void*>(args))) {} |
| 47 | 47 |
| 48 bool operator() (const void* _args) const { | 48 bool operator()(const volatile void* _args) const { |
| 49 const CommandBufferEntry* args = | 49 const volatile CommandBufferEntry* args = |
| 50 static_cast<const CommandBufferEntry*>(_args) + 1; | 50 static_cast<const volatile CommandBufferEntry*>(_args) + 1; |
| 51 for (unsigned int i = 0; i < arg_count_; ++i) { | 51 for (unsigned int i = 0; i < arg_count_; ++i) { |
| 52 if (args[i].value_uint32 != args_[i].value_uint32) return false; | 52 if (args[i].value_uint32 != args_[i].value_uint32) return false; |
| 53 } | 53 } |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 unsigned int arg_count_; | 58 unsigned int arg_count_; |
| 59 CommandBufferEntry *args_; | 59 volatile CommandBufferEntry* args_; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 MOCK_METHOD3(DoCommand, error::Error( | 62 MOCK_METHOD3(DoCommand, |
| 63 unsigned int command, | 63 error::Error(unsigned int command, |
| 64 unsigned int arg_count, | 64 unsigned int arg_count, |
| 65 const void* cmd_data)); | 65 const volatile void* cmd_data)); |
| 66 | 66 |
| 67 MOCK_METHOD4(DoCommands, | 67 MOCK_METHOD4(DoCommands, |
| 68 error::Error(unsigned int num_commands, | 68 error::Error(unsigned int num_commands, |
| 69 const void* buffer, | 69 const volatile void* buffer, |
| 70 int num_entries, | 70 int num_entries, |
| 71 int* entries_processed)); | 71 int* entries_processed)); |
| 72 | 72 |
| 73 const char* GetCommandName(unsigned int command_id) const { | 73 const char* GetCommandName(unsigned int command_id) const { |
| 74 return ""; | 74 return ""; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 // Sets the engine, to forward SetToken commands to it. | 77 // Sets the engine, to forward SetToken commands to it. |
| 78 void set_engine(CommandBufferEngine *engine) { engine_ = engine; } | 78 void set_engine(CommandBufferEngine *engine) { engine_ = engine; } |
| 79 | 79 |
| 80 // Forwards the SetToken commands to the engine. | 80 // Forwards the SetToken commands to the engine. |
| 81 void SetToken(unsigned int command, | 81 void SetToken(unsigned int command, |
| 82 unsigned int arg_count, | 82 unsigned int arg_count, |
| 83 const void* _args); | 83 const volatile void* _args); |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 CommandBufferEngine *engine_; | 86 CommandBufferEngine *engine_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 namespace gles2 { | 89 namespace gles2 { |
| 90 | 90 |
| 91 class MockShaderTranslator : public ShaderTranslatorInterface { | 91 class MockShaderTranslator : public ShaderTranslatorInterface { |
| 92 public: | 92 public: |
| 93 MockShaderTranslator(); | 93 MockShaderTranslator(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 private: | 158 private: |
| 159 friend class ::testing::StrictMock<MockMemoryTracker>; | 159 friend class ::testing::StrictMock<MockMemoryTracker>; |
| 160 friend class base::RefCounted< ::testing::StrictMock<MockMemoryTracker> >; | 160 friend class base::RefCounted< ::testing::StrictMock<MockMemoryTracker> >; |
| 161 virtual ~MockMemoryTracker(); | 161 virtual ~MockMemoryTracker(); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 } // namespace gles2 | 164 } // namespace gles2 |
| 165 } // namespace gpu | 165 } // namespace gpu |
| 166 | 166 |
| 167 #endif // GPU_COMMAND_BUFFER_SERVICE_MOCKS_H_ | 167 #endif // GPU_COMMAND_BUFFER_SERVICE_MOCKS_H_ |
| OLD | NEW |