blob: 431715eaa9fc50a0bd81bcdcd162ddfc60e68d26 [file] [log] [blame]
Thieu Le3426c8f2012-01-11 17:35:11 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone6515aab2011-10-12 16:19:09 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "shill/service_under_test.h"
6
7#include <string>
8
9#include "shill/mock_adaptors.h"
Paul Stewartbb833562015-01-21 23:30:46 -080010#include "shill/property_accessor.h"
Chris Masone6515aab2011-10-12 16:19:09 -070011
12using std::string;
13
14namespace shill {
15
16// static
Paul Stewartbb833562015-01-21 23:30:46 -080017const char ServiceUnderTest::kKeyValueStoreProperty[] = "key_value_store";
Jason Glasgowacdc11f2012-03-30 14:12:22 -040018const char ServiceUnderTest::kRpcId[] = "/mock_device_rpc";
Paul Stewart99dc9f32013-06-27 07:39:25 -070019const char ServiceUnderTest::kStringsProperty[] = "strings";
Chris Masone6515aab2011-10-12 16:19:09 -070020const char ServiceUnderTest::kStorageId[] = "service";
21
22ServiceUnderTest::ServiceUnderTest(ControlInterface *control_interface,
23 EventDispatcher *dispatcher,
Thieu Le3426c8f2012-01-11 17:35:11 -080024 Metrics *metrics,
Chris Masone6515aab2011-10-12 16:19:09 -070025 Manager *manager)
Thieu Le3426c8f2012-01-11 17:35:11 -080026 : Service(control_interface, dispatcher, metrics, manager,
27 Technology::kUnknown) {
Paul Stewartbb833562015-01-21 23:30:46 -080028 mutable_store()->RegisterStrings(kStringsProperty, &strings_);
29 mutable_store()->RegisterDerivedKeyValueStore(
30 kKeyValueStoreProperty,
31 KeyValueStoreAccessor(
32 new CustomAccessor<ServiceUnderTest, KeyValueStore>(
33 this, &ServiceUnderTest::GetKeyValueStore,
34 &ServiceUnderTest::SetKeyValueStore)));
Chris Masone6515aab2011-10-12 16:19:09 -070035}
36
37ServiceUnderTest::~ServiceUnderTest() {}
38
Chris Masone6515aab2011-10-12 16:19:09 -070039string ServiceUnderTest::GetRpcIdentifier() const {
40 return ServiceMockAdaptor::kRpcId;
41}
42
Paul Stewart1cf7eb82013-12-03 19:34:36 -080043string ServiceUnderTest::GetDeviceRpcId(Error */*error*/) const {
44 return kRpcId;
45}
Chris Masone6515aab2011-10-12 16:19:09 -070046
47string ServiceUnderTest::GetStorageIdentifier() const { return kStorageId; }
48
Paul Stewartbb833562015-01-21 23:30:46 -080049bool ServiceUnderTest::SetKeyValueStore(
50 const KeyValueStore &value, Error *error) {
51 key_value_store_.Clear();
52 key_value_store_.CopyFrom(value);
53 return true;
54}
55
56KeyValueStore ServiceUnderTest::GetKeyValueStore(Error *error) {
57 return key_value_store_;
58}
59
Chris Masone6515aab2011-10-12 16:19:09 -070060} // namespace shill