Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Chromium OS 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 | #include "update_engine/fake_shill_proxy.h" |
| 6 | |
| 7 | #include "update_engine/dbus_proxies.h" |
| 8 | |
| 9 | using org::chromium::flimflam::ManagerProxyMock; |
| 10 | using org::chromium::flimflam::ServiceProxyInterface; |
| 11 | |
| 12 | namespace chromeos_update_engine { |
| 13 | |
| 14 | FakeShillProxy::FakeShillProxy() |
| 15 | : manager_proxy_mock_(new ManagerProxyMock()) {} |
| 16 | |
| 17 | ManagerProxyMock* FakeShillProxy::GetManagerProxy() { |
| 18 | return manager_proxy_mock_.get(); |
| 19 | } |
| 20 | |
| 21 | std::unique_ptr<ServiceProxyInterface> FakeShillProxy::GetServiceForPath( |
| 22 | const std::string& path) { |
| 23 | auto it = service_proxy_mocks_.find(path); |
| 24 | CHECK(it != service_proxy_mocks_.end()) << "No ServiceProxyMock set for " |
| 25 | << path; |
| 26 | std::unique_ptr<ServiceProxyInterface> result = std::move(it->second); |
| 27 | service_proxy_mocks_.erase(it); |
| 28 | return result; |
| 29 | } |
| 30 | |
| 31 | void FakeShillProxy::SetServiceForPath( |
| 32 | const std::string& path, |
| 33 | std::unique_ptr<ServiceProxyInterface> service_proxy) { |
| 34 | service_proxy_mocks_[path] = std::move(service_proxy); |
| 35 | } |
| 36 | |
| 37 | } // namespace chromeos_update_engine |