blob: 84e032ff5dc72b5b1633d0abbe00b3654c063c49 [file] [log] [blame]
Thieu Le3426c8f2012-01-11 17:35:11 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone3bd3c8c2011-06-13 08:20:26 -07002// 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>
Eric Shienbrood3e20a232012-02-16 11:35:56 -050013#include <base/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"
Paul Stewart26b327e2011-10-19 11:38:09 -070020#include "shill/event_dispatcher.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070021#include "shill/manager.h"
22#include "shill/mock_control.h"
Chris Masone7aa5f902011-07-11 11:13:35 -070023#include "shill/mock_glib.h"
Thieu Le3426c8f2012-01-11 17:35:11 -080024#include "shill/mock_metrics.h"
Chris Masoneb925cc82011-06-22 15:39:57 -070025#include "shill/property_store.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070026
27namespace shill {
28
Chris Masoneb925cc82011-06-22 15:39:57 -070029class PropertyStoreTest : public testing::TestWithParam< ::DBus::Variant > {
Chris Masone3bd3c8c2011-06-13 08:20:26 -070030 public:
Chris Masoneb925cc82011-06-22 15:39:57 -070031 // 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
Gaurav Shah1b7a6162011-11-09 11:41:01 -080035 // copypaste. So I think it's safe and worth it.
Chris Masoneb925cc82011-06-22 15:39:57 -070036 static const ::DBus::Variant kBoolV;
37 static const ::DBus::Variant kByteV;
38 static const ::DBus::Variant kInt16V;
39 static const ::DBus::Variant kInt32V;
Darin Petkov63138a92012-02-06 14:09:15 +010040 static const ::DBus::Variant kKeyValueStoreV;
Chris Masoneb925cc82011-06-22 15:39:57 -070041 static const ::DBus::Variant kStringV;
42 static const ::DBus::Variant kStringmapV;
43 static const ::DBus::Variant kStringmapsV;
44 static const ::DBus::Variant kStringsV;
45 static const ::DBus::Variant kUint16V;
46 static const ::DBus::Variant kUint32V;
Chris Masone3bd3c8c2011-06-13 08:20:26 -070047
Chris Masoneb925cc82011-06-22 15:39:57 -070048 PropertyStoreTest();
49 virtual ~PropertyStoreTest();
Chris Masone3bd3c8c2011-06-13 08:20:26 -070050
Chris Masone9d779932011-08-25 16:33:41 -070051 virtual void SetUp();
52
Chris Masone3bd3c8c2011-06-13 08:20:26 -070053 protected:
Chris Masone9d779932011-08-25 16:33:41 -070054 Manager *manager() { return &manager_; }
Chris Masone2176a882011-09-14 22:29:15 -070055 MockControl *control_interface() { return &control_interface_; }
56 EventDispatcher *dispatcher() { return &dispatcher_; }
57 MockGLib *glib() { return &glib_; }
Thieu Le3426c8f2012-01-11 17:35:11 -080058 MockMetrics *metrics() { return &metrics_; }
Chris Masone9d779932011-08-25 16:33:41 -070059
60 const std::string &run_path() const { return path_; }
61 const std::string &storage_path() const { return path_; }
62
mukesh agrawalffa3d042011-10-06 15:26:10 -070063 const std::string &internal_error() const { return internal_error_; }
Chris Masone9d779932011-08-25 16:33:41 -070064 const std::string &invalid_args() const { return invalid_args_; }
65 const std::string &invalid_prop() const { return invalid_prop_; }
66
Chris Masone9d779932011-08-25 16:33:41 -070067 private:
mukesh agrawalffa3d042011-10-06 15:26:10 -070068 const std::string internal_error_;
Chris Masone9d779932011-08-25 16:33:41 -070069 const std::string invalid_args_;
70 const std::string invalid_prop_;
71 ScopedTempDir dir_;
72 const std::string path_;
Chris Masone2176a882011-09-14 22:29:15 -070073 MockControl control_interface_;
74 EventDispatcher dispatcher_;
Thieu Le3426c8f2012-01-11 17:35:11 -080075 MockMetrics metrics_;
Chris Masone2176a882011-09-14 22:29:15 -070076 MockGLib glib_;
Chris Masone9d779932011-08-25 16:33:41 -070077 Manager manager_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -070078};
79
80} // namespace shill
81#endif // SHILL_PROPERTY_STORE_UNITTEST_H_