summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/introspectable_client_unittest.cc
blob: 5e98b1cdf7d96665b4c8bd6eba8881ee14c79554 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chromeos/dbus/introspectable_client.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace {

const char kXmlData[] =
"<!DOCTYPE node PUBLIC "
"\"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" "
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
"<node>\n"
"  <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
"    <method name=\"Introspect\">\n"
"      <arg type=\"s\" direction=\"out\"/>\n"
"    </method>\n"
"  </interface>\n"
"  <interface name=\"org.bluez.Device\">\n"
"    <method name=\"GetProperties\">\n"
"      <arg type=\"a{sv}\" direction=\"out\"/>\n"
"    </method>\n"
"    <method name=\"SetProperty\">\n"
"      <arg type=\"s\" direction=\"in\"/>\n"
"      <arg type=\"v\" direction=\"in\"/>\n"
"    </method>\n"
"    <method name=\"DiscoverServices\">\n"
"      <arg type=\"s\" direction=\"in\"/>\n"
"      <arg type=\"a{us}\" direction=\"out\"/>\n"
"    </method>\n"
"    <method name=\"CancelDiscovery\"/>\n"
"    <method name=\"Disconnect\"/>\n"
"    <signal name=\"PropertyChanged\">\n"
"      <arg type=\"s\"/>\n"
"      <arg type=\"v\"/>\n"
"    </signal>\n"
"    <signal name=\"DisconnectRequested\"/>\n"
"  </interface>\n"
"  <interface name=\"org.bluez.Input\">\n"
"    <method name=\"Connect\"/>\n"
"    <method name=\"Disconnect\"/>\n"
"    <method name=\"GetProperties\">\n"
"      <arg type=\"a{sv}\" direction=\"out\"/>\n"
"    </method>\n"
"    <signal name=\"PropertyChanged\">\n"
"      <arg type=\"s\"/>\n"
"      <arg type=\"v\"/>\n"
"    </signal>\n"
"  </interface>\n"
"</node>";

}  // namespace

namespace chromeos {

TEST(IntrospectableClientTest, GetInterfacesFromIntrospectResult) {
  std::vector<std::string> interfaces =
      IntrospectableClient::GetInterfacesFromIntrospectResult(kXmlData);

  ASSERT_EQ(3U, interfaces.size());
  EXPECT_EQ("org.freedesktop.DBus.Introspectable", interfaces[0]);
  EXPECT_EQ("org.bluez.Device", interfaces[1]);
  EXPECT_EQ("org.bluez.Input", interfaces[2]);
}

}  // namespace chromeos