1//
2// Copyright (C) 2012 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
17#include "shill/service_under_test.h"
18
19#include <string>
20
21#include "shill/mock_adaptors.h"
22#include "shill/property_accessor.h"
23
24using std::string;
25
26namespace shill {
27
28// static
29const char ServiceUnderTest::kKeyValueStoreProperty[] = "key_value_store";
30const char ServiceUnderTest::kRpcId[] = "/mock_device_rpc";
31const char ServiceUnderTest::kStringsProperty[] = "strings";
32const char ServiceUnderTest::kStorageId[] = "service";
33
34ServiceUnderTest::ServiceUnderTest(ControlInterface* control_interface,
35                                   EventDispatcher* dispatcher,
36                                   Metrics* metrics,
37                                   Manager* manager)
38    : Service(control_interface, dispatcher, metrics, manager,
39              Technology::kUnknown) {
40  mutable_store()->RegisterStrings(kStringsProperty, &strings_);
41  mutable_store()->RegisterDerivedKeyValueStore(
42      kKeyValueStoreProperty,
43      KeyValueStoreAccessor(
44          new CustomAccessor<ServiceUnderTest, KeyValueStore>(
45              this, &ServiceUnderTest::GetKeyValueStore,
46              &ServiceUnderTest::SetKeyValueStore)));
47}
48
49ServiceUnderTest::~ServiceUnderTest() {}
50
51string ServiceUnderTest::GetRpcIdentifier() const {
52  return ServiceMockAdaptor::kRpcId;
53}
54
55string ServiceUnderTest::GetDeviceRpcId(Error* /*error*/) const {
56  return kRpcId;
57}
58
59string ServiceUnderTest::GetStorageIdentifier() const { return kStorageId; }
60
61bool ServiceUnderTest::SetKeyValueStore(
62    const KeyValueStore& value, Error* error) {
63  key_value_store_.Clear();
64  key_value_store_.CopyFrom(value);
65  return true;
66}
67
68KeyValueStore ServiceUnderTest::GetKeyValueStore(Error* error) {
69  return key_value_store_;
70}
71
72}  // namespace shill
73