Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame^] | 1 | // 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 | #include "shill/default_profile.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
| 10 | #include <chromeos/dbus/service_constants.h> |
| 11 | #include <gtest/gtest.h> |
| 12 | #include <gmock/gmock.h> |
| 13 | |
| 14 | #include "shill/manager.h" |
| 15 | #include "shill/mock_control.h" |
| 16 | #include "shill/property_store_unittest.h" |
| 17 | |
| 18 | using std::map; |
| 19 | using std::string; |
| 20 | using ::testing::_; |
| 21 | |
| 22 | namespace shill { |
| 23 | |
| 24 | class DefaultProfileTest : public PropertyStoreTest { |
| 25 | public: |
| 26 | DefaultProfileTest() : profile_(&control_interface_, properties_) {} |
| 27 | |
| 28 | virtual ~DefaultProfileTest() {} |
| 29 | |
| 30 | protected: |
| 31 | DefaultProfile profile_; |
| 32 | Manager::Properties properties_; |
| 33 | }; |
| 34 | |
| 35 | TEST_F(DefaultProfileTest, GetProperties) { |
| 36 | Error error(Error::kInvalidProperty, ""); |
| 37 | { |
| 38 | map<string, ::DBus::Variant> props; |
| 39 | ::DBus::Error dbus_error; |
| 40 | DBusAdaptor::GetProperties(profile_.store(), &props, &dbus_error); |
| 41 | ASSERT_FALSE(props.find(flimflam::kOfflineModeProperty) == props.end()); |
| 42 | EXPECT_FALSE(props[flimflam::kOfflineModeProperty].reader().get_bool()); |
| 43 | } |
| 44 | properties_.offline_mode = true; |
| 45 | { |
| 46 | map<string, ::DBus::Variant> props; |
| 47 | ::DBus::Error dbus_error; |
| 48 | DBusAdaptor::GetProperties(profile_.store(), &props, &dbus_error); |
| 49 | ASSERT_FALSE(props.find(flimflam::kOfflineModeProperty) == props.end()); |
| 50 | EXPECT_TRUE(props[flimflam::kOfflineModeProperty].reader().get_bool()); |
| 51 | } |
| 52 | { |
| 53 | Error error(Error::kInvalidProperty, ""); |
| 54 | EXPECT_FALSE( |
| 55 | profile_.store()->SetBoolProperty(flimflam::kOfflineModeProperty, |
| 56 | true, |
| 57 | &error)); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | } // namespace shill |