Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 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 "shill/service_under_test.h" |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include "shill/mock_adaptors.h" |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame^] | 10 | #include "shill/property_accessor.h" |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 11 | |
| 12 | using std::string; |
| 13 | |
| 14 | namespace shill { |
| 15 | |
| 16 | // static |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame^] | 17 | const char ServiceUnderTest::kKeyValueStoreProperty[] = "key_value_store"; |
Jason Glasgow | acdc11f | 2012-03-30 14:12:22 -0400 | [diff] [blame] | 18 | const char ServiceUnderTest::kRpcId[] = "/mock_device_rpc"; |
Paul Stewart | 99dc9f3 | 2013-06-27 07:39:25 -0700 | [diff] [blame] | 19 | const char ServiceUnderTest::kStringsProperty[] = "strings"; |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 20 | const char ServiceUnderTest::kStorageId[] = "service"; |
| 21 | |
| 22 | ServiceUnderTest::ServiceUnderTest(ControlInterface *control_interface, |
| 23 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 24 | Metrics *metrics, |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 25 | Manager *manager) |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 26 | : Service(control_interface, dispatcher, metrics, manager, |
| 27 | Technology::kUnknown) { |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame^] | 28 | 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 Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | ServiceUnderTest::~ServiceUnderTest() {} |
| 38 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 39 | string ServiceUnderTest::GetRpcIdentifier() const { |
| 40 | return ServiceMockAdaptor::kRpcId; |
| 41 | } |
| 42 | |
Paul Stewart | 1cf7eb8 | 2013-12-03 19:34:36 -0800 | [diff] [blame] | 43 | string ServiceUnderTest::GetDeviceRpcId(Error */*error*/) const { |
| 44 | return kRpcId; |
| 45 | } |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 46 | |
| 47 | string ServiceUnderTest::GetStorageIdentifier() const { return kStorageId; } |
| 48 | |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame^] | 49 | bool ServiceUnderTest::SetKeyValueStore( |
| 50 | const KeyValueStore &value, Error *error) { |
| 51 | key_value_store_.Clear(); |
| 52 | key_value_store_.CopyFrom(value); |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | KeyValueStore ServiceUnderTest::GetKeyValueStore(Error *error) { |
| 57 | return key_value_store_; |
| 58 | } |
| 59 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 60 | } // namespace shill |