Sha256: 64ea91eb69e7e48add44721b74656f82cccfd5f2131c8d8f217992967569f068

Contents?: true

Size: 1.67 KB

Versions: 13

Compression:

Stored size: 1.67 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 EventTests < Test::Unit::TestCase

  def test_event
    evt = Wx::Event.new(100, 1)
    assert_equal(100, evt.event_type)
    assert_equal(1, evt.id)
    assert(!evt.should_propagate)
    evt.skip
    assert(evt.skipped)
    evt_dup = evt.clone
    assert_not_equal(evt, evt_dup)
    assert_equal(evt.event_type, evt_dup.event_type)
    assert_equal(evt.id, evt_dup.id)
  end

  def test_command_event
    GC.start
    evt = Wx::CommandEvent.new(100, 1)
    evt.set_client_object({one: 'first'})
    assert_equal(100, evt.event_type)
    assert_equal(1, evt.id)
    assert_equal({one: 'first'}, evt.get_client_object)
    assert(evt.should_propagate)
    GC.start
    evt.skip
    assert(evt.skipped)
    evt.string = 'CommandEvent Test'
    assert_equal('CommandEvent Test', evt.string)
    evt_dup = evt.clone
    GC.start
    assert_not_equal(evt, evt_dup)
    assert_equal(evt.event_type, evt_dup.event_type)
    assert_equal(evt.id, evt_dup.id)
    assert_equal(evt.string, evt_dup.string)
    assert_equal({one: 'first'}, evt.get_client_object)
    assert_equal({one: 'first'}, evt_dup.get_client_object)
  end

  def test_event_clone
    evt = Wx::MouseEvent.new(Wx::EVT_LEFT_DOWN)
    assert_equal(Wx::EVT_LEFT_DOWN, evt.event_type)
    evt.position = Wx::Point.new(333,666)
    assert_equal(Wx::Point.new(333,666), evt.position)
    evt_dup = evt.clone
    assert_instance_of(Wx::MouseEvent, evt_dup)
    assert_not_equal(evt, evt_dup)
    assert_equal(evt.event_type, evt_dup.event_type)
    assert_equal(evt.position, evt_dup.position)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
wxruby3-1.3.1 tests/test_events.rb
wxruby3-1.3.0 tests/test_events.rb
wxruby3-1.2.1 tests/test_events.rb
wxruby3-1.2.0 tests/test_events.rb
wxruby3-1.1.2 tests/test_events.rb
wxruby3-1.1.1 tests/test_events.rb
wxruby3-1.1.0 tests/test_events.rb
wxruby3-1.0.1 tests/test_events.rb
wxruby3-0.9.8 tests/test_events.rb
wxruby3-0.9.7 tests/test_events.rb
wxruby3-0.9.5 tests/test_events.rb
wxruby3-0.9.4 tests/test_events.rb
wxruby3-0.9.3 tests/test_events.rb