Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 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 Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 12 | #include <base/memory/scoped_ptr.h> |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 13 | #include <base/scoped_temp_dir.h> |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 14 | #include <dbus-c++/dbus.h> |
Chris Masone | 7156c92 | 2011-08-23 20:36:21 -0700 | [diff] [blame] | 15 | #include <gmock/gmock.h> |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 16 | #include <gtest/gtest.h> |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 17 | |
| 18 | #include "shill/dbus_adaptor.h" |
| 19 | #include "shill/error.h" |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 20 | #include "shill/event_dispatcher.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 21 | #include "shill/manager.h" |
| 22 | #include "shill/mock_control.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 23 | #include "shill/mock_glib.h" |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 24 | #include "shill/mock_metrics.h" |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 25 | #include "shill/property_store.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 26 | |
| 27 | namespace shill { |
| 28 | |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 29 | class PropertyStoreTest : public testing::TestWithParam< ::DBus::Variant > { |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 30 | public: |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 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 |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 35 | // copypaste. So I think it's safe and worth it. |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 36 | static const ::DBus::Variant kBoolV; |
| 37 | static const ::DBus::Variant kByteV; |
| 38 | static const ::DBus::Variant kInt16V; |
| 39 | static const ::DBus::Variant kInt32V; |
Darin Petkov | 63138a9 | 2012-02-06 14:09:15 +0100 | [diff] [blame] | 40 | static const ::DBus::Variant kKeyValueStoreV; |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 41 | 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; |
Paul Stewart | e18c33b | 2012-07-10 20:48:44 -0700 | [diff] [blame] | 47 | static const ::DBus::Variant kUint64V; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 48 | |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 49 | PropertyStoreTest(); |
| 50 | virtual ~PropertyStoreTest(); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 51 | |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 52 | virtual void SetUp(); |
| 53 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 54 | protected: |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 55 | Manager *manager() { return &manager_; } |
Chris Masone | 2176a88 | 2011-09-14 22:29:15 -0700 | [diff] [blame] | 56 | MockControl *control_interface() { return &control_interface_; } |
| 57 | EventDispatcher *dispatcher() { return &dispatcher_; } |
| 58 | MockGLib *glib() { return &glib_; } |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 59 | MockMetrics *metrics() { return &metrics_; } |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 60 | |
| 61 | const std::string &run_path() const { return path_; } |
| 62 | const std::string &storage_path() const { return path_; } |
| 63 | |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 64 | const std::string &internal_error() const { return internal_error_; } |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 65 | const std::string &invalid_args() const { return invalid_args_; } |
| 66 | const std::string &invalid_prop() const { return invalid_prop_; } |
| 67 | |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 68 | private: |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 69 | const std::string internal_error_; |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 70 | const std::string invalid_args_; |
| 71 | const std::string invalid_prop_; |
| 72 | ScopedTempDir dir_; |
| 73 | const std::string path_; |
Chris Masone | 2176a88 | 2011-09-14 22:29:15 -0700 | [diff] [blame] | 74 | MockControl control_interface_; |
| 75 | EventDispatcher dispatcher_; |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 76 | testing::NiceMock<MockMetrics> metrics_; |
Chris Masone | 2176a88 | 2011-09-14 22:29:15 -0700 | [diff] [blame] | 77 | MockGLib glib_; |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 78 | Manager manager_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | } // namespace shill |
| 82 | #endif // SHILL_PROPERTY_STORE_UNITTEST_H_ |