From 16b87714b4efa06de2f975e5d0bf20ea1427fb3a Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Mon, 18 Jan 2016 09:45:14 +0100 Subject: [PATCH] more tests and fix missing label abstract method in PushButton --- library/cwm/src/lib/cwm/widget.rb | 2 ++ library/cwm/test/widgets_test.rb | 50 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/library/cwm/src/lib/cwm/widget.rb b/library/cwm/src/lib/cwm/widget.rb index 5c4659a2e..c3f4488a5 100644 --- a/library/cwm/src/lib/cwm/widget.rb +++ b/library/cwm/src/lib/cwm/widget.rb @@ -603,6 +603,8 @@ def value=(val) # end class PushButton < AbstractWidget self.widget_type = :push_button + + abstract_method :label end # Widget representing menu button with its submenu diff --git a/library/cwm/test/widgets_test.rb b/library/cwm/test/widgets_test.rb index b5de47601..dbfcbe5f2 100755 --- a/library/cwm/test/widgets_test.rb +++ b/library/cwm/test/widgets_test.rb @@ -147,6 +147,56 @@ def initialize expect(TNotHandleEvents.new.cwm_definition).to_not be_key("handle_events") end end + + class TInit < CWM::AbstractWidget + self.widget_type = :empty + def init + end + end + + it "returns hash with key init when init method defined" do + expect(TInit.new.cwm_definition).to be_key("init") + end + + class THandle1 < CWM::AbstractWidget + self.widget_type = :empty + def handle + end + end + + it "returns hash with key handle when handle without parameter defined" do + expect(THandle1.new.cwm_definition).to be_key("handle") + end + + class THandle2 < CWM::AbstractWidget + self.widget_type = :empty + def handle(event) + end + end + + it "returns hash with key handle when handle with parameter defined" do + expect(THandle2.new.cwm_definition).to be_key("handle") + end + + class TStore < CWM::AbstractWidget + self.widget_type = :empty + def store + end + end + + it "returns hash with key store when store method defined" do + expect(TStore.new.cwm_definition).to be_key("store") + end + + class TCleanup < CWM::AbstractWidget + self.widget_type = :empty + def cleanup + end + end + + it "returns hash with key cleanup when cleanup method defined" do + expect(TCleanup.new.cwm_definition).to be_key("cleanup") + end end end