File: test-loader.rb

package info (click to toggle)
ruby-gnome 4.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 26,648 kB
  • sloc: ruby: 67,701; ansic: 67,431; xml: 350; sh: 201; cpp: 45; makefile: 42
file content (104 lines) | stat: -rw-r--r-- 2,708 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright (C) 2012-2022  Ruby-GNOME Project Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

class TestLoaderInfo < Test::Unit::TestCase
  def setup
    @repository = GObjectIntrospection::Repository.default
  end

  def test_define_class
    info = @repository.find("Gio", "Application")
    gtype = info.gtype
    assert_equal(gtype, Gio::Application.gtype)
  end

  sub_test_case("virtual function") do
    def test_without_prefix
      active_vfs_class = Class.new(Gio::Vfs) do
        type_register("ActiveVfsWithoutPrefix")

        def virtual_do_is_active
          true
        end
      end
      active_vfs = active_vfs_class.new
      assert do
        active_vfs.active?
      end
    end

    def test_with_prefix
      active_vfs_class = Class.new(Gio::Vfs) do
        type_register("ActiveVfsWithPrefix")

        def virtual_do_gvfs_is_active
          true
        end
      end
      active_vfs = active_vfs_class.new
      assert do
        active_vfs.active?
      end
    end

    def test_interface
      resettable_converter_class = Class.new(GLib::Object) do
        type_register("ResettableConverter")

        include Gio::Converter

        attr_reader :was_reset

        def virtual_do_reset
          @was_reset = true
        end
      end
      resettable_converter = resettable_converter_class.new
      resettable_converter.reset
      assert do
        resettable_converter.was_reset
      end
    end

    def test_ancestor
      immutable_menu_class = Class.new(Gio::Menu) do
        type_register("ImmutableMenu")

        def virtual_do_is_mutable
          false
        end
      end
      immutable_menu = immutable_menu_class.new
      assert do
        not immutable_menu.mutable?
      end
    end
  end

  sub_test_case("#==") do
    def test_invalid
      assert do
        not (Gio::File.new_for_path("nonexistent") == "invalid")
      end
    end

    def test_nil
      assert do
        not (Gio::File.new_for_path("nonexistent") == nil)
      end
    end
  end
end