blob: 0fb3472a430c1c9ae62e49c501120e82027c6f3f [file] [log] [blame]
Chris Masone3bd3c8c2011-06-13 08:20:26 -07001// Copyright (c) 2011 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
Chris Masone9d779932011-08-25 16:33:41 -070012#include <base/memory/scoped_ptr.h>
Chris Masone2ae797d2011-08-23 20:41:00 -070013#include <base/memory/scoped_temp_dir.h>
Chris Masone3bd3c8c2011-06-13 08:20:26 -070014#include <dbus-c++/dbus.h>
Chris Masone7156c922011-08-23 20:36:21 -070015#include <gmock/gmock.h>
Chris Masone2ae797d2011-08-23 20:41:00 -070016#include <gtest/gtest.h>
Chris Masone3bd3c8c2011-06-13 08:20:26 -070017
18#include "shill/dbus_adaptor.h"
19#include "shill/error.h"
20#include "shill/manager.h"
21#include "shill/mock_control.h"
Chris Masone7aa5f902011-07-11 11:13:35 -070022#include "shill/mock_glib.h"
Chris Masoneb925cc82011-06-22 15:39:57 -070023#include "shill/property_store.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070024#include "shill/shill_event.h"
25
26namespace shill {
27
Chris Masoneb925cc82011-06-22 15:39:57 -070028class PropertyStoreTest : public testing::TestWithParam< ::DBus::Variant > {
Chris Masone3bd3c8c2011-06-13 08:20:26 -070029 public:
Chris Masoneb925cc82011-06-22 15:39:57 -070030 // In real code, it's frowned upon to have non-POD static members, as there
31 // can be ordering issues if your constructors have side effects.
32 // These constructors don't, and declaring these as static lets me
33 // autogenerate a bunch of unit test code that I would otherwise need to
34 // copypasta. So I think it's safe and worth it.
35 static const ::DBus::Variant kBoolV;
36 static const ::DBus::Variant kByteV;
37 static const ::DBus::Variant kInt16V;
38 static const ::DBus::Variant kInt32V;
39 static const ::DBus::Variant kStringV;
40 static const ::DBus::Variant kStringmapV;
41 static const ::DBus::Variant kStringmapsV;
42 static const ::DBus::Variant kStringsV;
Chris Masone889666b2011-07-03 12:58:50 -070043 static const ::DBus::Variant kStrIntPairV;
Chris Masoneb925cc82011-06-22 15:39:57 -070044 static const ::DBus::Variant kUint16V;
45 static const ::DBus::Variant kUint32V;
Chris Masone3bd3c8c2011-06-13 08:20:26 -070046
Chris Masoneb925cc82011-06-22 15:39:57 -070047 PropertyStoreTest();
48 virtual ~PropertyStoreTest();
Chris Masone3bd3c8c2011-06-13 08:20:26 -070049
Chris Masone9d779932011-08-25 16:33:41 -070050 virtual void SetUp();
51
Chris Masone3bd3c8c2011-06-13 08:20:26 -070052 protected:
Chris Masone9d779932011-08-25 16:33:41 -070053 Manager *manager() { return &manager_; }
54
55 const std::string &run_path() const { return path_; }
56 const std::string &storage_path() const { return path_; }
57
58 const std::string &invalid_args() const { return invalid_args_; }
59 const std::string &invalid_prop() const { return invalid_prop_; }
60
61 // TODO(cmasone): make these private as per http://crosbug.com/19573
Chris Masone3bd3c8c2011-06-13 08:20:26 -070062 MockControl control_interface_;
63 EventDispatcher dispatcher_;
Chris Masone7aa5f902011-07-11 11:13:35 -070064 MockGLib glib_;
Chris Masone9d779932011-08-25 16:33:41 -070065
66 private:
67 const std::string invalid_args_;
68 const std::string invalid_prop_;
69 ScopedTempDir dir_;
70 const std::string path_;
71 Manager manager_;
72
Chris Masone3bd3c8c2011-06-13 08:20:26 -070073};
74
75} // namespace shill
76#endif // SHILL_PROPERTY_STORE_UNITTEST_H_