blob: 44d755dfe5669f11e9010f1f2fdd35f603702ee2 [file] [log] [blame]
Chris Masone88cbd5f2011-07-03 14:30:04 -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#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
18using std::map;
19using std::string;
20using ::testing::_;
21
22namespace shill {
23
24class DefaultProfileTest : public PropertyStoreTest {
25 public:
Chris Masone7aa5f902011-07-11 11:13:35 -070026 DefaultProfileTest()
Chris Masone6791a432011-07-12 13:23:19 -070027 : profile_(new DefaultProfile(&control_interface_,
28 &glib_,
29 &manager_,
30 properties_)) {
Chris Masone7aa5f902011-07-11 11:13:35 -070031 }
Chris Masone88cbd5f2011-07-03 14:30:04 -070032
33 virtual ~DefaultProfileTest() {}
34
35 protected:
Chris Masone7aa5f902011-07-11 11:13:35 -070036 ProfileRefPtr profile_;
Darin Petkova4766822011-07-07 10:42:22 -070037 GLib glib_;
Chris Masone88cbd5f2011-07-03 14:30:04 -070038 Manager::Properties properties_;
39};
40
41TEST_F(DefaultProfileTest, GetProperties) {
42 Error error(Error::kInvalidProperty, "");
43 {
44 map<string, ::DBus::Variant> props;
45 ::DBus::Error dbus_error;
Chris Masone7aa5f902011-07-11 11:13:35 -070046 DBusAdaptor::GetProperties(profile_->store(), &props, &dbus_error);
Chris Masone88cbd5f2011-07-03 14:30:04 -070047 ASSERT_FALSE(props.find(flimflam::kOfflineModeProperty) == props.end());
48 EXPECT_FALSE(props[flimflam::kOfflineModeProperty].reader().get_bool());
49 }
50 properties_.offline_mode = true;
51 {
52 map<string, ::DBus::Variant> props;
53 ::DBus::Error dbus_error;
Chris Masone7aa5f902011-07-11 11:13:35 -070054 DBusAdaptor::GetProperties(profile_->store(), &props, &dbus_error);
Chris Masone88cbd5f2011-07-03 14:30:04 -070055 ASSERT_FALSE(props.find(flimflam::kOfflineModeProperty) == props.end());
56 EXPECT_TRUE(props[flimflam::kOfflineModeProperty].reader().get_bool());
57 }
58 {
59 Error error(Error::kInvalidProperty, "");
60 EXPECT_FALSE(
Chris Masone7aa5f902011-07-11 11:13:35 -070061 profile_->store()->SetBoolProperty(flimflam::kOfflineModeProperty,
62 true,
63 &error));
Chris Masone88cbd5f2011-07-03 14:30:04 -070064 }
65}
66
67} // namespace shill