Class: Scoutui::Commands::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/scoutui/commands/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_cmd, _drv = nil) ⇒ Command

Returns a new instance of Command.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/scoutui/commands/command.rb', line 17

def initialize(_cmd, _drv=nil)
  Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + "  Command.init: #{_cmd.to_s}"

  @enableAssert=true
  @bm=nil
  @cmd=_cmd

  if _cmd.is_a?(Hash) && _cmd.has_key?('page') && _cmd['page'].has_key?('action')
    @stanza = _cmd
    @cmd=_cmd['page']['action']
  end

  @rc=nil
  @drv=_drv
  @locator=nil
  @executed=false
  @executed_result=nil
end

Instance Attribute Details

#bmObject

Returns the value of attribute bm.



14
15
16
# File 'lib/scoutui/commands/command.rb', line 14

def bm
  @bm
end

#cmdObject

Returns the value of attribute cmd.



8
9
10
# File 'lib/scoutui/commands/command.rb', line 8

def cmd
  @cmd
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/scoutui/commands/command.rb', line 6

def description
  @description
end

#drvObject

Returns the value of attribute drv.



7
8
9
# File 'lib/scoutui/commands/command.rb', line 7

def drv
  @drv
end

#enableAssertObject

Returns the value of attribute enableAssert.



15
16
17
# File 'lib/scoutui/commands/command.rb', line 15

def enableAssert
  @enableAssert
end

#executedObject

Returns the value of attribute executed.



11
12
13
# File 'lib/scoutui/commands/command.rb', line 11

def executed
  @executed
end

#executed_resultObject

Returns the value of attribute executed_result.



12
13
14
# File 'lib/scoutui/commands/command.rb', line 12

def executed_result
  @executed_result
end

#locatorObject

Returns the value of attribute locator.



10
11
12
# File 'lib/scoutui/commands/command.rb', line 10

def locator
  @locator
end

#rcObject

Returns the value of attribute rc.



9
10
11
# File 'lib/scoutui/commands/command.rb', line 9

def rc
  @rc
end

#stanzaObject

Returns the value of attribute stanza.



13
14
15
# File 'lib/scoutui/commands/command.rb', line 13

def stanza
  @stanza
end

Instance Method Details

#assert?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/scoutui/commands/command.rb', line 36

def assert?
  @enableAssert
end

#disableAssertObject



46
47
48
# File 'lib/scoutui/commands/command.rb', line 46

def disableAssert()
  disableAsserts
end

#disableAssertsObject



50
51
52
# File 'lib/scoutui/commands/command.rb', line 50

def disableAsserts()
  @enableAssert=false
end

#enableAssertsObject



43
44
45
# File 'lib/scoutui/commands/command.rb', line 43

def enableAsserts()
  @enableAssert=true
end

#execute(_drv = nil, _dut = nil) ⇒ Object

Raises:

  • (NotImplementedError)


99
100
101
# File 'lib/scoutui/commands/command.rb', line 99

def execute(_drv=nil, _dut=nil)
  raise NotImplementedError
end

#executedResultObject



60
61
62
# File 'lib/scoutui/commands/command.rb', line 60

def executedResult
  @executed_result
end

#getLocatorObject



72
73
74
# File 'lib/scoutui/commands/command.rb', line 72

def getLocator()
  @locator
end

#passed?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/scoutui/commands/command.rb', line 80

def passed?
  !@executed_result.nil? && @executed_result
end

#resultObject



84
85
86
# File 'lib/scoutui/commands/command.rb', line 84

def result
  @rc
end

#run(opts) ⇒ Object

(_drv=nil, _dut=nil)



88
89
90
91
92
93
94
95
96
97
# File 'lib/scoutui/commands/command.rb', line 88

def run(opts) # (_drv=nil, _dut=nil)
  _drv=opts[:driver]
  _dut=opts.has_key?(:dut) ? opts[:dut] : nil

  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " = start run(#{@cmd}) ="
  @bm=Benchmark.measure { execute(_drv, _dut) }
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " = end run(#{@cmd}) : #{@bm.real}"

  Scoutui::Logger::LogMgr.instance.benchmarks.info "#{@cmd} => #{@bm.real}"
end

#setBenchmark(b) ⇒ Object



76
77
78
# File 'lib/scoutui/commands/command.rb', line 76

def setBenchmark(b)
  @bm=b
end

#setLocator(_locator) ⇒ Object



68
69
70
# File 'lib/scoutui/commands/command.rb', line 68

def setLocator(_locator)
  @locator=_locator
end

#setResult(r) ⇒ Object



54
55
56
57
58
# File 'lib/scoutui/commands/command.rb', line 54

def setResult(r)
  Scoutui::Logger::LogMgr.instance.commands.debug " #{@cmd.to_s} : setResult(#{r.to_s})"
  @executed=true
  @executed_result=r
end

#wasExecuted?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/scoutui/commands/command.rb', line 64

def wasExecuted?
  @executed
end