diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-08-19 15:21:56 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-08-19 15:21:56 +0200 |
commit | 2d6acef504bc71cc0af588dbc3ed5bf56b349378 (patch) | |
tree | 5f80e60c92a0fb3d487d5d1601061bbfcca21736 | |
parent | 0112867934acf482154e8ac315e68ed3afbde5b7 (diff) | |
download | ffi-efl-2d6acef504bc71cc0af588dbc3ed5bf56b349378.zip ffi-efl-2d6acef504bc71cc0af588dbc3ed5bf56b349378.tar.gz |
test_elementary : implement plain, image and options bg tests
-rw-r--r-- | test/test_elementary.rb | 38 | ||||
-rw-r--r-- | test/tests/test_bg.rb | 151 |
2 files changed, 182 insertions, 7 deletions
diff --git a/test/test_elementary.rb b/test/test_elementary.rb index 5356294..ffe542c 100644 --- a/test/test_elementary.rb +++ b/test/test_elementary.rb @@ -2,8 +2,13 @@ # -*- coding: UTF-8 -*- # require 'efl/elementary' +require 'efl/edje' require 'efl' # +Dir.glob( File.join File.dirname(__FILE__), 'tests', '*.rb').each do |f| + load f +end +# include Efl; # TESTS = [ @@ -189,7 +194,6 @@ class TestWin < Elm::ElmWin li.size_hint_weight_expand li.size_hint_align_set_fill @bx0.pack_end li - li.show end @idx = Elm::ElmIndex.new self do |idx| idx.smart_callback_add 'delay,changed', method(:index_changed) @@ -198,8 +202,16 @@ class TestWin < Elm::ElmWin idx.show end ch = nil - TESTS.each do |l,m| - it = @li.item_append l, nil, nil, method(:fake) + TESTS.sort.each do |l,m| + icon = nil + if Tests.respond_to? m + # TODO dosen't work ????? + icon = Elm::ElmIcon.new self + icon.file = "#{Efl::PACKAGE_DATA_DIR}/elementary/images/icon_00.png", nil + icon.scale = true, true + end + it = @li.item_append l, nil, icon, method(:try_test), FFI::MemoryPointer.from_string(m.to_s) + it.del_cb_set method(:free_list_item) if l[0]!=ch ch = l[0] @idx.item_append ch.to_s, it @@ -207,10 +219,16 @@ class TestWin < Elm::ElmWin end @idx.item_go 0 @li.go + @li.show end # - def fake data, evas_obj, event_info - puts 'FAKE' + def try_test data, evas_obj, event_info + fct = data.read_string + begin + Tests.send fct + rescue NoMethodError + puts "#{fct} not implemeneted yet" + end end # def tg_changed data, evas_obj, event_info @@ -221,6 +239,11 @@ class TestWin < Elm::ElmWin Native.elm_list_item_show event_info end # + def free_list_item data, evas_obj, event_info + # free FFI::MemoryPointer.from_string m.to_s + data.free + end + # def on_delete data, evas_object, event_info Elm.exit end @@ -234,9 +257,10 @@ end # Elm.init # +#Native.elm_app_compile_bin_dir_set PACKAGE_BIN_DIR +#Native.elm_app_compile_lib_dir_set PACKAGE_LIB_DIR +#Native.elm_app_compile_data_dir_set PACKAGE_DATA_DIR Native.elm_app_info_set elm_main, 'elementary', 'images/logo.png' -Native.elm_app_compile_bin_dir_set PACKAGE_BIN_DIR -Native.elm_app_compile_data_dir_set PACKAGE_DATA_DIR # Elm.run Elm.shutdown diff --git a/test/tests/test_bg.rb b/test/tests/test_bg.rb new file mode 100644 index 0000000..7f613eb --- /dev/null +++ b/test/tests/test_bg.rb @@ -0,0 +1,151 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +module Tests + # + class TestBg < Efl::Elm::ElmWin + def initialize name, title, fct + super nil, name + self.title = title + self.autodel = true + self.send fct + @bg.size_hint_min = 160, 160 + @bg.size_hint_max = 640, 640 + self.resize 320, 230 + self.show + end + def plain_bg + @bg = Elm::ElmBg.new self do |bg| + bg.size_hint_weight_expand + self.resize_object_add bg + bg.show + end + end + def image_bg + @bg = Elm::ElmBg.new self do |bg| + bg.file = "#{Efl::PACKAGE_DATA_DIR}/elementary/images/plant_01.jpg", nil + bg.size_hint_weight_expand + self.resize_object_add bg + bg.show + end + end + def options_bg + plain_bg + @bx = Elm::ElmBox.new self do |bx| + bx.size_hint_weight_expand + self.resize_object_add bx + bx.show + end + @o_bg = Elm::ElmBg.new self do |bg| + bg.file = "#{Efl::PACKAGE_DATA_DIR}/elementary/images/plant_01.jpg", nil + bg.size_hint_weight_expand + bg.size_hint_align_fill + @bx.pack_end bg + bg.show + end + @hbx = Elm::ElmBox.new self do |bx| + bx.horizontal = true + bx.size_hint_weight_expand_fill + bx.size_hint_align_fill + end + @rdg = Elm::ElmRadio.new self do |r| + r.state_value = :elm_bg_option_center + r.text = "Center" + r.size_hint_weight_expand_fill + r.smart_callback_add "changed", method(:cb_radio_changed) + @hbx.pack_end r + r.show + end + Elm::ElmRadio.new self do |r| + r.state_value = :elm_bg_option_scale + r.group_add @rdg + r.text = "Scale" + r.size_hint_weight_expand_fill + r.smart_callback_add "changed", method(:cb_radio_changed) + @hbx.pack_end r + r.show + end + Elm::ElmRadio.new self do |r| + r.state_value = :elm_bg_option_stretch + r.group_add @rdg + r.text = "Stretch" + r.size_hint_weight_expand_fill + r.smart_callback_add "changed", method(:cb_radio_changed) + @hbx.pack_end r + r.show + end + Elm::ElmRadio.new self do |r| + r.state_value = :elm_bg_option_tile + r.group_add @rdg + r.text = "Tile" + r.size_hint_weight_expand_fill + r.smart_callback_add "changed", method(:cb_radio_changed) + @hbx.pack_end r + r.show + end + @rdg.value_set :elm_bg_option_scale + Elm::ElmCheck.new self do |ck| + ck.text = "Show Overlay" + ck.size_hint_weight_expand_fill + ck.smart_callback_add "changed", method(:cb_overlay_changed) + @hbx.pack_end ck + ck.show + end + Elm::ElmSpinner.new self do |sp| + sp.style = "vertical" + sp.min_max = 1, 4 + sp.label_format = "%.0f" + sp.editable = false + sp.special_value_add 1, "White" + sp.special_value_add 2, "Red" + sp.special_value_add 3, "Blue" + sp.special_value_add 4, "Green" + sp.size_hint_weight_expand + sp.size_hint_align_fill + sp.smart_callback_add "changed", method(:cb_color_changed) + @hbx.pack_end sp + sp.show + end + @bx.pack_end @hbx + @hbx.show + end + def cb_radio_changed data, evas_obj, event_info + @o_bg.option = Elm::ElmRadio.new(evas_obj).value + end + def cb_overlay_changed data, evas_obj, event_info + if Elm::ElmCheck.new(evas_obj).state + over = @o_bg.parent_widget.evas.edje_object_add + over.file = File.join(Efl::PACKAGE_DATA_DIR,'elementary/objects/test.edj'), "bg_overlay" + @o_bg.overlay = over + else + @o_bg.overlay = FFI::Pointer::NULL + end + end + def cb_color_changed data, evas_obj, event_info + case Elm::ElmSpinner.new(evas_obj).value + when 1.0 + @o_bg.color = 255, 255, 255 + when 2.0 + @o_bg.color = 255, 0, 0 + when 3.0 + @o_bg.color = 0, 0, 255 + when 4.0 + @o_bg.color = 0, 255, 0 + end + end + end + # + def self.test_bg_plain + TestBg.new 'bg-plain', 'Bg Plain', :plain_bg + end + # + def self.test_bg_image + TestBg.new 'bg-image', 'Bg Image', :image_bg + end + def self.test_bg_options + TestBg.new 'bg-options', 'Bg Options', :options_bg + end +# +end +# +# EOF |