blob: 0b66cbc39ea22bcd358427e3d119934b9fff39bb [file] [log] [blame]
Peter Qiuc0beca52015-09-03 11:25:46 -07001//
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//
Chris Masone6515aab2011-10-12 16:19:09 -070016
17#include "shill/service_under_test.h"
18
19#include <string>
20
21#include "shill/mock_adaptors.h"
Paul Stewartbb833562015-01-21 23:30:46 -080022#include "shill/property_accessor.h"
Chris Masone6515aab2011-10-12 16:19:09 -070023
24using std::string;
25
26namespace shill {
27
28// static
Paul Stewartbb833562015-01-21 23:30:46 -080029const char ServiceUnderTest::kKeyValueStoreProperty[] = "key_value_store";
Jason Glasgowacdc11f2012-03-30 14:12:22 -040030const char ServiceUnderTest::kRpcId[] = "/mock_device_rpc";
Paul Stewart99dc9f32013-06-27 07:39:25 -070031const char ServiceUnderTest::kStringsProperty[] = "strings";
Chris Masone6515aab2011-10-12 16:19:09 -070032const char ServiceUnderTest::kStorageId[] = "service";
33
Paul Stewart1a212a62015-06-16 13:13:10 -070034ServiceUnderTest::ServiceUnderTest(ControlInterface* control_interface,
35 EventDispatcher* dispatcher,
36 Metrics* metrics,
37 Manager* manager)
Thieu Le3426c8f2012-01-11 17:35:11 -080038 : Service(control_interface, dispatcher, metrics, manager,
39 Technology::kUnknown) {
Paul Stewartbb833562015-01-21 23:30:46 -080040 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)));
Chris Masone6515aab2011-10-12 16:19:09 -070047}
48
49ServiceUnderTest::~ServiceUnderTest() {}
50
Chris Masone6515aab2011-10-12 16:19:09 -070051string ServiceUnderTest::GetRpcIdentifier() const {
52 return ServiceMockAdaptor::kRpcId;
53}
54
Paul Stewart1a212a62015-06-16 13:13:10 -070055string ServiceUnderTest::GetDeviceRpcId(Error* /*error*/) const {
Paul Stewart1cf7eb82013-12-03 19:34:36 -080056 return kRpcId;
57}
Chris Masone6515aab2011-10-12 16:19:09 -070058
59string ServiceUnderTest::GetStorageIdentifier() const { return kStorageId; }
60
Paul Stewartbb833562015-01-21 23:30:46 -080061bool ServiceUnderTest::SetKeyValueStore(
Paul Stewart1a212a62015-06-16 13:13:10 -070062 const KeyValueStore& value, Error* error) {
Paul Stewartbb833562015-01-21 23:30:46 -080063 key_value_store_.Clear();
64 key_value_store_.CopyFrom(value);
65 return true;
66}
67
Paul Stewart1a212a62015-06-16 13:13:10 -070068KeyValueStore ServiceUnderTest::GetKeyValueStore(Error* error) {
Paul Stewartbb833562015-01-21 23:30:46 -080069 return key_value_store_;
70}
71
Chris Masone6515aab2011-10-12 16:19:09 -070072} // namespace shill