blob: a3be06fe7da46b24c4650aa6a7c0cb91f2f27345 [file] [log] [blame]
Chris Masone3bd3c8c2011-06-13 08:20:26 -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/service.h"
6
7#include <map>
8#include <string>
9#include <vector>
10
11#include <dbus-c++/dbus.h>
12#include <chromeos/dbus/service_constants.h>
13#include <gtest/gtest.h>
14#include <gmock/gmock.h>
15
16#include "shill/dbus_adaptor.h"
17#include "shill/ethernet_service.h"
18#include "shill/manager.h"
19#include "shill/mock_control.h"
20#include "shill/mock_device.h"
21#include "shill/mock_service.h"
22#include "shill/property_store_unittest.h"
23#include "shill/shill_event.h"
24
25using std::map;
26using std::string;
27using std::vector;
28using ::testing::_;
29using ::testing::NiceMock;
30using ::testing::Return;
31using ::testing::Test;
32
33namespace shill {
34
35class ServiceTest : public PropertyStoreTest {
36 public:
37 ServiceTest() {}
38 virtual ~ServiceTest() {}
39};
40
41TEST_F(ServiceTest, Dispatch) {
42 DeviceRefPtr device(new MockDevice(&control_interface_,
43 &dispatcher_,
44 &manager_,
45 "mock-device",
46 0));
47 ServiceRefPtr service(new MockService(&control_interface_,
48 &dispatcher_,
49 device.get(),
50 "mock-service"));
51 ::DBus::Error error;
52 EXPECT_TRUE(DBusAdaptor::DispatchOnType(service.get(),
53 flimflam::kSaveCredentialsProperty,
54 bool_v_,
55 error));
56 EXPECT_TRUE(DBusAdaptor::DispatchOnType(service.get(),
57 flimflam::kPriorityProperty,
58 int32_v_,
59 error));
60 EXPECT_TRUE(DBusAdaptor::DispatchOnType(service.get(),
61 flimflam::kEAPEAPProperty,
62 string_v_,
63 error));
64
65 EXPECT_FALSE(DBusAdaptor::DispatchOnType(service.get(),
66 flimflam::kFavoriteProperty,
67 bool_v_,
68 error));
69 EXPECT_EQ(invalid_args_, error.name());
70 EXPECT_FALSE(DBusAdaptor::DispatchOnType(service.get(), "", int16_v_, error));
71 EXPECT_EQ(invalid_prop_, error.name());
72 EXPECT_FALSE(DBusAdaptor::DispatchOnType(service.get(), "", int32_v_, error));
73 EXPECT_EQ(invalid_prop_, error.name());
74 EXPECT_FALSE(DBusAdaptor::DispatchOnType(service.get(),
75 "",
76 uint16_v_,
77 error));
78 EXPECT_EQ(invalid_prop_, error.name());
79 EXPECT_FALSE(DBusAdaptor::DispatchOnType(service.get(),
80 "",
81 uint32_v_,
82 error));
83 EXPECT_EQ(invalid_prop_, error.name());
84 EXPECT_FALSE(DBusAdaptor::DispatchOnType(service.get(),
85 "",
86 strings_v_,
87 error));
88 EXPECT_EQ(invalid_prop_, error.name());
89}
90
91} // namespace shill