blob: 7e356453de9fe1fa8c8b55daa9d03b25052aba21 [file] [log] [blame]
Darin Petkove0a312e2011-07-20 13:45:28 -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 <gtest/gtest.h>
6
7#include "shill/dbus_properties.h"
8
9using std::string;
10using testing::Test;
11
12namespace shill {
13
14class DBusPropertiesTest : public Test {
15};
16
17TEST_F(DBusPropertiesTest, GetString) {
18 static const char kTestProperty[] = "RandomKey";
19 static const char kTestValue[] = "random-value";
20 static const char kOldValue[] = "old-value";
21 string value = kOldValue;
22 DBusPropertiesMap props;
23 EXPECT_FALSE(DBusProperties::GetString(props, kTestProperty, &value));
24 EXPECT_EQ(kOldValue, value);
25 props[kTestProperty].writer().append_string(kTestValue);
26 EXPECT_TRUE(DBusProperties::GetString(props, kTestProperty, &value));
27 EXPECT_EQ(kTestValue, value);
28}
29
30TEST_F(DBusPropertiesTest, GetUint32) {
31 static const char kTestProperty[] = "AKey";
32 const uint32 kTestValue = 35;
33 const uint32 kOldValue = 74;
34 uint32 value = kOldValue;
35 DBusPropertiesMap props;
36 EXPECT_FALSE(DBusProperties::GetUint32(props, kTestProperty, &value));
37 EXPECT_EQ(kOldValue, value);
38 props[kTestProperty].writer().append_uint32(kTestValue);
39 EXPECT_TRUE(DBusProperties::GetUint32(props, kTestProperty, &value));
40 EXPECT_EQ(kTestValue, value);
41}
42
Darin Petkovceb68172011-07-29 14:47:48 -070043TEST_F(DBusPropertiesTest, GetUint16) {
44 static const char kTestProperty[] = "version";
45 const uint16 kTestValue = 77;
46 const uint16 kOldValue = 88;
47 uint16 value = kOldValue;
48 DBusPropertiesMap props;
49 EXPECT_FALSE(DBusProperties::GetUint16(props, kTestProperty, &value));
50 EXPECT_EQ(kOldValue, value);
51 props[kTestProperty].writer().append_uint16(kTestValue);
52 EXPECT_TRUE(DBusProperties::GetUint16(props, kTestProperty, &value));
53 EXPECT_EQ(kTestValue, value);
54}
55
Darin Petkove0a312e2011-07-20 13:45:28 -070056} // namespace shill