require 'test/unit'
require 'phi'

class TCSubComponent < Test::Unit::TestCase
  def test_upcase
    assert_equal 'EDIT', Phi.upcase('edit')
  end
  def test_capitalize
    assert_equal 'Edit', Phi.capitalize('edit')
  end
=begin
  skip_const_name = %w[ Control Application Screen Menu CustomGrid Form ]
  Phi.constants.select { |const_name|
    next if skip_const_name.include? const_name
    const = eval("Phi::#{const_name}")
    Class === const && const < Phi::Component
  }.each { |cname|
    iname = Phi.downcase(cname)
    if /Action|Animate|ApplicationEvents|Bevel|CheckListBox|ColorBox|ComboBox|Control|CustomizeDlg|Bar|Frame|Grid|Image|ListBox|PaintBox/ =~ cname
      text_test_code = ''
    else
      text_method_name = /BitBtn|Button|CheckBox|GroupBox|Label/ =~ cname ? 'caption' : 'text'
      text_test_code = <<EOT
assert_equal 'ab.cd', instance.#{text_method_name}
EOT
    end
    eval_string = <<EOT
      class Sub#{cname} < Phi::#{cname}
        def initialize(*args)
          @form = Phi::Form.new(:form)
          super(@form, :#{iname}, *args)
        end
      end

      def test_#{iname}
        instance = nil
        assert_nothing_raised { instance = Sub#{cname}.new('ab.cd') }
        assert_equal '#{iname}', instance.name
        #{text_test_code}
      end
EOT
    # puts eval_string
    eval eval_string
  }
=end
end

