require "test/unit"
require "phi"
class TCStaticText < Test::Unit::TestCase
  def test_ancestors
    assert_equal Phi::WinControl, Phi::StaticText.superclass
  end

  def setup
    @form = Phi::Form.new(:form)
  end

  def test_tag
    instance = Phi::StaticText.new(@form, :static_text)
    assert_raise(NoMethodError) { instance.tag }
  end

  def test_new_name_default
    instance = Phi::StaticText.new(@form)
    assert_equal 'StaticText1', instance.name
    assert_equal instance, @form.instance_eval { @StaticText1 }
    assert_equal instance, @form.instance_eval { self.StaticText1 }
  end

  def test_new_name
    instance = Phi::StaticText.new(@form, :static_text)
    assert_equal 'static_text', instance.name
    assert_equal instance, @form.instance_eval { @static_text }
    assert_equal instance, @form.instance_eval { self.static_text }
  end

  def test_new_text_default
    instance = Phi::StaticText.new(@form, :static_text)
    assert_equal '', instance.caption
  end

  def test_new_text
    instance = Phi::StaticText.new(@form, :static_text, 'hello')
    assert_equal 'hello', instance.caption
  end

  def test_font
    instance = Phi::StaticText.new(@form, :static_text)
    assert_instance_of Phi::Font, instance.font
  end
end

class SubStaticText < Phi::StaticText
  def initialize(*args)
    @form = Phi::Form.new(:form)
    super(@form, :static_text, *args)
  end
end

class TCSubStaticText < Test::Unit::TestCase
  def test_new
    instance = nil
    assert_nothing_raised { instance = SubStaticText.new('ab.cd') }
    assert_equal 'static_text', instance.name
    assert_equal 'ab.cd', instance.caption
  end
end
