test/test-gtk-widget.rb in gtk3-3.5.1 vs test/test-gtk-widget.rb in gtk3-4.0.0
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (C) 2008-2020 Ruby-GNOME Project Team
+# Copyright (C) 2008-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.
@@ -240,11 +240,17 @@
data = @resource_data
widget_class = Class.new(Gtk::Window) do
type_register "BindTemplateChildNothing"
singleton_class.send(:define_method, :init) do
+ super()
set_template(:data => data)
+ set_connect_func do |handler_name|
+ lambda do
+ # Do nothing
+ end
+ end
end
end
widget = widget_class.new
assert_nil(widget.get_template_child(widget_class, :label))
end
@@ -253,12 +259,18 @@
data = @resource_data
widget_class = Class.new(Gtk::Window) do
type_register "BindTemplateChildBind"
singleton_class.send(:define_method, :init) do
+ super()
set_template(:data => data)
bind_template_child(:label)
+ set_connect_func do |handler_name|
+ lambda do
+ # Do nothing
+ end
+ end
end
end
widget = widget_class.new
assert_equal(Gtk::Label,
widget.get_template_child(widget_class, :label).class)
@@ -276,10 +288,11 @@
handler_names = []
widget_class = Class.new(Gtk::Window) do
type_register "SetConnectFunc"
singleton_class.send(:define_method, :init) do
+ super()
set_template(:data => data)
bind_template_child(:label)
set_connect_func do |handler_name|
handler_names << handler_name
lambda do
@@ -289,7 +302,26 @@
end
end
widget_class.new
assert_equal(["on_move_cursor"], handler_names)
end
+ end
+
+ def test_gc_action_group
+ GC.start
+ n_alive_action_groups_before =
+ ObjectSpace.each_object(Gio::SimpleActionGroup) {}
+ n_tries = 100
+ n_tries.times do |i|
+ action_prefix = "test#{i}"
+ action_group = Gio::SimpleActionGroup.new
+ @widget.insert_action_group(action_prefix, action_group)
+ end
+ GC.start
+ n_alive_action_groups_after =
+ ObjectSpace.each_object(Gio::SimpleActionGroup) {}
+ n_alive_action_groups =
+ n_alive_action_groups_after -
+ n_alive_action_groups_before
+ assert_equal(n_tries, n_alive_action_groups)
end
end