[shill] Add properties to Profiles.
There are several properties of the Manager that are reflected only in
the default Profile. We create a subclass for this special type of
profile and hand it a const ref to the properties of the Manager class
so it can provide read-only access to these values via RPC.
BUG=chromium-os:17261
TEST=unit tests
STATUS=Verified
Change-Id: I6fa9f2549a0e1af1b9523206bad8ee17e133f399
Reviewed-on: http://gerrit.chromium.org/gerrit/3620
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/default_profile_unittest.cc b/default_profile_unittest.cc
new file mode 100644
index 0000000..6e3e712
--- /dev/null
+++ b/default_profile_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shill/default_profile.h"
+
+#include <map>
+#include <string>
+
+#include <chromeos/dbus/service_constants.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "shill/manager.h"
+#include "shill/mock_control.h"
+#include "shill/property_store_unittest.h"
+
+using std::map;
+using std::string;
+using ::testing::_;
+
+namespace shill {
+
+class DefaultProfileTest : public PropertyStoreTest {
+ public:
+ DefaultProfileTest() : profile_(&control_interface_, properties_) {}
+
+ virtual ~DefaultProfileTest() {}
+
+ protected:
+ DefaultProfile profile_;
+ Manager::Properties properties_;
+};
+
+TEST_F(DefaultProfileTest, GetProperties) {
+ Error error(Error::kInvalidProperty, "");
+ {
+ map<string, ::DBus::Variant> props;
+ ::DBus::Error dbus_error;
+ DBusAdaptor::GetProperties(profile_.store(), &props, &dbus_error);
+ ASSERT_FALSE(props.find(flimflam::kOfflineModeProperty) == props.end());
+ EXPECT_FALSE(props[flimflam::kOfflineModeProperty].reader().get_bool());
+ }
+ properties_.offline_mode = true;
+ {
+ map<string, ::DBus::Variant> props;
+ ::DBus::Error dbus_error;
+ DBusAdaptor::GetProperties(profile_.store(), &props, &dbus_error);
+ ASSERT_FALSE(props.find(flimflam::kOfflineModeProperty) == props.end());
+ EXPECT_TRUE(props[flimflam::kOfflineModeProperty].reader().get_bool());
+ }
+ {
+ Error error(Error::kInvalidProperty, "");
+ EXPECT_FALSE(
+ profile_.store()->SetBoolProperty(flimflam::kOfflineModeProperty,
+ true,
+ &error));
+ }
+}
+
+} // namespace shill