Sha256: 64af9c4912984f5bd0786b91ba86bc7ae656e3ad99cbf4c5c1d9cdb51dec772a

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

#!/usr/bin/env ruby
# Test the bus class
require File.expand_path("../test_helper", __FILE__)
require "test/unit"
require 'rubygems'
require 'nokogiri'
require "dbus"

class BusAndXmlBackendTest < Test::Unit::TestCase
  def setup
    @bus = DBus::ASessionBus.new
  end

  def test_introspection_reading_rexml
    DBus::IntrospectXMLParser.backend = DBus::IntrospectXMLParser::REXMLParser
    @svc = @bus.service("org.ruby.service")
    obj = @svc.object("/org/ruby/MyInstance")
    obj.default_iface = 'org.ruby.SampleInterface'
    obj.introspect
    assert_nothing_raised do
      assert_equal 42, obj.the_answer[0], "should respond to :the_answer"
    end
    assert_nothing_raised do
      assert_equal "oof", obj["org.ruby.AnotherInterface"].Reverse('foo')[0], "should work with multiple interfaces"
    end
  end

  def test_introspection_reading_nokogiri
    # peek inside the object to see if a cleanup step worked or not
    DBus::IntrospectXMLParser.backend = DBus::IntrospectXMLParser::NokogiriParser
    @svc = @bus.service("org.ruby.service")
    obj = @svc.object("/org/ruby/MyInstance")
    obj.default_iface = 'org.ruby.SampleInterface'
    obj.introspect
    assert_nothing_raised do
      assert_equal 42, obj.the_answer[0], "should respond to :the_answer"
    end
    assert_nothing_raised do
      assert_equal "oof", obj["org.ruby.AnotherInterface"].Reverse('foo')[0], "should work with multiple interfaces"
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-dbus-0.10.0 test/bus_and_xml_backend_test.rb
ruby-dbus-0.9.3 test/bus_and_xml_backend_test.rb
ruby-dbus-0.9.2 test/bus_and_xml_backend_test.rb