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 #ifndef SHILL_SERVICE_UNDER_TEST_H_
18 #define SHILL_SERVICE_UNDER_TEST_H_
19 
20 #include <string>
21 #include <vector>
22 
23 #include "shill/key_value_store.h"
24 #include "shill/service.h"
25 
26 namespace shill {
27 
28 class ControlInterface;
29 class Error;
30 class EventDispatcher;
31 class Manager;
32 class Metrics;
33 
34 // This is a simple Service subclass with all the pure-virtual methods stubbed.
35 class ServiceUnderTest : public Service {
36  public:
37   static const char kKeyValueStoreProperty[];
38   static const char kRpcId[];
39   static const char kStringsProperty[];
40   static const char kStorageId[];
41 
42   ServiceUnderTest(ControlInterface* control_interface,
43                    EventDispatcher* dispatcher,
44                    Metrics* metrics,
45                    Manager* manager);
46   ~ServiceUnderTest() override;
47 
48   std::string GetRpcIdentifier() const override;
49   std::string GetDeviceRpcId(Error* error) const override;
50   std::string GetStorageIdentifier() const override;
51 
52   // Getter and setter for a string array property for use in testing.
set_strings(const std::vector<std::string> & strings)53   void set_strings(const std::vector<std::string>& strings) {
54     strings_ = strings;
55   }
strings()56   const std::vector<std::string>& strings() const { return strings_; }
57 
58   // Getter and setter for a KeyValueStore property for use in testing.
59   bool SetKeyValueStore(const KeyValueStore& value, Error* error);
60   KeyValueStore GetKeyValueStore(Error* error);
61 
62  private:
63   // The Service superclass has no string array or KeyValueStore properties
64   // but we need them in order to test Service::Configure.
65   std::vector<std::string> strings_;
66   KeyValueStore key_value_store_;
67 
68   DISALLOW_COPY_AND_ASSIGN(ServiceUnderTest);
69 };
70 
71 }  // namespace shill
72 
73 #endif  // SHILL_SERVICE_UNDER_TEST_H_
74