require 'test/unit'

require 'fox'

include Fox

class TC_FXAccelTable < Test::Unit::TestCase
  def setup
    @accel = FXAccelTable.new
  end

  def test_addAccel
    hotkey = fxparsehotkey('&A')
    target = FXObject.new
    seldn, selup = 0, 0
    @accel.addAccel(hotkey)
    @accel.addAccel(hotkey, target)
    @accel.addAccel(hotkey, target, seldn)
    @accel.addAccel(hotkey, target, seldn, selup)
  end
  
  def test_hasAccel
    hotkey = fxparsehotkey('&b')
    assert(!@accel.hasAccel?(hotkey))
    @accel.addAccel(hotkey)
    assert(@accel.hasAccel?(hotkey))
  end
  
  def test_targetOfAccel
    hotkey = fxparsehotkey("&x")
    target = FXObject.new
    @accel.addAccel(hotkey, target)
    assert_same(target, @accel.targetOfAccel(hotkey))
  end
  
  def test_removeAccel
    hotkey = fxparsehotkey('&b')
    @accel.addAccel(hotkey)
    assert(@accel.hasAccel?(hotkey))
    @accel.removeAccel(hotkey)
    assert(!@accel.hasAccel?(hotkey))
  end
end
