property_store_unittest.h revision 3426c8fc7a3943f2d8fcb2ec78f0593088b42bed
1// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_PROPERTY_STORE_UNITTEST_H_
6#define SHILL_PROPERTY_STORE_UNITTEST_H_
7
8#include <map>
9#include <string>
10#include <vector>
11
12#include <base/memory/scoped_ptr.h>
13#include <base/memory/scoped_temp_dir.h>
14#include <dbus-c++/dbus.h>
15#include <gmock/gmock.h>
16#include <gtest/gtest.h>
17
18#include "shill/dbus_adaptor.h"
19#include "shill/error.h"
20#include "shill/event_dispatcher.h"
21#include "shill/manager.h"
22#include "shill/mock_control.h"
23#include "shill/mock_glib.h"
24#include "shill/mock_metrics.h"
25#include "shill/property_store.h"
26
27namespace shill {
28
29class PropertyStoreTest : public testing::TestWithParam< ::DBus::Variant > {
30 public:
31  // In real code, it's frowned upon to have non-POD static members, as there
32  // can be ordering issues if your constructors have side effects.
33  // These constructors don't, and declaring these as static lets me
34  // autogenerate a bunch of unit test code that I would otherwise need to
35  // copypaste.  So I think it's safe and worth it.
36  static const ::DBus::Variant kBoolV;
37  static const ::DBus::Variant kByteV;
38  static const ::DBus::Variant kInt16V;
39  static const ::DBus::Variant kInt32V;
40  static const ::DBus::Variant kStringV;
41  static const ::DBus::Variant kStringmapV;
42  static const ::DBus::Variant kStringmapsV;
43  static const ::DBus::Variant kStringsV;
44  static const ::DBus::Variant kStrIntPairV;
45  static const ::DBus::Variant kUint16V;
46  static const ::DBus::Variant kUint32V;
47
48  PropertyStoreTest();
49  virtual ~PropertyStoreTest();
50
51  virtual void SetUp();
52
53 protected:
54  Manager *manager() { return &manager_; }
55  MockControl *control_interface() { return &control_interface_; }
56  EventDispatcher *dispatcher() { return &dispatcher_; }
57  MockGLib *glib() { return &glib_; }
58  MockMetrics *metrics() { return &metrics_; }
59
60  const std::string &run_path() const { return path_; }
61  const std::string &storage_path() const { return path_; }
62
63  const std::string &internal_error() const { return internal_error_; }
64  const std::string &invalid_args() const { return invalid_args_; }
65  const std::string &invalid_prop() const { return invalid_prop_; }
66
67 private:
68  const std::string internal_error_;
69  const std::string invalid_args_;
70  const std::string invalid_prop_;
71  ScopedTempDir dir_;
72  const std::string path_;
73  MockControl control_interface_;
74  EventDispatcher dispatcher_;
75  MockMetrics metrics_;
76  MockGLib glib_;
77  Manager manager_;
78};
79
80}  // namespace shill
81#endif  // SHILL_PROPERTY_STORE_UNITTEST_H_
82