summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy.zurcher@heraeus.com>2011-04-14 10:28:58 +0200
committerJérémy Zurcher <jeremy.zurcher@heraeus.com>2011-04-14 10:28:58 +0200
commitcc0f3f9e31ad216224b44f3a7897108cd96e17bb (patch)
tree91fdc2b4a7de82c9110516cb808d2cf4c9c4fa94 /spec
parent350843476bf1156881a0dd45131f5f6e4efee77f (diff)
downloadffi-efl-cc0f3f9e31ad216224b44f3a7897108cd96e17bb.zip
ffi-efl-cc0f3f9e31ad216224b44f3a7897108cd96e17bb.tar.gz
update ecore event, use FFIHelper, clean spec
Diffstat (limited to 'spec')
-rw-r--r--spec/ecore_event_spec.rb54
1 files changed, 26 insertions, 28 deletions
diff --git a/spec/ecore_event_spec.rb b/spec/ecore_event_spec.rb
index 0dba5b9..d8bc5cc 100644
--- a/spec/ecore_event_spec.rb
+++ b/spec/ecore_event_spec.rb
@@ -10,7 +10,7 @@ describe E17::ECORE do
#
before(:all) do
USER_SIGNAL_CB = Proc.new do |data, type, event|
- data.read_string.should eql "666"
+ data.read_string.should eql "ok"
type.should eql ECORE::EVENT_SIGNAL_USER
event.read_int.should eql 666
ECORE.event_current_type_get.should eql ECORE::EVENT_SIGNAL_USER
@@ -21,25 +21,26 @@ describe E17::ECORE do
data.read_string.should eql "none"
event.read_int.should eql 666
end
- NONE = "none"
- NONE_PTR = FFI::MemoryPointer.from_string NONE
+ OK = FFI::MemoryPointer.from_string "ok"
+ KO = FFI::MemoryPointer.from_string "ko"
+ NONE = FFI::MemoryPointer.from_string "none"
end
#
- it 'should be able to add event hanlder and process event' do
+ it 'should be able to add, del event hanlder and process event' do
ECORE.init
evt = FFI::MemoryPointer.new(:int)
evt.write_int 666
# add, del, add event handler
- evt_handler = ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, "wrong"
+ evt_handler = ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, KO
evt_handler.null?.should be_false
- ECORE.event_handler_del evt_handler
- evt_handler = ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, "666"
+ ECORE.event_handler_del(evt_handler).address.should eql KO.address
+ evt_handler = ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, OK
evt_handler.null?.should be_false
# add, del, add event
- ecore_evt = ECORE.event_add ECORE::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE_PTR
+ ecore_evt = ECORE.event_add ECORE::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE
ecore_evt.null?.should be_false
- ECORE.event_del ecore_evt
- ecore_evt = ECORE.event_add ECORE::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE_PTR
+ ECORE.event_del(ecore_evt).address.should eql NONE.address
+ ecore_evt = ECORE.event_add ECORE::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE
ecore_evt.null?.should be_false
ECORE.main_loop_begin # process event
ECORE.shutdown
@@ -49,12 +50,12 @@ describe E17::ECORE do
ECORE.init
evt = FFI::MemoryPointer.new(:int)
evt.write_int 666
- evt_handler = ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, "wrong"
+ evt_handler = ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, KO
evt_handler.null?.should be_false
- ECORE.event_handler_data_get(evt_handler).read_string.should eql "wrong"
- ECORE.event_handler_data_set evt_handler, FFI::MemoryPointer.from_string("666")
- ECORE.event_handler_data_get(evt_handler).read_string.should eql "666"
- ecore_evt = ECORE.event_add ECORE::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE_PTR
+ ECORE.event_handler_data_get(evt_handler).read_string.should eql "ko"
+ ECORE.event_handler_data_set(evt_handler, OK).address.should eql KO.address
+ ECORE.event_handler_data_get(evt_handler).read_string.should eql "ok"
+ ecore_evt = ECORE.event_add ECORE::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE
ecore_evt.null?.should be_false
ECORE.main_loop_begin # process event
ECORE.shutdown
@@ -72,16 +73,16 @@ describe E17::ECORE do
ECORE.init
loop_data = FFI::MemoryPointer.from_string("loop_data")
event_free_cb = Proc.new do |data,event|
- data.read_string.should eql "wrong"
+ data.read_string.should eql "ko"
event.read_int.should eql 69
end
start_cb = Proc.new do |data|
- data.read_string.should eql "yeah"
+ data.read_string.should eql "ok"
loop_data
end
count = 0
filter_cb = Proc.new do |data,loop_data,type,event|
- data.read_string.should eql "yeah"
+ data.read_string.should eql "ok"
loop_data.read_string.should eql "loop_data"
type.should eql ECORE::EVENT_SIGNAL_USER
count += 1
@@ -95,23 +96,20 @@ describe E17::ECORE do
end
end
end_cb = Proc.new do |data,loop_data|
- data.read_string.should eql "yeah"
+ data.read_string.should eql "ok"
loop_data.read_string.should eql "loop_data"
end
- m0 = FFI::MemoryPointer.from_string("yeah")
- filter = ECORE.ecore_event_filter_add start_cb, filter_cb, end_cb, m0
- ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, "666"
+ filter = ECORE.ecore_event_filter_add start_cb, filter_cb, end_cb, OK
+ ECORE.event_handler_add ECORE::EVENT_SIGNAL_USER, USER_SIGNAL_CB, OK
e1 = FFI::MemoryPointer.new(:int)
e1.write_int 69
- m1 = FFI::MemoryPointer.from_string("wrong")
- evt1 = ECORE.event_add ECORE::EVENT_SIGNAL_USER, e1, event_free_cb, m1
+ evt1 = ECORE.event_add ECORE::EVENT_SIGNAL_USER, e1, event_free_cb, KO
e2 = FFI::MemoryPointer.new(:int)
e2.write_int 666
- m2 = FFI::MemoryPointer.from_string("none")
- evt2 = ECORE.event_add ECORE::EVENT_SIGNAL_USER, e2, EVENT_FREE_CB, m2
+ evt2 = ECORE.event_add ECORE::EVENT_SIGNAL_USER, e2, EVENT_FREE_CB, NONE
ECORE.main_loop_begin # process event
- ECORE.ecore_event_filter_del filter
- evt2 = ECORE.event_add ECORE::EVENT_SIGNAL_USER, e2, EVENT_FREE_CB, m2
+ ECORE.ecore_event_filter_del(filter).address.should eql OK.address
+ evt2 = ECORE.event_add ECORE::EVENT_SIGNAL_USER, e2, EVENT_FREE_CB, NONE
ECORE.main_loop_begin # process event
ECORE.shutdown
end