Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -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/device_dbus_adaptor.h" |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include <dbus-c++/dbus.h> |
| 10 | #include <gtest/gtest.h> |
| 11 | #include <gmock/gmock.h> |
| 12 | |
| 13 | namespace shill { |
| 14 | using ::testing::Test; |
| 15 | using ::testing::_; |
| 16 | using ::testing::NiceMock; |
| 17 | using ::testing::Return; |
| 18 | |
| 19 | class DBusAdaptorTest : public Test { |
| 20 | public: |
| 21 | DBusAdaptorTest() {} |
| 22 | virtual ~DBusAdaptorTest() {} |
| 23 | }; |
| 24 | |
| 25 | TEST_F(DBusAdaptorTest, Conversions) { |
| 26 | bool expected = false; |
| 27 | EXPECT_EQ(expected, DBusAdaptor::BoolToVariant(expected).reader().get_bool()); |
| 28 | expected = true; |
| 29 | EXPECT_EQ(expected, DBusAdaptor::BoolToVariant(expected).reader().get_bool()); |
| 30 | |
| 31 | uint32 ex_uint = 0; |
| 32 | EXPECT_EQ(ex_uint, |
| 33 | DBusAdaptor::UInt32ToVariant(ex_uint).reader().get_uint32()); |
| 34 | ex_uint = 128; |
| 35 | EXPECT_EQ(ex_uint, |
| 36 | DBusAdaptor::UInt32ToVariant(ex_uint).reader().get_uint32()); |
| 37 | |
| 38 | int32 ex_int = 0; |
| 39 | EXPECT_EQ(ex_int, |
| 40 | DBusAdaptor::IntToVariant(ex_int).reader().get_int32()); |
| 41 | ex_int = 128; |
| 42 | EXPECT_EQ(ex_int, |
| 43 | DBusAdaptor::IntToVariant(ex_int).reader().get_int32()); |
| 44 | |
| 45 | std::string ex_string = ""; |
| 46 | EXPECT_EQ(ex_string, |
| 47 | DBusAdaptor::StringToVariant(ex_string).reader().get_string()); |
| 48 | ex_string = "hello"; |
| 49 | EXPECT_EQ(ex_string, |
| 50 | DBusAdaptor::StringToVariant(ex_string).reader().get_string()); |
| 51 | } |
| 52 | |
| 53 | } // namespace shill |