fake_shill_proxy.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright (C) 2015 The Android Open Source Project
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #ifndef UPDATE_ENGINE_FAKE_SHILL_PROXY_H_
  17. #define UPDATE_ENGINE_FAKE_SHILL_PROXY_H_
  18. #include <map>
  19. #include <memory>
  20. #include <string>
  21. #include <base/macros.h>
  22. #include <shill/dbus-proxies.h>
  23. #include <shill/dbus-proxy-mocks.h>
  24. #include "update_engine/shill_proxy_interface.h"
  25. namespace chromeos_update_engine {
  26. // This class implements the connection to shill using real DBus calls.
  27. class FakeShillProxy : public ShillProxyInterface {
  28. public:
  29. FakeShillProxy();
  30. ~FakeShillProxy() override = default;
  31. // ShillProxyInterface overrides.
  32. // GetManagerProxy returns the subclass ManagerProxyMock so tests can easily
  33. // use it. Mocks for the return value of GetServiceForPath() can be provided
  34. // with SetServiceForPath().
  35. org::chromium::flimflam::ManagerProxyMock* GetManagerProxy() override;
  36. std::unique_ptr<org::chromium::flimflam::ServiceProxyInterface>
  37. GetServiceForPath(const dbus::ObjectPath& path) override;
  38. // Sets the service_proxy that will be returned by GetServiceForPath().
  39. void SetServiceForPath(
  40. const dbus::ObjectPath& path,
  41. std::unique_ptr<org::chromium::flimflam::ServiceProxyInterface>
  42. service_proxy);
  43. private:
  44. std::unique_ptr<org::chromium::flimflam::ManagerProxyMock>
  45. manager_proxy_mock_;
  46. std::map<std::string,
  47. std::unique_ptr<org::chromium::flimflam::ServiceProxyInterface>>
  48. service_proxy_mocks_;
  49. DISALLOW_COPY_AND_ASSIGN(FakeShillProxy);
  50. };
  51. } // namespace chromeos_update_engine
  52. #endif // UPDATE_ENGINE_FAKE_SHILL_PROXY_H_