blob: dfa8b8cbe29abbb15eee74e7617d5c98be561521 [file] [log] [blame]
Thieu Le3426c8f2012-01-11 17:35:11 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone6515aab2011-10-12 16:19:09 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ben Chanc45688b2014-07-02 23:50:45 -07005#ifndef SHILL_SERVICE_UNDER_TEST_H_
6#define SHILL_SERVICE_UNDER_TEST_H_
7
Chris Masone6515aab2011-10-12 16:19:09 -07008#include <string>
Paul Stewart99dc9f32013-06-27 07:39:25 -07009#include <vector>
Chris Masone6515aab2011-10-12 16:19:09 -070010
Paul Stewartbb833562015-01-21 23:30:46 -080011#include "shill/key_value_store.h"
Chris Masone6515aab2011-10-12 16:19:09 -070012#include "shill/service.h"
13
14namespace shill {
15
16class ControlInterface;
17class Error;
18class EventDispatcher;
19class Manager;
Thieu Le3426c8f2012-01-11 17:35:11 -080020class Metrics;
Chris Masone6515aab2011-10-12 16:19:09 -070021
Paul Stewart99dc9f32013-06-27 07:39:25 -070022// This is a simple Service subclass with all the pure-virtual methods stubbed.
Chris Masone6515aab2011-10-12 16:19:09 -070023class ServiceUnderTest : public Service {
24 public:
Paul Stewartbb833562015-01-21 23:30:46 -080025 static const char kKeyValueStoreProperty[];
Chris Masone6515aab2011-10-12 16:19:09 -070026 static const char kRpcId[];
Paul Stewart99dc9f32013-06-27 07:39:25 -070027 static const char kStringsProperty[];
Chris Masone6515aab2011-10-12 16:19:09 -070028 static const char kStorageId[];
29
30 ServiceUnderTest(ControlInterface *control_interface,
31 EventDispatcher *dispatcher,
Thieu Le3426c8f2012-01-11 17:35:11 -080032 Metrics *metrics,
Chris Masone6515aab2011-10-12 16:19:09 -070033 Manager *manager);
Ben Chan5ea763b2014-08-13 11:07:54 -070034 ~ServiceUnderTest() override;
Chris Masone6515aab2011-10-12 16:19:09 -070035
Alex Vakulenko016fa0e2014-08-11 15:59:58 -070036 std::string GetRpcIdentifier() const override;
37 std::string GetDeviceRpcId(Error *error) const override;
38 std::string GetStorageIdentifier() const override;
Chris Masone6515aab2011-10-12 16:19:09 -070039
Paul Stewart99dc9f32013-06-27 07:39:25 -070040 // 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 Stewartbb833562015-01-21 23:30:46 -080046 // 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 Masone6515aab2011-10-12 16:19:09 -070050 private:
Paul Stewartbb833562015-01-21 23:30:46 -080051 // The Service superclass has no string array or KeyValueStore properties
52 // but we need them in order to test Service::Configure.
Paul Stewart99dc9f32013-06-27 07:39:25 -070053 std::vector<std::string> strings_;
Paul Stewartbb833562015-01-21 23:30:46 -080054 KeyValueStore key_value_store_;
Paul Stewart99dc9f32013-06-27 07:39:25 -070055
Chris Masone6515aab2011-10-12 16:19:09 -070056 DISALLOW_COPY_AND_ASSIGN(ServiceUnderTest);
57};
58
59} // namespace shill
Ben Chanc45688b2014-07-02 23:50:45 -070060
61#endif // SHILL_SERVICE_UNDER_TEST_H_