Home | History | Annotate | Download | only in dbus
      1 // Copyright (c) 2012 The Chromium 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 "chromeos/dbus/introspectable_client.h"
      6 
      7 #include "testing/gtest/include/gtest/gtest.h"
      8 
      9 namespace {
     10 
     11 const char kXmlData[] =
     12 "<!DOCTYPE node PUBLIC "
     13 "\"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" "
     14 "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
     15 "<node>\n"
     16 "  <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
     17 "    <method name=\"Introspect\">\n"
     18 "      <arg type=\"s\" direction=\"out\"/>\n"
     19 "    </method>\n"
     20 "  </interface>\n"
     21 "  <interface name=\"org.bluez.Device\">\n"
     22 "    <method name=\"GetProperties\">\n"
     23 "      <arg type=\"a{sv}\" direction=\"out\"/>\n"
     24 "    </method>\n"
     25 "    <method name=\"SetProperty\">\n"
     26 "      <arg type=\"s\" direction=\"in\"/>\n"
     27 "      <arg type=\"v\" direction=\"in\"/>\n"
     28 "    </method>\n"
     29 "    <method name=\"DiscoverServices\">\n"
     30 "      <arg type=\"s\" direction=\"in\"/>\n"
     31 "      <arg type=\"a{us}\" direction=\"out\"/>\n"
     32 "    </method>\n"
     33 "    <method name=\"CancelDiscovery\"/>\n"
     34 "    <method name=\"Disconnect\"/>\n"
     35 "    <signal name=\"PropertyChanged\">\n"
     36 "      <arg type=\"s\"/>\n"
     37 "      <arg type=\"v\"/>\n"
     38 "    </signal>\n"
     39 "    <signal name=\"DisconnectRequested\"/>\n"
     40 "  </interface>\n"
     41 "  <interface name=\"org.bluez.Input\">\n"
     42 "    <method name=\"Connect\"/>\n"
     43 "    <method name=\"Disconnect\"/>\n"
     44 "    <method name=\"GetProperties\">\n"
     45 "      <arg type=\"a{sv}\" direction=\"out\"/>\n"
     46 "    </method>\n"
     47 "    <signal name=\"PropertyChanged\">\n"
     48 "      <arg type=\"s\"/>\n"
     49 "      <arg type=\"v\"/>\n"
     50 "    </signal>\n"
     51 "  </interface>\n"
     52 "</node>";
     53 
     54 }  // namespace
     55 
     56 namespace chromeos {
     57 
     58 TEST(IntrospectableClientTest, GetInterfacesFromIntrospectResult) {
     59   std::vector<std::string> interfaces =
     60       IntrospectableClient::GetInterfacesFromIntrospectResult(kXmlData);
     61 
     62   ASSERT_EQ(3U, interfaces.size());
     63   EXPECT_EQ("org.freedesktop.DBus.Introspectable", interfaces[0]);
     64   EXPECT_EQ("org.bluez.Device", interfaces[1]);
     65   EXPECT_EQ("org.bluez.Input", interfaces[2]);
     66 }
     67 
     68 }  // namespace chromeos
     69