summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/vdr/osd/menu_spec.rb50
-rw-r--r--spec/vdrswig-fakewrapper.rb21
2 files changed, 66 insertions, 5 deletions
diff --git a/spec/vdr/osd/menu_spec.rb b/spec/vdr/osd/menu_spec.rb
index dff9b31..21235b9 100644
--- a/spec/vdr/osd/menu_spec.rb
+++ b/spec/vdr/osd/menu_spec.rb
@@ -68,21 +68,65 @@ describe Vdr::Osd::Menu do
end
it 'should return the parents result from process_key' do
- @menu.process_key(Vdr::Swig::KOk).should == Vdr::Swig::OsUnknown
+ @menu.fake_process_key(Vdr::Swig::KOk).should == Vdr::Swig::OsUnknown
end
it 'should return OsBack from process_key when requesting to close the menu' do
@menu.close
- @menu.process_key(Vdr::Swig::KOk).should == Vdr::Swig::OsBack
+ @menu.fake_process_key(Vdr::Swig::KOk).should == Vdr::Swig::OsBack
end
it 'should return OsEnd from process_key when requesting to close all menus' do
@menu.close_all
- @menu.process_key(Vdr::Swig::KOk).should == Vdr::Swig::OsEnd
+ @menu.fake_process_key(Vdr::Swig::KOk).should == Vdr::Swig::OsEnd
end
it 'should add a new menu item' do
@menu.add_new_item('item')
@menu[0].text.should == 'item'
end
+
+ it 'should set the color help texts' do
+ @menu.red_help = 'Red'
+ @menu.COsdMenu_help_texts.should == ['Red', nil, nil, nil]
+
+ @menu.green_help = 'Green'
+ @menu.COsdMenu_help_texts.should == ['Red', 'Green', nil, nil]
+
+ @menu.yellow_help = 'Yellow'
+ @menu.COsdMenu_help_texts.should == ['Red', 'Green', 'Yellow', nil]
+
+ @menu.blue_help = 'Blue'
+ @menu.COsdMenu_help_texts.should == ['Red', 'Green', 'Yellow', 'Blue']
+ end
+
+ it 'should trigger the on_keypress event when a key is pressed' do
+ pressed_key = nil
+ @menu.on_keypress do |key|
+ pressed_key = key
+ end
+ @menu.fake_process_key(Vdr::Swig::KRed)
+ pressed_key.should == :key_red
+ end
+
+ it 'should trigger the on_keypress event when a specific key is pressed' do
+ red_key_pressed = false
+ @menu.on_keypress(:key_red) do
+ red_key_pressed = true
+ end
+ @menu.fake_process_key(Vdr::Swig::KGreen)
+ red_key_pressed.should == false
+ @menu.fake_process_key(Vdr::Swig::KRed)
+ red_key_pressed.should == true
+ end
+
+ it 'should clear the menu' do
+ @menu.clear
+ @menu.COsdMenu_cleared.should == true
+ end
+
+ it 'should redisplay the menu when refreshing' do
+ @menu.should_receive(:display)
+ @menu.refresh
+ end
end
diff --git a/spec/vdrswig-fakewrapper.rb b/spec/vdrswig-fakewrapper.rb
index a004ac3..2b98723 100644
--- a/spec/vdrswig-fakewrapper.rb
+++ b/spec/vdrswig-fakewrapper.rb
@@ -27,8 +27,13 @@ module Vdr
OsEnd = :OsEnd
KOk = 1
+ KRed = 2
+ KGreen = 3
+ KBlue = 4
+ KYellow = 5
+
class COsdMenu
- attr_reader :cosdmenu_ctor_arguments, :current
+ attr_reader :cosdmenu_ctor_arguments, :current, :COsdMenu_help_texts, :COsdMenu_cleared
def initialize(*args)
@cosdmenu_ctor_arguments = args
@@ -39,15 +44,27 @@ module Vdr
def add(item)
end
-
+
def process_key(key)
return OsUnknown
end
+
+ def fake_process_key(key)
+ return process_key(key)
+ end
def simulate_select(index)
@current = index
process_key(Vdr::Swig::KOk)
end
+
+ def set_help(red, green, yellow, blue)
+ @COsdMenu_help_texts = [red, green, yellow, blue]
+ end
+
+ def clear
+ @COsdMenu_cleared = true
+ end
end
class COsdItem