Sha256: feda8a3f451358d4e45c8425753f2be72e6af253f88ae907dfa42b1afa9be62b

Contents?: true

Size: 1.36 KB

Versions: 21

Compression:

Stored size: 1.36 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 TestArtProvider < Test::Unit::TestCase

  class MyArtProvider < Wx::ArtProvider

    class << self
      def is_called?
        !!@called
      end
      def set_called(f = true)
        @called = f
      end
    end

    def create_bitmap(id, client, size)
      if id == Wx::ArtProvider.get_message_box_icon_id(Wx::ICON_INFORMATION)
        MyArtProvider.set_called
        Wx::Bitmap(:sample3)
      else
        MyArtProvider.set_called(false)
        super
      end
    end

  end

  def test_custom_provider
    assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
    GC.start
    assert(!MyArtProvider.is_called?)
    GC.start
    assert_nothing_raised { Wx::ArtProvider.push(MyArtProvider.new) }
    GC.start
    assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
    GC.start
    assert(MyArtProvider.is_called?)
    GC.start
    assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_ERROR))
    GC.start
    assert(!MyArtProvider.is_called?)
    GC.start
    assert_nothing_raised { Wx::ArtProvider.pop }
    GC.start
    assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
    GC.start
    assert(!MyArtProvider.is_called?)
    GC.start
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
wxruby3-1.5.1 tests/test_art_provider.rb
wxruby3-1.5.0 tests/test_art_provider.rb
wxruby3-1.4.2 tests/test_art_provider.rb
wxruby3-1.4.1 tests/test_art_provider.rb
wxruby3-1.4.0 tests/test_art_provider.rb
wxruby3-1.3.1 tests/test_art_provider.rb
wxruby3-1.3.0 tests/test_art_provider.rb
wxruby3-1.2.1 tests/test_art_provider.rb
wxruby3-1.2.0 tests/test_art_provider.rb
wxruby3-1.1.2 tests/test_art_provider.rb
wxruby3-1.1.1 tests/test_art_provider.rb
wxruby3-1.1.0 tests/test_art_provider.rb
wxruby3-1.0.1 tests/test_art_provider.rb
wxruby3-0.9.8 tests/test_art_provider.rb
wxruby3-0.9.7 tests/test_art_provider.rb
wxruby3-0.9.5 tests/test_art_provider.rb
wxruby3-0.9.4 tests/test_art_provider.rb
wxruby3-0.9.3 tests/test_art_provider.rb
wxruby3-0.9.2 tests/test_art_provider.rb
wxruby3-0.9.1 tests/test_art_provider.rb