| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "command_buffer/service/cross/cmd_buffer_engine.h" | 45 #include "command_buffer/service/cross/cmd_buffer_engine.h" |
| 46 | 46 |
| 47 namespace o3d { | 47 namespace o3d { |
| 48 namespace command_buffer { | 48 namespace command_buffer { |
| 49 | 49 |
| 50 // Mocks an AsyncAPIInterface, using GMock. | 50 // Mocks an AsyncAPIInterface, using GMock. |
| 51 class AsyncAPIMock : public AsyncAPIInterface { | 51 class AsyncAPIMock : public AsyncAPIInterface { |
| 52 public: | 52 public: |
| 53 AsyncAPIMock() { | 53 AsyncAPIMock() { |
| 54 testing::DefaultValue<BufferSyncInterface::ParseError>::Set( | 54 testing::DefaultValue<BufferSyncInterface::ParseError>::Set( |
| 55 BufferSyncInterface::PARSE_NO_ERROR); | 55 BufferSyncInterface::kParseNoError); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Predicate that matches args passed to DoCommand, by looking at the values. | 58 // Predicate that matches args passed to DoCommand, by looking at the values. |
| 59 class IsArgs { | 59 class IsArgs { |
| 60 public: | 60 public: |
| 61 IsArgs(unsigned int arg_count, const void* args) | 61 IsArgs(unsigned int arg_count, const void* args) |
| 62 : arg_count_(arg_count), | 62 : arg_count_(arg_count), |
| 63 args_(static_cast<CommandBufferEntry*>(const_cast<void*>(args))) { } | 63 args_(static_cast<CommandBufferEntry*>(const_cast<void*>(args))) { |
| 64 } |
| 64 | 65 |
| 65 bool operator() (const void* _args) const { | 66 bool operator() (const void* _args) const { |
| 66 const CommandBufferEntry* args = | 67 const CommandBufferEntry* args = |
| 67 static_cast<const CommandBufferEntry*>(_args); | 68 static_cast<const CommandBufferEntry*>(_args) + 1; |
| 68 for (unsigned int i = 0; i < arg_count_; ++i) { | 69 for (unsigned int i = 0; i < arg_count_; ++i) { |
| 69 if (args[i].value_uint32 != args_[i].value_uint32) return false; | 70 if (args[i].value_uint32 != args_[i].value_uint32) return false; |
| 70 } | 71 } |
| 71 return true; | 72 return true; |
| 72 } | 73 } |
| 73 | 74 |
| 74 private: | 75 private: |
| 75 unsigned int arg_count_; | 76 unsigned int arg_count_; |
| 76 CommandBufferEntry *args_; | 77 CommandBufferEntry *args_; |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 MOCK_METHOD3(DoCommand, BufferSyncInterface::ParseError( | 80 MOCK_METHOD3(DoCommand, BufferSyncInterface::ParseError( |
| 80 unsigned int command, | 81 unsigned int command, |
| 81 unsigned int arg_count, | 82 unsigned int arg_count, |
| 82 const void* args)); | 83 const void* cmd_data)); |
| 83 | 84 |
| 84 // Sets the engine, to forward SET_TOKEN commands to it. | 85 // Sets the engine, to forward SetToken commands to it. |
| 85 void set_engine(CommandBufferEngine *engine) { engine_ = engine; } | 86 void set_engine(CommandBufferEngine *engine) { engine_ = engine; } |
| 86 | 87 |
| 87 // Forwards the SetToken commands to the engine. | 88 // Forwards the SetToken commands to the engine. |
| 88 void SetToken(unsigned int command, | 89 void SetToken(unsigned int command, |
| 89 unsigned int arg_count, | 90 unsigned int arg_count, |
| 90 const void* _args) { | 91 const void* _args) { |
| 91 DCHECK(engine_); | 92 DCHECK(engine_); |
| 92 DCHECK_EQ(1, command); | 93 DCHECK_EQ(1, command); |
| 93 DCHECK_EQ(1, arg_count); | 94 DCHECK_EQ(1, arg_count); |
| 94 const CommandBufferEntry* args = | 95 const CommandBufferEntry* args = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 private: | 145 private: |
| 145 bool would_have_blocked_; | 146 bool would_have_blocked_; |
| 146 unsigned int message_count_; | 147 unsigned int message_count_; |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 | 150 |
| 150 } // namespace command_buffer | 151 } // namespace command_buffer |
| 151 } // namespace o3d | 152 } // namespace o3d |
| 152 | 153 |
| 153 #endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_MOCKS_H_ | 154 #endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_MOCKS_H_ |
| OLD | NEW |