# Author:: Nicolas Pouillard . # Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved. # License:: LGPL # $Id: /fey/uttk/trunk/lib/uttk/status.rb 8800 2005-10-09T11:12:27.126567Z ertai $ module Uttk class Status < UttkException include Abstract def self.default_weight ( aSymbol ) self.default_weight_value = Weights::Default.new(aSymbol) end def self.status_name name.sub(/^.*?(\w+)Status$/, '\1').upcase.to_sym end def self.hook_name (status_name.to_s.downcase + '_hook').to_sym end attr_accessor :weight, :reason class_inheritable_accessor :default_weight_value class_inheritable_accessor :default_reason self.default_reason = nil default_weight :FAIL def initialize ( anObject=nil ) super() @reason = anObject || default_reason @weight = default_weight_value end def to_uttk_log ( log ) log.status = self.to_s log.reason = @reason unless @reason.nil? end def hook_name self.class.hook_name end def to_s res = self.class.status_name.to_s if @weight != default_weight_value res += "(#{@weight.get})" end res end def pass? false end end # class Status class PassStatus < Status include Concrete default_weight :PASS def pass? true end end class SkipStatus < Status include Concrete def initialize ( aWeight=nil, anObject=nil ) super(anObject) @weight = aWeight unless aWeight.nil? end end class ErrorStatus < Status include Concrete end class AbortStatus < Status include Concrete end # class AbortStatus class TimeoutAbortStatus < AbortStatus attr_reader :timeout_id @@timeout_id ||= -1 def initialize ( *a, &b ) @timeout_id = (@@timeout_id += 1) super end def == ( rhs ) rhs.class <= self.class and @timeout_id == rhs.timeout_id end def self.status_name :ABORT end end # class TimeoutAbortStatus class StartStatus < Status include Concrete default_weight :START end class RunningStatus < Status include Concrete default_weight :FAIL end class FailStatus < Status include Concrete def initialize ( aWeight=nil, anObject=nil ) super(anObject) @weight = aWeight unless aWeight.nil? end def hook_name :failed_hook end end # class FailStatus end # module Uttk