From 8877205350bb7c70232c90e61ae30f83af05f5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 21 Apr 2011 22:46:39 +0200 Subject: add the new tests --- spec/ecore_spec.rb | 1 + test/test_elm_win.rb | 38 +++++++++++++++++++++++++++++++++++ test/test_elm_win_class.rb | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 test/test_elm_win.rb create mode 100644 test/test_elm_win_class.rb diff --git a/spec/ecore_spec.rb b/spec/ecore_spec.rb index 966f9ab..40586ec 100644 --- a/spec/ecore_spec.rb +++ b/spec/ecore_spec.rb @@ -147,4 +147,5 @@ describe Efl::Ecore do Ecore.main_loop_begin # process event Ecore.shutdown end + # end diff --git a/test/test_elm_win.rb b/test/test_elm_win.rb new file mode 100644 index 0000000..58c9462 --- /dev/null +++ b/test/test_elm_win.rb @@ -0,0 +1,38 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elementary' +# +include Efl +# +puts Elm.init + +win_del = Proc.new { |data,evas_object,event_info| + Efl::API.elm_exit(); +} + +win = Efl::API.elm_win_add FFI::MemoryPointer::NULL, "App name", :elm_win_basic +Efl::API.elm_win_title_set win, "Window title" +Efl::API.evas_object_smart_callback_add win, "delete,request", win_del, FFI::MemoryPointer::NULL + +bg = Efl::API.elm_bg_add win +Efl::API.evas_object_size_hint_weight_set bg, 1.0, 1.0 +Efl::API.elm_win_resize_object_add win, bg +Efl::API.evas_object_show bg + +lb = Efl::API.elm_label_add win +Efl::API.elm_label_label_set lb, "Hello World!" +Efl::API.evas_object_size_hint_weight_set lb, 1.0, 1.0 +Efl::API.elm_win_resize_object_add win, lb +Efl::API.evas_object_show lb + +Efl::API.evas_object_move win, 300, 300 +Efl::API.evas_object_resize win, 200, 100 + +Efl::API.evas_object_show win + +Elm.run +puts Elm.shutdown +# +# EOF + diff --git a/test/test_elm_win_class.rb b/test/test_elm_win_class.rb new file mode 100644 index 0000000..7934551 --- /dev/null +++ b/test/test_elm_win_class.rb @@ -0,0 +1,49 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elementary' +# +include Efl +# +DATA = FFI::MemoryPointer.from_string("my data") +# +class MyWin < Elm::ElmWin + def initialize name, title + super FFI::MemoryPointer::NULL, name + title_set title + feed + smart_callback_add "delete,request", method(:exit), DATA + end + def feed + # using block + @bg = add 'bg' do |bg| + bg.size_hint_weight_set 1.0, 1.0 + bg.show + end + resize_object_add @bg.ptr + @lb = add 'label'do |lb| + lb.elm_label_label_set "Hello World!" # complete function name + lb.size_hint_weight_set 1.0, 1.0 # implicit evas_object function name prefix + end + @lb.show + resize_object_add @lb.ptr + end + def exit data, evas_object, event_info + puts "EXIT #{data.read_string}" + Elm.exit + end +end +# +Elm.init +# +win = MyWin.new "App name", "Window Title" do |w,eo| + eo.move 300, 300 + eo.resize 200, 100 + eo.show +end +# +Elm.run +Elm.shutdown +# +# EOF + -- cgit v1.1-2-g2b99