From 601f74881e06a85e57d9799c57512f8b587b59fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 9 May 2011 14:01:57 +0200 Subject: cleanup specs --- spec/ecore_evas_spec.rb | 18 ++++++------------ spec/ecore_getopt_spec.rb | 28 +++++++++++++++++++++++----- spec/ecore_spec.rb | 4 ++-- spec/edje_spec.rb | 15 ++++++--------- spec/eet_spec.rb | 4 ++-- spec/eina_spec.rb | 18 ++++++++++++------ spec/evas_spec.rb | 22 ++++------------------ spec/helper.rb | 13 +++++++++++++ 8 files changed, 68 insertions(+), 54 deletions(-) diff --git a/spec/ecore_evas_spec.rb b/spec/ecore_evas_spec.rb index 3b4c934..5343498 100644 --- a/spec/ecore_evas_spec.rb +++ b/spec/ecore_evas_spec.rb @@ -9,10 +9,10 @@ describe Efl::EcoreEvas do # before(:all) do EcoreEvas = Efl::EcoreEvas - EcoreEvas.init + EcoreEvas.init.should==1 end after(:all) do - EcoreEvas.shutdown + EcoreEvas.shutdown.should==0 end # it "should init" do @@ -49,7 +49,7 @@ describe Efl::EcoreEvas do # describe Efl::EcoreEvas::REcoreEvas do before(:all) { - EcoreEvas.init + EcoreEvas.init.should == 2 } before(:each) do @e = EcoreEvas::REcoreEvas.new :engine_name=>"software_x11", :x=>10, :y=>10, :w=>100, :h=>120 @@ -67,7 +67,7 @@ describe Efl::EcoreEvas do @e.free end after(:all) do - EcoreEvas.shutdown + EcoreEvas.shutdown.should == 1 end # it "engine_name_get " do @@ -200,17 +200,11 @@ describe Efl::EcoreEvas do # FIXME maximized # ecore/src/lib/ecore_evas/ecore_evas.c => ecore_evas_maximized_set => IFC => return it "maximized set/get " do - @e.maximized?.should be_false - @e.maximized_set true - ecore_loop 10 - @e.maximized_get.should be_true - @e.maximized = false - ecore_loop 3 - @e.maximized?.should be_false + bool_check @e, 'maximized', 5 end # it "fullscreen set/get " do - bool_check @e, 'fullscreen', 3 + bool_check @e, 'fullscreen', 5 end # it "avoid_damage set/get " do diff --git a/spec/ecore_getopt_spec.rb b/spec/ecore_getopt_spec.rb index cdd04e3..9cd95dc 100644 --- a/spec/ecore_getopt_spec.rb +++ b/spec/ecore_getopt_spec.rb @@ -3,10 +3,14 @@ # require 'efl/ecore' require 'efl/ecore_evas' +require 'efl/eina_list' require 'efl/ecore_getopt' # describe Efl::EcoreGetopt do # + after(:all) do + Efl::Ecore.shutdown + end before(:all) do Efl::Ecore.init # @@ -33,6 +37,7 @@ describe Efl::EcoreGetopt do :true => FFI::MemoryPointer.new(:uchar), :false => FFI::MemoryPointer.new(:uchar), :choice => FFI::MemoryPointer.new(:pointer), + :append => FFI::MemoryPointer.new(:pointer), :count => FFI::MemoryPointer.new(:int), :callback => FFI::MemoryPointer.new(:int), } @@ -49,6 +54,7 @@ describe Efl::EcoreGetopt do @p.help 'H', 'help' @p.value :boolp, @values[:help] # FIXME debug callback : ecore_getopt_callback_ecore_evas_list_engines +# @p.callback_noargs 'E', 'list-engines', 'list ecore-evas available engines', @engines_cb, FFI::Pointer::NULL @p.callback_noargs 'E', 'list-engines', 'list ecore-evas available engines', Efl::Native.method(:ecore_getopt_callback_ecore_evas_list_engines), FFI::Pointer::NULL @p.value :boolp, @values[:engines] @p.store_type :int, 'i', 'int', 'store an integer' @@ -67,8 +73,8 @@ describe Efl::EcoreGetopt do @p.value :boolp, @values[:true] @p.choice 'm', 'many', 'store choice', ['ch1','ch2','ch3'] @p.value :strp, @values[:choice] -# # FIXME: uses listp with Eina_List -# @p.append 'a', 'append', 'store append', :ecore_getopt_type_int + @p.append 'a', 'append', 'store append', :ecore_getopt_type_int + @p.value :listp, @values[:append] @p.count 'k', 'count', 'store count' @p.value :intp, @values[:count] @p.callback_args 'b', 'callback', 'callback full', @meta1, @callback, @cb_data @@ -89,12 +95,10 @@ describe Efl::EcoreGetopt do @values[:true].write_uchar 1 @values[:false].write_uchar 0 @values[:choice].write_pointer FFI::Pointer::NULL + @values[:append].write_pointer FFI::Pointer::NULL @values[:count].write_int 664 @values[:callback].write_int 99 end - after(:all) do - Efl::Ecore.shutdown - end # describe "license copyright version help" do it "should handle -L" do @@ -179,6 +183,13 @@ describe Efl::EcoreGetopt do args = @p.parse ["progname","-mch2"] @values[:choice].read_pointer.read_string.should == "ch2" end + it "should handle -a" do + @values[:append].read_pointer.should == FFI::Pointer::NULL + args = @p.parse ["progname","-a10", "-a20"] + l = Efl::EinaList::REinaList.new(@values[:append].read_pointer).to_a + l[0].read_int.should==10 + l[1].read_int.should==20 + end it "should handle -k" do @values[:count].read_int.should == 664 args = @p.parse ["progname","-kk"] @@ -229,6 +240,13 @@ describe Efl::EcoreGetopt do args = @p.parse ["progname","--many=ch3"] @values[:choice].read_pointer.read_string.should == "ch3" end + it "should handle -append" do + @values[:append].read_pointer.should == FFI::Pointer::NULL + args = @p.parse ["progname","--append=10", "--append=20"] + l = Efl::EinaList::REinaList.new(@values[:append].read_pointer).to_a + l[0].read_int.should==10 + l[1].read_int.should==20 + end it "should handle --count" do @values[:count].read_int.should == 664 args = @p.parse ["progname","--count","--count"] diff --git a/spec/ecore_spec.rb b/spec/ecore_spec.rb index 4a1b077..0ab3d6c 100644 --- a/spec/ecore_spec.rb +++ b/spec/ecore_spec.rb @@ -24,10 +24,10 @@ describe Efl::Ecore do NONE = FFI::MemoryPointer.from_string "none" end before(:each) { - Ecore.init + Ecore.init==1 } after(:each) { - Ecore.shutdown + Ecore.shutdown==0 } # it "should init" do diff --git a/spec/edje_spec.rb b/spec/edje_spec.rb index 483ab95..90a1660 100644 --- a/spec/edje_spec.rb +++ b/spec/edje_spec.rb @@ -23,13 +23,12 @@ require './spec/helper' # describe Efl::Edje do # - before(:all) { Edje = Efl::Edje } - # - before(:each) { - Edje.init + before(:all) { + Edje = Efl::Edje + Edje.init.should == 1 } - after(:each) { - Edje.shutdown + after(:all) { + Edje.shutdown == 0 } # it "should init" do @@ -96,7 +95,6 @@ describe Efl::Edje do describe Efl::Edje::REdje do before(:all) do Efl::Evas.init - Efl::Edje.init realize_evas @ed = @e.edje_object_add @ed.file_set EDJE_FILE, "my_group" @@ -107,8 +105,7 @@ describe Efl::Edje do after(:all) do @e.free @pixels.free - Efl::Edje.shutdown - Efl::Evas.shutdown + Efl::Evas.shutdown.should==0 end # it "scale get/set " do diff --git a/spec/eet_spec.rb b/spec/eet_spec.rb index c499295..57b869a 100644 --- a/spec/eet_spec.rb +++ b/spec/eet_spec.rb @@ -39,8 +39,8 @@ describe Efl::Eet do end # describe Efl::Eet::REetFile do - before(:each) { Eet.init } - after(:each) { Eet.shutdown } + before(:all) { Eet.init.should==1 } + after(:all) { Eet.shutdown.should==0 } # it "should open and close" do f = REetFile.open FP, Native.enum_type(:eet_file_mode)[:eet_file_mode_write] diff --git a/spec/eina_spec.rb b/spec/eina_spec.rb index b16a0cb..39f2944 100644 --- a/spec/eina_spec.rb +++ b/spec/eina_spec.rb @@ -4,17 +4,23 @@ require 'efl/eina' # describe Efl::Eina do + before(:all) { + @i = Efl::Eina.init + } + after(:all) { + Efl::Eina.shutdown + } # it "should init" do - Efl::Eina.init.should == 1 - Efl::Eina.init.should == 2 - Efl::Eina.init.should == 3 + Efl::Eina.init.should == @i+1 + Efl::Eina.init.should == @i+2 + Efl::Eina.init.should == @i+3 end # it "should shutdown" do - Efl::Eina.shutdown.should == 2 - Efl::Eina.shutdown.should == 1 - Efl::Eina.shutdown.should == 0 + Efl::Eina.shutdown.should == @i+2 + Efl::Eina.shutdown.should == @i+1 + Efl::Eina.shutdown.should == @i+0 end # end diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb index f745298..4290053 100644 --- a/spec/evas_spec.rb +++ b/spec/evas_spec.rb @@ -11,10 +11,13 @@ describe Efl::Evas do before(:all) { Evas = Efl::Evas Native = Efl::Native unless Kernel.const_defined? 'Native' + Evas.init.should == 1 + } + after(:all) { + Evas.shutdown.should == 0 } # it "should init" do - Evas.init.should == 1 Evas.init.should == 2 Evas.init.should == 3 end @@ -22,7 +25,6 @@ describe Efl::Evas do it "should shutdown" do Evas.shutdown.should == 2 Evas.shutdown.should == 1 - Evas.shutdown.should == 0 end # it "evas alloc error enum is ok" do @@ -38,9 +40,7 @@ describe Efl::Evas do end # it "should have no memory allocation error occured" do - Evas.init Evas.alloc_error.should == :evas_alloc_error_none - Evas.shutdown end # it "should process async events" do @@ -49,24 +49,20 @@ describe Efl::Evas do type.should == :evas_callback_show evt.read_string.should == "work" end - Evas.init target = FFI::MemoryPointer.from_string("target") work = FFI::MemoryPointer.from_string("work") Evas.async_events_put target, :evas_callback_show, work, cb Evas.async_events_process.should == 1 Evas.async_events_process.should == 0 - Evas.shutdown end # describe Efl::Evas::REvas do before(:all) do - Evas.init realize_evas end after(:all) do @e.free @pixels.free - Evas.shutdown end # it "should be able to create and destroy evas" do @@ -299,7 +295,6 @@ describe Efl::Evas do describe Efl::Evas::REvasObject do # before(:all) do - Evas.init realize_evas @o = @e.object_rectangle_add { |o| o.color = 200,200,200,200 @@ -312,7 +307,6 @@ describe Efl::Evas do @e.free @o.free @pixels.free - Evas.shutdown end # it "clipper " do @@ -563,14 +557,12 @@ describe Efl::Evas do describe Efl::Evas::REvasLine do # before(:all) do - Evas.init realize_evas @l = @e.object_line_add end after(:all) do @l.free @e.free - Evas.shutdown end it "xy get/set " do @l.line_xy_set 10, 20, 30, 40 @@ -581,14 +573,12 @@ describe Efl::Evas do describe Efl::Evas::REvasPolygon do # before(:all) do - Evas.init realize_evas @p = @e.object_polygon_add end after(:all) do @p.free @e.free - Evas.shutdown end it "xy point_add " do @p.point_add 10, 20 @@ -605,14 +595,12 @@ describe Efl::Evas do describe Efl::Evas::REvasText do # before(:all) do - Evas.init realize_evas @t = @e.object_text_add end after(:all) do @t.free @e.free - Evas.shutdown end # it "font_source get/set " do @@ -715,7 +703,6 @@ describe Efl::Evas do describe Efl::Evas::REvasBox do # before(:all) do - Evas.init realize_evas @b = @e.object_box_add @os = [] @@ -726,7 +713,6 @@ describe Efl::Evas do after(:all) do @b.free @e.free - Evas.shutdown end # it "append, prepend, insert_before, insert_after, insert_at, remove, remove_at, remove_all and children_get " do diff --git a/spec/helper.rb b/spec/helper.rb index 6b9c849..efdc2b3 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -44,6 +44,19 @@ def bool_check t, fct, delay=nil t.send(fct+'_get').should be_false end # +def char_check t, fct, delay=nil + t.send fct+'_set', "char1" + ecore_loop delay if delay + t.send(fct).should == "char1" + t.send(fct+'?').should == "char1" + t.send(fct+'_get').should == "char1" + t.send fct+'=', "char2" + ecore_loop delay if delay + t.send(fct).should == "char2" + t.send(fct+'?').should == "char2" + t.send(fct+'_get').should == "char2" +end +# def realize_win @win = Elm::ElmWin.new(nil, 'TEST') do |w| w.title= 'spec win' -- cgit v1.1-2-g2b99