testability-driver 0.9.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +1 -1
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +11 -7
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +8 -0
- data/lib/tdriver/base/behaviour/factory.rb +229 -209
- data/lib/tdriver/base/errors.rb +3 -0
- data/lib/tdriver/base/state_object.rb +11 -20
- data/lib/tdriver/base/sut/controller.rb +4 -4
- data/lib/tdriver/base/sut/factory.rb +205 -170
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +256 -174
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +17 -11
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +57 -66
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +578 -497
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +41 -15
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +48 -19
- data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +25 -13
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +16 -10
- data/lib/tdriver/base/sut/generic/plugin.rb +9 -3
- data/lib/tdriver/base/sut/sut.rb +41 -33
- data/lib/tdriver/base/test_object/abstract.rb +26 -3
- data/lib/tdriver/base/test_object/adapter.rb +399 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +56 -14
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +663 -197
- data/lib/tdriver/base/test_object/cache.rb +132 -0
- data/lib/tdriver/base/test_object/factory.rb +677 -426
- data/lib/tdriver/base/test_object/factory_new.rb +202 -0
- data/lib/tdriver/base/test_object/identificator.rb +24 -17
- data/lib/tdriver/base/test_object/loader.rb +9 -3
- data/lib/tdriver/base/test_object/verification.rb +181 -0
- data/lib/tdriver/loader.rb +1 -1
- data/lib/tdriver/report/report.rb +2 -0
- data/lib/tdriver/report/report_api.rb +4 -4
- data/lib/tdriver/report/report_creator.rb +29 -3
- data/lib/tdriver/report/report_data_presentation.rb +7 -3
- data/lib/tdriver/report/report_execution_statistics.rb +80 -21
- data/lib/tdriver/report/report_javascript.rb +192 -0
- data/lib/tdriver/report/report_test_case_run.rb +22 -0
- data/lib/tdriver/report/report_test_run.rb +62 -55
- data/lib/tdriver/report/report_writer.rb +57 -56
- data/lib/tdriver/tdriver.rb +14 -41
- data/lib/tdriver/util/common/error.rb +1 -0
- data/lib/tdriver/util/common/exceptions.rb +12 -0
- data/lib/tdriver/util/common/file.rb +12 -6
- data/lib/tdriver/util/common/gem.rb +2 -1
- data/lib/tdriver/util/common/hash.rb +152 -0
- data/lib/tdriver/util/common/kernel.rb +49 -34
- data/lib/tdriver/util/common/loader.rb +21 -17
- data/lib/tdriver/util/common/numeric.rb +39 -0
- data/lib/tdriver/util/common/object.rb +115 -0
- data/lib/tdriver/util/common/string.rb +55 -2
- data/lib/tdriver/util/dbaccess/dbaccess.rb +194 -161
- data/lib/tdriver/util/dynamic_attribute_filter.rb +6 -0
- data/lib/tdriver/util/hooking.rb +2 -2
- data/lib/tdriver/util/loader.rb +2 -2
- data/lib/tdriver/util/localisation/localisation.rb +277 -18
- data/lib/tdriver/util/logger.rb +142 -13
- data/lib/tdriver/util/parameter/parameter_hash.rb +8 -5
- data/lib/tdriver/util/parameter/parameter_xml.rb +18 -2
- data/lib/tdriver/util/recorder.rb +17 -12
- data/lib/tdriver/util/user_data/user_data.rb +3 -2
- data/lib/tdriver/util/{video_rec.rb → video_utils.rb} +136 -16
- data/lib/tdriver/util/xml/abstraction.rb +7 -0
- data/lib/tdriver/util/xml/attribute.rb +32 -0
- data/lib/tdriver/util/xml/loader.rb +8 -2
- data/lib/tdriver/util/xml/nil_node.rb +95 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +46 -7
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +19 -9
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +1 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +13 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +6 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +27 -15
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +57 -0
- data/lib/tdriver/util/xml/text.rb +32 -0
- data/lib/tdriver/util/xml/xml.rb +35 -22
- data/lib/tdriver/version.rb +1 -1
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +41 -34
- data/lib/tdriver-devtools/doc/generate.rb +31 -6
- data/lib/tdriver-devtools/doc/xslt/template.xsl +46 -25
- data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +1 -1
- data/lib/tdriver.rb +0 -3
- data/xml/behaviours/generic.xml +1 -1
- data/xml/defaults/generic.xml +4 -90
- data/xml/templates/generic.xml +33 -25
- metadata +21 -29
- data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +0 -245
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +0 -964
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +0 -68
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +0 -1865
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +0 -12
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +0 -5
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +0 -2
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +0 -7
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +0 -14
- data/lib/tdriver-devtools/behaviour/xml_generator/update +0 -3
- data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +0 -233
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +0 -194
data/lib/tdriver/base/errors.rb
CHANGED
@@ -64,15 +64,18 @@ module MobyBase
|
|
64
64
|
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
add_parent( parent ) unless parent.nil?
|
67
|
+
#@parent = nil
|
68
|
+
#add_parent( parent ) unless parent.nil?
|
69
|
+
#@parent = parent unless parent.nil?
|
70
|
+
|
71
|
+
@parent = parent
|
69
72
|
|
70
73
|
self.xml_data= xml_element
|
71
74
|
|
72
|
-
|
75
|
+
@child_object_cache = TDriver::TestObjectCache.new
|
73
76
|
|
74
77
|
# Create accessor methods for any child state objects.
|
75
|
-
|
78
|
+
TDriver::TestObjectAdapter.create_child_accessors!( xml_element, self )
|
76
79
|
|
77
80
|
end
|
78
81
|
|
@@ -81,18 +84,8 @@ module MobyBase
|
|
81
84
|
|
82
85
|
hash_rule = method_arguments.first
|
83
86
|
|
84
|
-
# method mapping/aliases
|
85
|
-
case method_id
|
86
|
-
|
87
|
-
when :Button;
|
88
|
-
method_id = [ :Button, :QToolButton, :DuiButton, :HbPushButton, :softkey ]
|
89
|
-
|
90
|
-
when :List;
|
91
|
-
method_id = [ :QList, :HbListWidgetView, :DuiList ]
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
87
|
hash_rule = Hash.new unless hash_rule.kind_of? Hash
|
88
|
+
|
96
89
|
hash_rule[ :type ] = method_id
|
97
90
|
|
98
91
|
begin
|
@@ -211,11 +204,9 @@ module MobyBase
|
|
211
204
|
|
212
205
|
def get_cached_test_object!( object )
|
213
206
|
|
214
|
-
|
215
|
-
|
216
|
-
if @_child_object_cache.has_key?( object_hash )
|
207
|
+
if @child_object_cache.has_object?( object )
|
217
208
|
|
218
|
-
object = @
|
209
|
+
object = @child_object_cache[ object ]
|
219
210
|
|
220
211
|
true
|
221
212
|
|
@@ -247,7 +238,7 @@ module MobyBase
|
|
247
238
|
get_cached_test_object!( child_object ).tap{ | found_in_cache |
|
248
239
|
|
249
240
|
# add child to objects cache
|
250
|
-
|
241
|
+
@child_object_cache.add_object( child_object ) unless found_in_cache
|
251
242
|
|
252
243
|
}
|
253
244
|
|
@@ -17,7 +17,6 @@
|
|
17
17
|
##
|
18
18
|
############################################################################
|
19
19
|
|
20
|
-
|
21
20
|
module MobyBase
|
22
21
|
|
23
22
|
class SutController
|
@@ -28,10 +27,11 @@ module MobyBase
|
|
28
27
|
# == params
|
29
28
|
# sut_adapter:: MobyController::SutAdapter descendant, e.g. MobyController::QT::SutAdapter
|
30
29
|
# == raises
|
30
|
+
# TypeError:: Wrong argument type $1 for SUT controller (expected $2)
|
31
31
|
# NameError:: No SUT controller found for %s (%s)
|
32
32
|
def initialize( sut_controllers, sut_adapter )
|
33
33
|
|
34
|
-
|
34
|
+
sut_controllers.check_type( String, "Wrong argument type $1 for SUT controller (expected $2)" )
|
35
35
|
|
36
36
|
@sut_adapter = sut_adapter
|
37
37
|
|
@@ -81,11 +81,11 @@ module MobyBase
|
|
81
81
|
# == returns
|
82
82
|
# command_data implementation specific return value
|
83
83
|
# == raises
|
84
|
-
#
|
84
|
+
# TypeError:: Wrong argument type $1 for command_data (expected $2)
|
85
85
|
# MobyBase::CommandNotFoundError:: if no implementation is found for the CommandData object
|
86
86
|
def execute_command( command_data )
|
87
87
|
|
88
|
-
|
88
|
+
command_data.check_type( MobyCommand::CommandData, "Wrong argument type $1 for command_data (expected $2)" )
|
89
89
|
|
90
90
|
@execution_order.each{ | controller |
|
91
91
|
|
@@ -17,271 +17,306 @@
|
|
17
17
|
##
|
18
18
|
############################################################################
|
19
19
|
|
20
|
-
|
21
20
|
module MobyBase
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
# Class to create SUT objects
|
23
|
+
# Hides actual SUT object from the clients -> clients should be able to use the instantiated SUT object as if it was any SUT
|
24
|
+
class SUTFactory
|
26
25
|
|
27
|
-
|
26
|
+
include Singleton
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
# Initialize the singleton
|
29
|
+
def initialize()
|
31
30
|
|
32
|
-
|
31
|
+
reset
|
33
32
|
|
34
|
-
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
# Create/reset hash to store sut ids for all current suts
|
36
|
+
def reset
|
38
37
|
|
39
|
-
|
38
|
+
@_sut_list = {}
|
40
39
|
|
41
|
-
|
40
|
+
end
|
42
41
|
|
43
|
-
|
42
|
+
def mapped_sut?( sut_id )
|
44
43
|
|
45
|
-
|
46
|
-
end
|
44
|
+
MobyUtil::Parameter[ :mappings, {} ].has_key?( sut_id.to_sym )
|
47
45
|
|
46
|
+
end
|
48
47
|
|
49
|
-
def get_mapped_sut( sut_id )
|
50
48
|
|
51
|
-
|
49
|
+
def get_mapped_sut( sut_id )
|
52
50
|
|
53
|
-
|
51
|
+
MobyUtil::Parameter[ :mappings ][ sut_id.to_sym ].to_sym
|
54
52
|
|
55
|
-
|
56
|
-
# === params
|
57
|
-
# sut_type:: sut_type - sut type, supportes all types defined by SUTFactory constants
|
58
|
-
# id:: id - unique identifier for identifying particular SUT from each other. Is propagated to proper initializers.
|
59
|
-
# === returns
|
60
|
-
# return:: SUT object
|
61
|
-
# raise::
|
62
|
-
# ArgumentError:: SUT ID '%s' not found from tdriver_parameters.xml
|
63
|
-
def make( sut_id )
|
53
|
+
end
|
64
54
|
|
65
|
-
|
66
|
-
|
55
|
+
# Function to create the actual SUT objects based on the 'sut' attribute.
|
56
|
+
# === params
|
57
|
+
# sut_type:: sut_type - sut type, supportes all types defined by SUTFactory constants
|
58
|
+
# id:: id - unique identifier for identifying particular SUT from each other. Is propagated to proper initializers.
|
59
|
+
# === returns
|
60
|
+
# return:: SUT object
|
61
|
+
# raise::
|
62
|
+
# ArgumentError:: SUT ID '%s' not found from tdriver_parameters.xml
|
63
|
+
def make( sut_attributes )
|
67
64
|
|
68
|
-
|
65
|
+
sut_id = retrieve_sut_id_from_hash( sut_attributes )
|
69
66
|
|
70
|
-
|
71
|
-
return get_sut_from_list( sut_id ) if sut_exists?( sut_id )
|
67
|
+
sut_id = get_mapped_sut( sut_id ) if mapped_sut?( sut_id )
|
72
68
|
|
73
|
-
|
69
|
+
# if sut is already connected, return existing sut
|
70
|
+
return get_sut_from_list( sut_id ) if sut_exists?( sut_id )
|
74
71
|
|
75
|
-
# check if the sut or an alias exists in tdriver_parameters.xml
|
76
|
-
#mapped_id = find_sut_or_mapping( sut_id )
|
77
72
|
|
78
|
-
|
79
|
-
|
73
|
+
# retrieve sut from parameters
|
74
|
+
sut = MobyUtil::Parameter[ sut_id, nil ]
|
80
75
|
|
81
|
-
|
76
|
+
# raise exception if sut was not found
|
77
|
+
Kernel::raise ArgumentError.new( "%s not defined in TDriver parameters XML" % [ sut_id ]) if sut.nil?
|
78
|
+
|
79
|
+
# retrieve sut type from parameters
|
80
|
+
sut_type = sut[ :type, nil ]
|
81
|
+
|
82
|
+
# raise exception if sut type was not found
|
83
|
+
Kernel::raise RuntimeError.new( "SUT parameter 'type' not defined for %s in TDriver parameters/templates XML" % [ sut_id ] ) if sut_type.nil?
|
82
84
|
|
83
|
-
|
84
|
-
Kernel::raise RuntimeError.new( "SUT type not defined for #{ sut_id } in TDriver parameters/templates XML" ) if ( sut_type = MobyUtil::Parameter[ sut_id ][ :type, nil ] ).nil?
|
85
|
+
sut_type_symbol = sut_type.downcase.to_sym
|
85
86
|
|
86
|
-
|
87
|
+
# retrieve plugin name that implements given sut
|
88
|
+
sut_plugin = sut[ :sut_plugin, nil ]
|
87
89
|
|
88
|
-
|
89
|
-
sut_plugin = MobyUtil::Parameter[ sut_id ][ :sut_plugin, nil ]
|
90
|
+
sut_env = sut[ :env, '*' ]
|
90
91
|
|
91
|
-
|
92
|
-
|
92
|
+
# verify that sut plugin is defined in sut configuration
|
93
|
+
Kernel::raise RuntimeError.new( "SUT parameter 'sut_plugin' not defined for %s (%s)" % [ sut_id, sut_type ] ) if sut_plugin.nil?
|
94
|
+
|
95
|
+
# flag to determine that should exception be raised; allow one retry, then set flag to true if error still occures
|
96
|
+
raise_exception = false
|
93
97
|
|
94
|
-
|
95
|
-
raise_exception = false
|
98
|
+
begin
|
96
99
|
|
97
|
-
|
100
|
+
# verify that sut plugin is registered
|
101
|
+
if MobyUtil::PluginService.instance.plugin_registered?( sut_plugin, :sut )
|
102
|
+
|
103
|
+
# create sut object
|
104
|
+
created_sut = MobyUtil::PluginService.instance.call_plugin_method( sut_plugin, :make_sut, sut_id )
|
98
105
|
|
99
|
-
|
100
|
-
if MobyUtil::PluginService.instance.plugin_registered?( sut_plugin, :sut )
|
101
|
-
|
102
|
-
# create sut object
|
103
|
-
created_sut = MobyUtil::PluginService.instance.call_plugin_method( sut_plugin, :make_sut, sut_id )
|
106
|
+
else
|
104
107
|
|
105
|
-
|
108
|
+
# raise error if sut was not registered
|
109
|
+
Kernel::raise NotImplementedError.new( "No plugin implementation found for SUT type: %s" % [ sut_type ] )
|
106
110
|
|
107
|
-
|
108
|
-
Kernel::raise NotImplementedError.new( "No plugin/implementation for SUT type: %s" % [ sut_type ] )
|
111
|
+
end
|
109
112
|
|
110
|
-
|
113
|
+
rescue Exception => exception
|
111
114
|
|
112
|
-
|
115
|
+
# if sut was not registered, try to load it
|
116
|
+
MobyUtil::PluginService.instance.load_plugin( sut_plugin ) if exception.kind_of?( NotImplementedError )
|
113
117
|
|
114
|
-
|
115
|
-
MobyUtil::PluginService.instance.load_plugin( sut_plugin ) if exception.kind_of?( NotImplementedError )
|
118
|
+
if !raise_exception
|
116
119
|
|
117
|
-
|
120
|
+
raise_exception = true
|
121
|
+
retry
|
122
|
+
|
123
|
+
else
|
118
124
|
|
119
|
-
|
120
|
-
|
121
|
-
else
|
125
|
+
# still errors, raise original exception
|
126
|
+
Kernel::raise exception
|
122
127
|
|
123
|
-
|
124
|
-
Kernel::raise exception
|
128
|
+
end
|
125
129
|
|
126
|
-
|
130
|
+
end
|
127
131
|
|
128
|
-
|
132
|
+
# sut type version, default: nil
|
133
|
+
created_sut.instance_eval {
|
134
|
+
@ui_type = sut_type;
|
135
|
+
@ui_version = MobyUtil::Parameter[ sut_id ][ :version, nil ];
|
136
|
+
@input = MobyUtil::Parameter[ sut_id ][ :input_type, nil ];
|
137
|
+
}
|
138
|
+
|
139
|
+
# add behaviours to sut
|
140
|
+
created_sut.extend( MobyBehaviour::ObjectBehaviourComposition )
|
129
141
|
|
130
|
-
|
131
|
-
|
132
|
-
@ui_type = sut_type;
|
133
|
-
@ui_version = MobyUtil::Parameter[ sut_id ][ :version, nil ];
|
134
|
-
@input = MobyUtil::Parameter[ sut_id ][ :input_type, nil ];
|
135
|
-
}
|
136
|
-
|
137
|
-
# add behaviours to sut
|
138
|
-
created_sut.extend( MobyBehaviour::ObjectBehaviourComposition )
|
142
|
+
# retrieve list of optional extension plugins
|
143
|
+
@extension_plugins = MobyUtil::Parameter[ sut_id ][ :extension_plugins, "" ].split( ";" )
|
139
144
|
|
140
|
-
|
141
|
-
|
145
|
+
# load optional extension plugins
|
146
|
+
if @extension_plugins.count > 0
|
142
147
|
|
143
|
-
|
144
|
-
if @extension_plugins.count > 0
|
148
|
+
@extension_plugins.each{ | plugin_name |
|
145
149
|
|
146
|
-
|
150
|
+
raise_exception = false
|
147
151
|
|
148
|
-
|
152
|
+
begin
|
149
153
|
|
150
|
-
|
154
|
+
# verify that extension plugin is registered
|
155
|
+
unless MobyUtil::PluginService.instance.plugin_registered?( plugin_name, :extension )
|
151
156
|
|
152
|
-
|
153
|
-
|
157
|
+
# raise error if sut was not registered
|
158
|
+
Kernel::raise NotImplementedError.new( "Extension plugin not found %s" % [ plugin_name ] )
|
154
159
|
|
155
|
-
|
156
|
-
Kernel::raise NotImplementedError.new( "Extension plugin not found %s" % [ plugin_name ] )
|
160
|
+
end
|
157
161
|
|
158
|
-
|
162
|
+
rescue Exception => exception
|
159
163
|
|
160
|
-
|
164
|
+
# if sut was not registered, try to load it
|
165
|
+
MobyUtil::PluginService.instance.load_plugin( plugin_name ) if exception.kind_of?( NotImplementedError )
|
161
166
|
|
162
|
-
|
163
|
-
MobyUtil::PluginService.instance.load_plugin( plugin_name ) if exception.kind_of?( NotImplementedError )
|
167
|
+
if !raise_exception
|
164
168
|
|
165
|
-
|
169
|
+
raise_exception = true
|
170
|
+
retry
|
171
|
+
else
|
166
172
|
|
167
|
-
|
168
|
-
|
169
|
-
else
|
173
|
+
# still errors, raise original exception
|
174
|
+
Kernel::raise exception
|
170
175
|
|
171
|
-
|
172
|
-
Kernel::raise exception
|
176
|
+
end
|
173
177
|
|
174
|
-
|
178
|
+
end
|
175
179
|
|
176
|
-
|
180
|
+
}
|
177
181
|
|
178
|
-
|
182
|
+
end
|
179
183
|
|
180
|
-
|
184
|
+
# apply sut generic behaviours
|
185
|
+
created_sut.apply_behaviour!(
|
186
|
+
:object_type => [ 'sut' ],
|
187
|
+
# :sut_type => [ '*', sut_type.upcase ],
|
188
|
+
# :sut_type => [ '*', sut_type ],
|
189
|
+
:input_type => [ '*', created_sut.input.to_s ],
|
190
|
+
:env => [ '*', *sut_env.to_s.split(";") ],
|
191
|
+
:version => [ '*', created_sut.ui_version.to_s ]
|
192
|
+
)
|
181
193
|
|
182
|
-
|
183
|
-
created_sut.apply_behaviour!(
|
184
|
-
:object_type => [ 'sut' ],
|
185
|
-
:sut_type => [ '*', sut_type.upcase ],
|
186
|
-
:input_type => [ '*', created_sut.input.to_s ],
|
187
|
-
:version => [ '*', created_sut.ui_version.to_s ]
|
188
|
-
)
|
194
|
+
@_sut_list[ sut_id ] = { :sut => created_sut, :is_connected => true }
|
189
195
|
|
190
|
-
|
196
|
+
created_sut
|
191
197
|
|
192
|
-
|
198
|
+
end
|
193
199
|
|
194
|
-
|
200
|
+
def disconnect_sut( sut_attributes )
|
195
201
|
|
196
|
-
|
202
|
+
sut_id = retrieve_sut_id_from_hash( sut_attributes )
|
197
203
|
|
198
|
-
|
199
|
-
|
200
|
-
|
204
|
+
Kernel::raise RuntimeError.new(
|
205
|
+
|
206
|
+
"Unable disconnect SUT due to %s is not connected" % [ sut_id ]
|
207
|
+
|
208
|
+
) unless sut_exists?( sut_id ) && @_sut_list[ sut_id ][ :is_connected ]
|
209
|
+
|
210
|
+
@_sut_list[ sut_id ][ :sut ].disconnect
|
211
|
+
|
212
|
+
@_sut_list[ sut_id ][ :is_connected ] = false
|
201
213
|
|
202
|
-
|
203
|
-
@_sut_list[ id ][ :is_connected ] = false
|
214
|
+
end
|
204
215
|
|
205
|
-
|
216
|
+
def reboot_sut( sut_attributes )
|
206
217
|
|
207
|
-
|
218
|
+
sut_id = retrieve_sut_id_from_hash( sut_attributes )
|
208
219
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
220
|
+
Kernel::raise RuntimeError.new(
|
221
|
+
|
222
|
+
"Unable to reboot SUT due to %s is not connected" % [ sut_id ]
|
223
|
+
|
224
|
+
) unless sut_exists?( sut_id ) && @_sut_list[ sut_id ][ :is_connected ]
|
225
|
+
|
226
|
+
@_sut_list[ sut_id ][ :sut ].reboot
|
215
227
|
|
216
|
-
|
228
|
+
disconnect_sut( sut_id )
|
217
229
|
|
218
|
-
|
230
|
+
end
|
219
231
|
|
220
|
-
|
232
|
+
def connected_suts
|
233
|
+
|
234
|
+
@_sut_list
|
235
|
+
|
236
|
+
end
|
221
237
|
|
222
238
|
private
|
223
239
|
|
224
|
-
|
225
|
-
def get_sut_from_list( id )
|
240
|
+
def retrieve_sut_id_from_hash( sut_attributes )
|
226
241
|
|
227
|
-
|
242
|
+
# usability improvement: threat sut_attribute as SUT id if it is type of Symbol or String
|
243
|
+
sut_attributes = { :id => sut_attributes.to_sym } if [ String, Symbol ].include?( sut_attributes.class )
|
228
244
|
|
229
|
-
|
230
|
-
|
245
|
+
# verify that sut_attributes is type of Hash
|
246
|
+
sut_attributes.check_type( [ Hash, Symbol, String ], "Wrong argument type $1 for 'sut_attributes' (expected $2)" )
|
231
247
|
|
232
|
-
|
248
|
+
# legacy support: support also :Id
|
249
|
+
sut_attributes[ :id ] = sut_attributes.delete( :Id ) if sut_attributes.has_key?( :Id )
|
233
250
|
|
234
|
-
|
235
|
-
|
251
|
+
sut_attributes.require_key( :id, "Required SUT identification key $1 not defined in 'sut_attributes'" )
|
252
|
+
|
253
|
+
sut_attributes[ :id ].to_sym
|
236
254
|
|
237
|
-
|
255
|
+
end
|
238
256
|
|
239
|
-
|
257
|
+
# gets sut from sut-factorys list - if not connected tries to reconnect first
|
258
|
+
def get_sut_from_list( id )
|
240
259
|
|
241
|
-
|
260
|
+
if !@_sut_list[ id ][ :is_connected ]
|
242
261
|
|
243
|
-
|
244
|
-
|
245
|
-
# === params
|
246
|
-
# id:: Symbol defining the id of the sut to search for
|
247
|
-
# === returns
|
248
|
-
# Symbol:: Either id if it was found in the parameter file or the id of a sut mapped to this id, or nil if no direct or mapped match was found
|
249
|
-
# === raises
|
250
|
-
# ArgumentError:: The id argument was not a Symbol
|
251
|
-
def find_sut_or_mapping( id )
|
262
|
+
@_sut_list[ id ][ :sut ].connect( id )
|
263
|
+
@_sut_list[ id ][ :is_connected ] = true
|
252
264
|
|
253
|
-
|
265
|
+
end
|
254
266
|
|
255
|
-
|
267
|
+
@_sut_list[ id ][ :sut ]
|
268
|
+
end
|
256
269
|
|
257
|
-
|
258
|
-
return id if MobyUtil::Parameter[ id ]
|
270
|
+
def sut_exists?( sut_id )
|
259
271
|
|
260
|
-
|
272
|
+
@_sut_list.has_key?( sut_id )
|
261
273
|
|
262
|
-
|
263
|
-
begin
|
274
|
+
end
|
264
275
|
|
265
|
-
|
266
|
-
|
276
|
+
# Finds the sut definition matching the id, either directly or via a mapping
|
277
|
+
#
|
278
|
+
# === params
|
279
|
+
# sut_id:: Symbol defining the id of the sut to search for
|
280
|
+
# === returns
|
281
|
+
# Symbol:: Either id if it was found in the parameter file or the id of a sut mapped to this id, or nil if no direct or mapped match was found
|
282
|
+
# === raises
|
283
|
+
# ArgumentError:: The id argument was not a Symbol
|
284
|
+
def find_sut_or_mapping( sut_id )
|
267
285
|
|
268
|
-
|
269
|
-
|
286
|
+
sut_id.check_type( Symbol, "Wrong argument type $1 for SUT id (expected $2)" )
|
287
|
+
|
288
|
+
#Kernel::raise ArgumentError.new( "The id argument was not a Symbol." ) unless sut_id.kind_of?( Symbol )
|
270
289
|
|
271
|
-
|
290
|
+
begin
|
272
291
|
|
273
|
-
|
274
|
-
|
292
|
+
# check if direct match exists
|
293
|
+
return sut_id if MobyUtil::Parameter[ sut_id ]
|
275
294
|
|
276
|
-
|
295
|
+
rescue MobyUtil::ParameterNotFoundError
|
277
296
|
|
278
|
-
|
297
|
+
# check if a mapping is defined for the id
|
298
|
+
begin
|
279
299
|
|
280
|
-
|
300
|
+
# return nil if no mapping exists
|
301
|
+
return nil if ( mapped_id = MobyUtil::Parameter[ :mappings ][ sut_id ] ).nil?
|
302
|
+
|
303
|
+
# check if the mapped to sut id exists
|
304
|
+
return mapped_id if MobyUtil::Parameter[ ( mapped_id = mapped_id.to_sym ) ]
|
305
|
+
|
306
|
+
rescue MobyUtil::ParameterNotFoundError
|
307
|
+
|
308
|
+
# no mappings defined in tdriver_parameters.xml or the mapped to sut was not found
|
309
|
+
return nil
|
310
|
+
|
311
|
+
end # check if mapping exists
|
312
|
+
|
313
|
+
end # check if direct match exists
|
314
|
+
|
315
|
+
end
|
281
316
|
|
282
|
-
|
283
|
-
|
317
|
+
# enable hooking for performance measurement & debug logging
|
318
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
284
319
|
|
285
|
-
|
320
|
+
end # SUTFactory
|
286
321
|
|
287
322
|
end # MobyBase
|