<commit_before>class TestGtkBuilder < Test::Unit::TestCase
  include GtkTestUtils

  def test_constants
    only_gtk_version(2, 12, 0)
    assert_kind_of(Gtk::BuilderError, Gtk::BuilderError::INVALID_TAG)
  end

  def test_new
    only_gtk_version(2, 12, 0)
    assert_nothing_raised do
      Gtk::Builder.new
    end
  end

  def test_add_from_file
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add_from_file(ui_definition_file.path)
    end
    assert_kind_of(Gtk::Dialog, builder["dialog1"])
  end

  def test_add_from_string
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add_from_string(ui_definition)
    end
    assert_kind_of(Gtk::VBox, builder["vbox1"])
  end

  def test_add_with_file
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add(ui_definition_file.path)
    end
    assert_kind_of(Gtk::HButtonBox, builder["hbuttonbox1"])
  end

  def test_add_with_string
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add(ui_definition)
    end
    assert_kind_of(Gtk::Button, builder["ok_button"])
  end

  def test_add_chain
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder << ui_definition_file.path << ui_definition_simple
    end
    assert_kind_of(Gtk::Dialog, builder["dialog1"])
    assert_kind_of(Gtk::Window, builder["main-window"])
  end

  def test_objects
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder << ui_definition_file.path << ui_definition_simple
    end
    assert_equal(["dialog1", "vbox1", "hbuttonbox1", "ok_button",
                  "main-window"].sort,
                 builder.objects.collect {|object| object.name}.sort)
  end

  def test_translation_domain
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nil(builder.translation_domain)
    builder.translation_domain = "ruby-gnome2"
    assert_equal("ruby-gnome2", builder.translation_domain)
  end

  def test_connect_signals
    only_gtk_version(2, 12, 0)
<commit_msg>* test/test_gtk_builder.rb (TestGtkBuilder#test_objects): use   builder_name instead of name.<commit_after>class TestGtkBuilder < Test::Unit::TestCase
  include GtkTestUtils

  def test_constants
    only_gtk_version(2, 12, 0)
    assert_kind_of(Gtk::BuilderError, Gtk::BuilderError::INVALID_TAG)
  end

  def test_new
    only_gtk_version(2, 12, 0)
    assert_nothing_raised do
      Gtk::Builder.new
    end
  end

  def test_add_from_file
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add_from_file(ui_definition_file.path)
    end
    assert_kind_of(Gtk::Dialog, builder["dialog1"])
  end

  def test_add_from_string
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add_from_string(ui_definition)
    end
    assert_kind_of(Gtk::VBox, builder["vbox1"])
  end

  def test_add_with_file
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add(ui_definition_file.path)
    end
    assert_kind_of(Gtk::HButtonBox, builder["hbuttonbox1"])
  end

  def test_add_with_string
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder.add(ui_definition)
    end
    assert_kind_of(Gtk::Button, builder["ok_button"])
  end

  def test_add_chain
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder << ui_definition_file.path << ui_definition_simple
    end
    assert_kind_of(Gtk::Dialog, builder["dialog1"])
    assert_kind_of(Gtk::Window, builder["main-window"])
  end

  def test_objects
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nothing_raised do
      builder << ui_definition_file.path << ui_definition_simple
    end
    assert_equal(["dialog1", "vbox1", "hbuttonbox1", "ok_button",
                  "main-window"].sort,
                 builder.objects.collect {|object| object.builder_name}.sort)
  end

  def test_translation_domain
    only_gtk_version(2, 12, 0)

    builder = Gtk::Builder.new
    assert_nil(builder.translation_domain)
    builder.translation_domain = "ruby-gnome2"
    assert_equal("ruby-gnome2", builder.translation_domain)
  end

  def test_connect_signals
    only_gtk_version(2, 12, 0)

{'fraction_non_alphanumeric': 0.09446397188049209, 'fraction_numerical': 0.021528998242530756, 'mean_word_length': 3.6793422404933196, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7459176', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1545, 'n_words': 281}