Alex Vakulenko | ba98115 | 2015-12-05 13:58:22 -0800 | [diff] [blame] | 1 | // Copyright 2015 The Weave Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef LIBWEAVE_SRC_MOCK_COMPONENT_MANAGER_H_ |
| 6 | #define LIBWEAVE_SRC_MOCK_COMPONENT_MANAGER_H_ |
| 7 | |
| 8 | #include "src/component_manager.h" |
| 9 | |
| 10 | #include <gmock/gmock.h> |
| 11 | |
| 12 | namespace weave { |
| 13 | |
| 14 | class MockComponentManager : public ComponentManager { |
| 15 | public: |
| 16 | ~MockComponentManager() override {} |
| 17 | MOCK_METHOD2(LoadTraits, bool(const base::DictionaryValue& dict, |
| 18 | ErrorPtr* error)); |
| 19 | MOCK_METHOD2(LoadTraits, bool(const std::string& json, ErrorPtr* error)); |
| 20 | MOCK_METHOD1(AddTraitDefChangedCallback, void(const base::Closure& callback)); |
| 21 | MOCK_METHOD4(AddComponent, bool(const std::string& path, |
| 22 | const std::string& name, |
| 23 | const std::vector<std::string>& traits, |
| 24 | ErrorPtr* error)); |
| 25 | MOCK_METHOD4(AddComponentArrayItem, |
| 26 | bool(const std::string& path, |
| 27 | const std::string& name, |
| 28 | const std::vector<std::string>& traits, |
| 29 | ErrorPtr* error)); |
| 30 | MOCK_METHOD1(AddComponentTreeChangedCallback, |
| 31 | void(const base::Closure& callback)); |
Alex Vakulenko | b736c98 | 2015-12-05 14:09:27 -0800 | [diff] [blame^] | 32 | MOCK_METHOD5(AddCommand, bool(const base::DictionaryValue& command, |
| 33 | Command::Origin command_origin, |
Alex Vakulenko | ba98115 | 2015-12-05 13:58:22 -0800 | [diff] [blame] | 34 | UserRole role, |
| 35 | std::string* id, |
| 36 | ErrorPtr* error)); |
| 37 | MOCK_METHOD1(FindCommand, CommandInstance*(const std::string& id)); |
| 38 | MOCK_METHOD1(AddCommandAddedCallback, |
| 39 | void(const CommandQueue::CommandCallback& callback)); |
| 40 | MOCK_METHOD1(AddCommandRemovedCallback, |
| 41 | void(const CommandQueue::CommandCallback& callback)); |
| 42 | MOCK_METHOD3(AddCommandHandler, |
| 43 | void(const std::string& component_path, |
| 44 | const std::string& command_name, |
| 45 | const Device::CommandHandlerCallback& callback)); |
| 46 | MOCK_CONST_METHOD2(FindComponent, |
| 47 | const base::DictionaryValue*(const std::string& path, |
| 48 | ErrorPtr* error)); |
| 49 | MOCK_CONST_METHOD1(FindTraitDefinition, |
| 50 | const base::DictionaryValue*(const std::string& name)); |
| 51 | MOCK_CONST_METHOD1( |
| 52 | FindCommandDefinition, |
| 53 | const base::DictionaryValue*(const std::string& command_name)); |
| 54 | MOCK_CONST_METHOD3(GetMinimalRole, bool(const std::string& command_name, |
| 55 | UserRole* minimal_role, |
| 56 | ErrorPtr* error)); |
| 57 | MOCK_CONST_METHOD0(GetTraits, const base::DictionaryValue&()); |
| 58 | MOCK_CONST_METHOD0(GetComponents, const base::DictionaryValue&()); |
| 59 | MOCK_METHOD3(SetStateProperties, bool(const std::string& component_path, |
| 60 | const base::DictionaryValue& dict, |
| 61 | ErrorPtr* error)); |
| 62 | MOCK_METHOD3(SetStatePropertiesFromJson, |
| 63 | bool(const std::string& component_path, |
| 64 | const std::string& json, |
| 65 | ErrorPtr* error)); |
| 66 | MOCK_CONST_METHOD3(GetStateProperty, |
| 67 | const base::Value*(const std::string& component_path, |
| 68 | const std::string& name, |
| 69 | ErrorPtr* error)); |
| 70 | MOCK_METHOD4(SetStateProperty, bool(const std::string& component_path, |
| 71 | const std::string& name, |
| 72 | const base::Value& value, |
| 73 | ErrorPtr* error)); |
| 74 | MOCK_METHOD1(AddStateChangedCallback, void(const base::Closure& callback)); |
| 75 | MOCK_METHOD0(MockGetAndClearRecordedStateChanges, StateSnapshot&()); |
| 76 | MOCK_METHOD1(NotifyStateUpdatedOnServer, void(UpdateID id)); |
| 77 | MOCK_CONST_METHOD0(GetLastStateChangeId, UpdateID()); |
| 78 | MOCK_METHOD1(MockAddServerStateUpdatedCallback, |
| 79 | base::CallbackList<void(UpdateID)>::Subscription*( |
| 80 | const base::Callback<void(UpdateID)>& callback)); |
| 81 | MOCK_CONST_METHOD1(FindComponentWithTrait, |
| 82 | std::string(const std::string& trait)); |
| 83 | |
| 84 | private: |
Alex Vakulenko | ba98115 | 2015-12-05 13:58:22 -0800 | [diff] [blame] | 85 | StateSnapshot GetAndClearRecordedStateChanges() override { |
| 86 | return std::move(MockGetAndClearRecordedStateChanges()); |
| 87 | } |
| 88 | Token AddServerStateUpdatedCallback( |
| 89 | const base::Callback<void(UpdateID)>& callback) override { |
| 90 | return Token{MockAddServerStateUpdatedCallback(callback)}; |
| 91 | } |
| 92 | }; |
| 93 | |
| 94 | } // namespace weave |
| 95 | |
| 96 | #endif // LIBWEAVE_SRC_COMPONENT_MANAGER_H_ |