Sha256: fff2a8d3b9e077864cda9dbe2ff7b7a9bb268de6372485231658ec7848939b72

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

require_relative './lib/wxapp_runner'

class FileDialogTests < Test::Unit::TestCase

  def dialog_tester(dlg, rc=Wx::ID_OK)
    if Wx::PLATFORM == 'WXGTK'
      timer = Wx::Timer.new(dlg)
      dlg.evt_timer(timer) { dlg.end_modal(rc) }
      timer.start_once(2000)
      dlg.show_modal
    else
      rc
    end
  end

  def test_file_dialog
    dlg = Wx::FileDialog.new(nil, 'Select file')
    assert_kind_of(Wx::FileDialog, dlg)
    assert_kind_of(Wx::Dialog, dlg)
    assert_kind_of(Wx::Window, dlg)
    assert_equal(Wx::ID_OK, dialog_tester(dlg))
  end

  class FileDialogTestCustomization < Wx::FileDialogCustomizeHook

    def initialize
      super
      @hooked = Wx::PLATFORM != 'WXGTK'
    end

    attr_reader :hooked

    def add_custom_controls(customizer)
      @hooked = true
      btn_ctrl = customizer.add_button('Custom Button')
    end

  end

  def test_customized_file_dialog
    dlg = Wx::FileDialog.new(nil, 'Select file')
    hook = FileDialogTestCustomization.new
    dlg.set_customize_hook(hook)
    GC.start
    assert_equal(Wx::ID_OK, dialog_tester(dlg))
    GC.start
    assert_true(hook.hooked)
    GC.start
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wxruby3-0.9.7-x64-mingw-ucrt tests/test_file_dialog.rb
wxruby3-0.9.5-x64-mingw-ucrt tests/test_file_dialog.rb
wxruby3-0.9.4-x64-mingw-ucrt tests/test_file_dialog.rb
wxruby3-0.9.3-x64-mingw-ucrt tests/test_file_dialog.rb
wxruby3-0.9.2-x64-mingw-ucrt tests/test_file_dialog.rb
wxruby3-0.9.1-x64-mingw-ucrt tests/test_file_dialog.rb
wxruby3-0.9.0-x64-mingw-ucrt tests/test_file_dialog.rb