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 | |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 5 | #ifndef SHILL_SERVICE_UNDER_TEST_H_ |
| 6 | #define SHILL_SERVICE_UNDER_TEST_H_ |
| 7 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 8 | #include <string> |
Paul Stewart | 99dc9f3 | 2013-06-27 07:39:25 -0700 | [diff] [blame] | 9 | #include <vector> |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 10 | |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame] | 11 | #include "shill/key_value_store.h" |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 12 | #include "shill/service.h" |
| 13 | |
| 14 | namespace shill { |
| 15 | |
| 16 | class ControlInterface; |
| 17 | class Error; |
| 18 | class EventDispatcher; |
| 19 | class Manager; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 20 | class Metrics; |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 21 | |
Paul Stewart | 99dc9f3 | 2013-06-27 07:39:25 -0700 | [diff] [blame] | 22 | // This is a simple Service subclass with all the pure-virtual methods stubbed. |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 23 | class ServiceUnderTest : public Service { |
| 24 | public: |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame] | 25 | static const char kKeyValueStoreProperty[]; |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 26 | static const char kRpcId[]; |
Paul Stewart | 99dc9f3 | 2013-06-27 07:39:25 -0700 | [diff] [blame] | 27 | static const char kStringsProperty[]; |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 28 | static const char kStorageId[]; |
| 29 | |
| 30 | ServiceUnderTest(ControlInterface *control_interface, |
| 31 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 32 | Metrics *metrics, |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 33 | Manager *manager); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 34 | ~ServiceUnderTest() override; |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 35 | |
Alex Vakulenko | 016fa0e | 2014-08-11 15:59:58 -0700 | [diff] [blame] | 36 | std::string GetRpcIdentifier() const override; |
| 37 | std::string GetDeviceRpcId(Error *error) const override; |
| 38 | std::string GetStorageIdentifier() const override; |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 39 | |
Paul Stewart | 99dc9f3 | 2013-06-27 07:39:25 -0700 | [diff] [blame] | 40 | // Getter and setter for a string array property for use in testing. |
| 41 | void set_strings(const std::vector<std::string> &strings) { |
| 42 | strings_ = strings; |
| 43 | } |
| 44 | const std::vector<std::string> &strings() const { return strings_; } |
| 45 | |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame] | 46 | // Getter and setter for a KeyValueStore property for use in testing. |
| 47 | bool SetKeyValueStore(const KeyValueStore &value, Error *error); |
| 48 | KeyValueStore GetKeyValueStore(Error *error); |
| 49 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 50 | private: |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame] | 51 | // The Service superclass has no string array or KeyValueStore properties |
| 52 | // but we need them in order to test Service::Configure. |
Paul Stewart | 99dc9f3 | 2013-06-27 07:39:25 -0700 | [diff] [blame] | 53 | std::vector<std::string> strings_; |
Paul Stewart | bb83356 | 2015-01-21 23:30:46 -0800 | [diff] [blame] | 54 | KeyValueStore key_value_store_; |
Paul Stewart | 99dc9f3 | 2013-06-27 07:39:25 -0700 | [diff] [blame] | 55 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 56 | DISALLOW_COPY_AND_ASSIGN(ServiceUnderTest); |
| 57 | }; |
| 58 | |
| 59 | } // namespace shill |
Ben Chan | c45688b | 2014-07-02 23:50:45 -0700 | [diff] [blame] | 60 | |
| 61 | #endif // SHILL_SERVICE_UNDER_TEST_H_ |