Sha256: 7914c2d5b9413db03b3213d5f049c6729da16098c793a40c9158fd0a450abe3f

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

require 'test/unit'
require 'rubygems'
require 'rubeus'

# Test for attributes.rb
class TestAttributes < Test::Unit::TestCase
  include Rubeus::Swing

  # setup method
  def setup
  end

  # new with no argument
  def test_default_attributes=
    JFrame.new do |f|
      assert_equal(JFrame.const_get(:EXIT_ON_CLOSE), f.default_close_operation)
      assert_equal(400, f.size.width)
      assert_equal(300, f.size.height)
    end
  end

  # new with argument
  def test_new
    JFrame.new(:title => 'test') do |f|
      assert_equal(JFrame.const_get(:EXIT_ON_CLOSE), f.default_close_operation)
      assert_equal(400, f.size.width)
      assert_equal(300, f.size.height)
      assert_equal('test', f.title)
    end
  end

  # new with argument that overrides default attributes
  def test_new_override
    JFrame.new(:size => "500 x 400") do |f|
      assert_equal(JFrame.const_get(:EXIT_ON_CLOSE), f.default_close_operation)
      assert_equal(500, f.size.width)
      assert_equal(400, f.size.height)
    end
  end

  # new with argument that value is symbol
  def test_new_with_symbol_value
    JFrame.new(:default_close_operation => :DO_NOTHING_ON_CLOSE) do |f|
      assert_equal(JFrame.const_get(:DO_NOTHING_ON_CLOSE), f.default_close_operation)
      assert_equal(400, f.size.width)
      assert_equal(300, f.size.height)
    end
  end

  # new with argument with error
  def test_new_with_attribute_does_not_exist
    assert_raise(ArgumentError) do
      JFrame.new(:illegal_param => "illegal_value") do |f|
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubeus-0.0.9-java test/rubeus/awt/test_attributes.rb
rubeus-0.0.8-java test/rubeus/awt/test_attributes.rb
rubeus-0.0.7-java test/rubeus/awt/test_attributes.rb