testability-driver 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/config/sut_parameters.rb +21 -8
- data/config/tdriver_custom_error_recovery.rb +83 -0
- data/ext/extconf.rb +3 -2
- data/ext/native_extensions.c +60 -2
- data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +2 -105
- data/lib/tdriver/base/behaviour/factory.rb +154 -89
- data/lib/tdriver/base/behaviour/factory_new.rb +409 -0
- data/lib/tdriver/base/errors.rb +3 -3
- data/lib/tdriver/base/state_object.rb +85 -22
- data/lib/tdriver/base/sut/adapter.rb +26 -0
- data/lib/tdriver/base/sut/controller.rb +1 -1
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +89 -118
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +67 -62
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +296 -187
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +7 -7
- data/lib/tdriver/base/sut/generic/commands/application.rb +366 -295
- data/lib/tdriver/base/sut/sut.rb +19 -3
- data/lib/tdriver/base/test_object/abstract.rb +41 -21
- data/lib/tdriver/base/test_object/adapter.rb +62 -9
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +10 -6
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +84 -47
- data/lib/tdriver/base/test_object/factory.rb +124 -68
- data/lib/tdriver/base/test_object/loader.rb +3 -4
- data/lib/tdriver/base/test_object/verification.rb +3 -3
- data/lib/tdriver/base/test_object/xml/adapter.rb +734 -0
- data/lib/tdriver/loader.rb +12 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +3 -2
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +14 -14
- data/lib/tdriver/report/report.rb +4 -8
- data/lib/tdriver/report/report_api.rb +9 -0
- data/lib/tdriver/report/report_crash_file_capture.rb +4 -4
- data/lib/tdriver/report/report_creator.rb +57 -35
- data/lib/tdriver/report/report_cucumber.rb +1 -1
- data/lib/tdriver/report/report_cucumber_listener.rb +5 -158
- data/lib/tdriver/report/report_cucumber_reporter.rb +7 -161
- data/lib/tdriver/report/report_execution_statistics.rb +4 -4
- data/lib/tdriver/report/report_file_capture.rb +5 -5
- data/lib/tdriver/report/report_grouping.rb +24 -22
- data/lib/tdriver/report/report_junit_xml.rb +5 -5
- data/lib/tdriver/report/report_test_case_run.rb +31 -22
- data/lib/tdriver/report/report_test_run.rb +107 -104
- data/lib/tdriver/report/report_writer.rb +150 -83
- data/lib/tdriver/tdriver.rb +147 -103
- data/lib/tdriver/util/common/boolean.rb +51 -0
- data/lib/tdriver/util/common/crc16.rb +110 -68
- data/lib/tdriver/util/common/hash.rb +63 -7
- data/lib/tdriver/util/common/kernel.rb +46 -1
- data/lib/tdriver/util/common/loader.rb +1 -0
- data/lib/tdriver/util/common/object.rb +20 -8
- data/lib/tdriver/util/common/string.rb +21 -2
- data/lib/tdriver/util/logger/logger.rb +4 -4
- data/lib/tdriver/util/parameter/loader.rb +2 -19
- data/lib/tdriver/util/parameter/parameter.rb +874 -177
- data/lib/tdriver/util/plugin/service.rb +1 -1
- data/lib/tdriver/util/recorder/recorder.rb +7 -1
- data/lib/tdriver/util/xml/abstraction.rb +13 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +63 -10
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +8 -2
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +16 -3
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +36 -32
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +19 -22
- data/lib/tdriver/util/xml/xml.rb +147 -32
- data/lib/tdriver/verify/verify.rb +1112 -289
- data/lib/tdriver/version.rb +1 -1
- data/xml/templates/generic.xml +14 -2
- metadata +51 -24
- data/lib/tdriver/util/parameter/parameter_hash.rb +0 -104
- data/lib/tdriver/util/parameter/parameter_new.rb +0 -869
- data/lib/tdriver/util/parameter/parameter_template.rb +0 -120
- data/lib/tdriver/util/parameter/parameter_user_api.rb +0 -116
- data/lib/tdriver/util/parameter/parameter_xml.rb +0 -261
@@ -0,0 +1,409 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of Testability Driver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
#require 'lib/tdriver'
|
21
|
+
|
22
|
+
module TDriver
|
23
|
+
|
24
|
+
class Behaviour
|
25
|
+
|
26
|
+
def initialize( values )
|
27
|
+
|
28
|
+
# add each hash pair as class instance attribute
|
29
|
+
values.each_pair do | key, value |
|
30
|
+
|
31
|
+
# cast to string; might need additional verification for invalid characters
|
32
|
+
key = key.to_s
|
33
|
+
|
34
|
+
# add attribute reader for hash key
|
35
|
+
eval <<-CODE
|
36
|
+
|
37
|
+
# add attribute reader
|
38
|
+
class << self; attr_reader :#{ key }; end
|
39
|
+
|
40
|
+
# set value
|
41
|
+
@#{ key } = #{ value.inspect };
|
42
|
+
|
43
|
+
CODE
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def method_missing( name, *args )
|
50
|
+
|
51
|
+
nil
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def applies_to?( rule )
|
56
|
+
|
57
|
+
rule.default = [ '*' ]
|
58
|
+
|
59
|
+
case rule[ :name ]
|
60
|
+
|
61
|
+
when @name
|
62
|
+
|
63
|
+
true
|
64
|
+
|
65
|
+
when ['*']
|
66
|
+
|
67
|
+
!( rule[ :object_type ] & @object_type ).empty? &&
|
68
|
+
!( rule[ :input_type ] & @input_type ).empty? &&
|
69
|
+
!( rule[ :env ] & @env ).empty? &&
|
70
|
+
!( rule[ :version ] & @version ).empty?
|
71
|
+
|
72
|
+
else
|
73
|
+
|
74
|
+
false
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
=begin
|
79
|
+
# calculate hash for behaviour rule / hash value will be used to identify similar objects
|
80
|
+
@@behaviours_cache.fetch( rule.delete_keys( :object ).hash ){ | behaviour_hash |
|
81
|
+
|
82
|
+
rule.default = [ '*' ]
|
83
|
+
|
84
|
+
@@behaviours_cache[ behaviour_hash ] = @@behaviours.each_with_index.collect{ | behaviour, index |
|
85
|
+
|
86
|
+
case rule[ :name ]
|
87
|
+
|
88
|
+
when behaviour[ :name ]
|
89
|
+
|
90
|
+
index
|
91
|
+
|
92
|
+
when [ '*' ]
|
93
|
+
|
94
|
+
index if (
|
95
|
+
!( rule[ :object_type ] & behaviour[ :object_type ] ).empty? &&
|
96
|
+
!( rule[ :input_type ] & behaviour[ :input_type ] ).empty? &&
|
97
|
+
!( rule[ :env ] & behaviour[ :env ] ).empty? &&
|
98
|
+
!( rule[ :version ] & behaviour[ :version ] ).empty?
|
99
|
+
)
|
100
|
+
|
101
|
+
else
|
102
|
+
|
103
|
+
nil
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
}.compact
|
108
|
+
|
109
|
+
}
|
110
|
+
=end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
class BehaviourFactory
|
117
|
+
|
118
|
+
class << self
|
119
|
+
|
120
|
+
public
|
121
|
+
|
122
|
+
# initialize behaviours factory
|
123
|
+
def init( options )
|
124
|
+
|
125
|
+
load_behaviours(
|
126
|
+
|
127
|
+
options[ :path ]
|
128
|
+
|
129
|
+
)
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
# reset class configuration
|
134
|
+
def reset
|
135
|
+
|
136
|
+
# reset default values
|
137
|
+
initialize_class
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
def collect_behaviours( rule )
|
142
|
+
|
143
|
+
cache_key = rule.reject{ | key, value | key == :object }
|
144
|
+
|
145
|
+
if @behaviours_cache.has_key?( cache_key )
|
146
|
+
|
147
|
+
@behaviours_cache[ cache_key ]
|
148
|
+
|
149
|
+
else
|
150
|
+
|
151
|
+
# retrieve enabled plugins from PluginService
|
152
|
+
enabled_plugins = TDriver::PluginService.enabled_plugins
|
153
|
+
|
154
|
+
@behaviours_cache[ cache_key ] = @behaviours.select do | behaviour |
|
155
|
+
|
156
|
+
# skip if required plugin is not registered or enabled; compare requires array and enabled_plugins array
|
157
|
+
next unless ( behaviour[ 'requires' ] - enabled_plugins ).empty?
|
158
|
+
|
159
|
+
rule.default = [ '*' ]
|
160
|
+
|
161
|
+
case rule[ :name ]
|
162
|
+
|
163
|
+
when @name
|
164
|
+
|
165
|
+
# exact match with name
|
166
|
+
true
|
167
|
+
|
168
|
+
when ['*']
|
169
|
+
|
170
|
+
# compare rules and behaviour attributes
|
171
|
+
!( rule[ :object_type ] & behaviour[ 'object_type' ] ).empty? &&
|
172
|
+
!( rule[ :input_type ] & behaviour[ 'input_type' ] ).empty? &&
|
173
|
+
!( rule[ :env ] & behaviour[ 'env' ] ).empty? &&
|
174
|
+
!( rule[ :version ] & behaviour[ 'version' ] ).empty?
|
175
|
+
|
176
|
+
else
|
177
|
+
|
178
|
+
false
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
def apply_behaviour( rule )
|
189
|
+
|
190
|
+
collected_indexes = []
|
191
|
+
|
192
|
+
rule[ :object ].instance_variable_get( :@object_behaviours )
|
193
|
+
|
194
|
+
collect_behaviours( rule ).each do | behaviour |
|
195
|
+
|
196
|
+
begin
|
197
|
+
|
198
|
+
# retrieve behaviour module
|
199
|
+
behaviour[ 'module' ] = MobyUtil::KernelHelper.get_constant( behaviour[ 'module' ].to_s ) unless behaviour[ 'module' ].kind_of?( Module )
|
200
|
+
|
201
|
+
# extend target object with behaviour module
|
202
|
+
rule[ :object ].extend( behaviour[ 'module' ] )
|
203
|
+
|
204
|
+
# store behaviour indexes
|
205
|
+
collected_indexes << behaviour[ 'index' ]
|
206
|
+
|
207
|
+
rescue NameError
|
208
|
+
|
209
|
+
raise NameError, "Implementation for #{ behaviour[ 'name' ] } behaviour does not exist. (#{ behaviour[ 'module' ] })"
|
210
|
+
|
211
|
+
rescue
|
212
|
+
|
213
|
+
raise RuntimeError, "Error while applying #{ behaviour[ 'name' ] } (#{ behaviour[ 'module' ] }) behaviour to target object due to #{ $!.message } (#{ $!.class })"
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
rule[ :object ].instance_variable_get( :@object_behaviours ).tap{ | indexes | indexes = indexes | collected_indexes }
|
221
|
+
|
222
|
+
=begin
|
223
|
+
# retrieve enabled plugins from PluginService
|
224
|
+
enabled_plugins = TDriver::PluginService.enabled_plugins
|
225
|
+
|
226
|
+
@behaviours.each_with_index{ | behaviour, index |
|
227
|
+
|
228
|
+
# skip if required plugin is not registered or enabled; compare requires array and enabled_plugins array
|
229
|
+
next unless ( behaviour.requires - enabled_plugins ).empty?
|
230
|
+
|
231
|
+
if behaviour.applies_to?( rule )
|
232
|
+
|
233
|
+
begin
|
234
|
+
|
235
|
+
behaviour_module = behaviour.module
|
236
|
+
|
237
|
+
# retrieve behaviour module
|
238
|
+
if behaviour_module.kind_of?( String )
|
239
|
+
behaviour_module = behaviour.instance_variable_set(:@module, MobyUtil::KernelHelper.get_constant( behaviour.module ))
|
240
|
+
end
|
241
|
+
|
242
|
+
# extend target object with behaviour module
|
243
|
+
rule[ :object ].extend( behaviour_module )
|
244
|
+
|
245
|
+
rescue NameError
|
246
|
+
|
247
|
+
raise NameError, "Implementation for #{ behaviour.name } behaviour does not exist. (#{ behaviour.module })"
|
248
|
+
|
249
|
+
rescue
|
250
|
+
|
251
|
+
raise RuntimeError, "Error while applying #{ behaviour.name } (#{ behaviour.module }) behaviour to target object due to #{ $!.message } (#{ $!.class })"
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
# new
|
256
|
+
#MobyBase::BehaviourFactory::apply_behaviour! 631 2.25980600 2.21837500 3.178% 0.00358131
|
257
|
+
|
258
|
+
# old
|
259
|
+
#MobyBase::BehaviourFactory::apply_behaviour! 631 2.27668800 2.23749700 3.178% 0.00360806
|
260
|
+
#MobyBase::BehaviourFactory::apply_behaviour! 631 0.87363100 0.77245300 1.131% 0.00138452
|
261
|
+
#MobyBase::BehaviourFactory::apply_behaviour! 631 0.51659900 0.48817000 0.720% 0.00081870
|
262
|
+
#MobyBase::BehaviourFactory::apply_behaviour! 631 0.73310700 0.70426600 1.030% 0.00116182
|
263
|
+
#MobyBase::BehaviourFactory::apply_behaviour! 631 0.58667000 0.55826300 0.824% 0.00092975
|
264
|
+
|
265
|
+
#=begin
|
266
|
+
# add behaviour information to test object
|
267
|
+
rule[ :object ].instance_variable_get( :@object_behaviours ).tap{ | indexes |
|
268
|
+
|
269
|
+
indexes.push( index ) unless indexes.include?( index )
|
270
|
+
|
271
|
+
}
|
272
|
+
#=end
|
273
|
+
|
274
|
+
# add behaviour information to test object
|
275
|
+
indexes = rule[ :object ].instance_variable_get( :@object_behaviours )
|
276
|
+
|
277
|
+
indexes.push( index ) unless indexes.include?( index )
|
278
|
+
|
279
|
+
end # if applies.to?
|
280
|
+
|
281
|
+
}
|
282
|
+
=end
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
private
|
287
|
+
|
288
|
+
# private methods and variables
|
289
|
+
def initialize_class
|
290
|
+
|
291
|
+
# behaviours container
|
292
|
+
@behaviours = []
|
293
|
+
|
294
|
+
@behaviours_cache = {}
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
# load and parse behaviours files
|
299
|
+
def load_behaviours( path )
|
300
|
+
|
301
|
+
# behaviour xml files path
|
302
|
+
Dir.glob( File.join( path, '*.xml' ) ){ | filename |
|
303
|
+
|
304
|
+
begin
|
305
|
+
|
306
|
+
# read file contents
|
307
|
+
content = MobyUtil::FileHelper.get_file( filename )
|
308
|
+
|
309
|
+
# skip when empty file
|
310
|
+
next if content.empty?
|
311
|
+
|
312
|
+
# parse behaviour xml and process each behaviours element
|
313
|
+
MobyUtil::XML.parse_string( content ).root.xpath( '/behaviours' ).each do | behaviours |
|
314
|
+
|
315
|
+
# retrieve root attributes
|
316
|
+
root_attributes = behaviours.attributes
|
317
|
+
|
318
|
+
# process each behaviour element
|
319
|
+
behaviours.xpath( 'behaviour' ).each do | behaviour |
|
320
|
+
|
321
|
+
# retrieve behaviour attributes - set default values if not found from element
|
322
|
+
attributes = behaviour.attributes.default_values(
|
323
|
+
"name" => '',
|
324
|
+
"object_type" => '',
|
325
|
+
"input_type" => '',
|
326
|
+
"sut_type" => '',
|
327
|
+
"version" => '',
|
328
|
+
"env" => '*'
|
329
|
+
)
|
330
|
+
|
331
|
+
# verify that behaviour attributes are not empty
|
332
|
+
attributes.each_pair do | key, value |
|
333
|
+
|
334
|
+
value.not_empty "behaviour element attribute #{ key.inspect } is not defined or empty", RuntimeError
|
335
|
+
|
336
|
+
end
|
337
|
+
|
338
|
+
# retrieve implementation/module name
|
339
|
+
module_name = behaviour.at_xpath( 'module/@name' ).to_s
|
340
|
+
|
341
|
+
# verify that module name is defined
|
342
|
+
module_name.not_empty "behaviour #{ attributes[ "name" ].inspect } does not have module name defined or is empty", RuntimeError
|
343
|
+
|
344
|
+
# store behaviour
|
345
|
+
#@behaviours << Behaviour.new(
|
346
|
+
|
347
|
+
# store behaviour
|
348
|
+
@behaviours << { #Behaviour.new(
|
349
|
+
|
350
|
+
"index" => @behaviours.count,
|
351
|
+
|
352
|
+
"name" => attributes[ 'name' ],
|
353
|
+
"object_type" => attributes[ 'object_type' ].split(';'),
|
354
|
+
"input_type" => attributes[ 'input_type' ].split(';'),
|
355
|
+
"version" => attributes[ 'version' ].split(';'),
|
356
|
+
"env" => attributes[ 'env' ].split(';'),
|
357
|
+
|
358
|
+
"requires" => root_attributes[ 'plugin' ].to_s.split(';'),
|
359
|
+
|
360
|
+
"module" => module_name,
|
361
|
+
"file" => behaviour.at_xpath( 'module/text()' ).to_s, # optional
|
362
|
+
|
363
|
+
"methods" => Hash[
|
364
|
+
# collect method details from behaviour
|
365
|
+
behaviour.xpath( 'methods/method' ).collect{ | method |
|
366
|
+
[
|
367
|
+
method.attribute('name'),
|
368
|
+
{
|
369
|
+
"description" => method.at_xpath( 'description/text()' ).to_s,
|
370
|
+
"example" => method.at_xpath( 'example/text()' ).to_s
|
371
|
+
}
|
372
|
+
]
|
373
|
+
}
|
374
|
+
]
|
375
|
+
|
376
|
+
}
|
377
|
+
|
378
|
+
# )
|
379
|
+
|
380
|
+
end # behaviour.each
|
381
|
+
|
382
|
+
end # behaviours.each
|
383
|
+
|
384
|
+
rescue MobyUtil::FileNotFoundError
|
385
|
+
|
386
|
+
raise
|
387
|
+
|
388
|
+
rescue MobyUtil::XML::ParseError
|
389
|
+
|
390
|
+
raise MobyUtil::XML::ParseError, "Error while parsing behaviours file #{ behaviours[ :filename ] } due to #{ $!.message }"
|
391
|
+
|
392
|
+
rescue
|
393
|
+
|
394
|
+
raise RuntimeError, "Error while processing behaviours file #{ filename } due to #{ $!.message }"
|
395
|
+
|
396
|
+
end
|
397
|
+
|
398
|
+
} # Dir.glob
|
399
|
+
|
400
|
+
end # behaviours
|
401
|
+
|
402
|
+
end # self
|
403
|
+
|
404
|
+
# initialize behaviour factory
|
405
|
+
initialize_class
|
406
|
+
|
407
|
+
end
|
408
|
+
|
409
|
+
end
|
data/lib/tdriver/base/errors.rb
CHANGED
@@ -93,9 +93,9 @@ module MobyBase
|
|
93
93
|
# This error should be raised when verification results were not as expected
|
94
94
|
class VerificationError < MobyStandardError; end;
|
95
95
|
|
96
|
-
# This verification error should overwrite standard verification procedure and
|
97
|
-
#
|
98
|
-
class ContinuousVerificationError <
|
96
|
+
# This verification error should overwrite standard verification procedure and fail immediately
|
97
|
+
#class ContinuousVerificationError < VerificationError; end;
|
98
|
+
class ContinuousVerificationError < MobyStandardError; end;
|
99
99
|
|
100
100
|
# This error should be raised to indicate that a synchronization timeout has elapsed without
|
101
101
|
# synchronization conditions having been met.
|
@@ -38,41 +38,100 @@ module MobyBase
|
|
38
38
|
attr_accessor :parent
|
39
39
|
|
40
40
|
# TODO: document me
|
41
|
-
attr_reader
|
41
|
+
attr_reader(
|
42
|
+
:type, # object type
|
43
|
+
:name, # object name
|
44
|
+
:id # object id
|
45
|
+
)
|
42
46
|
|
43
|
-
#
|
44
|
-
#
|
47
|
+
# Creation of a new StateObject from source data.
|
45
48
|
# === params
|
46
|
-
#
|
47
|
-
# parent:: TestObject, SUT or StateObject. Parent of this state object. Must be of type TestObjectComposition.
|
49
|
+
# options:: Hash containing source data describing the object and all other required configuration values e.g. test object factory, -adapter etc.
|
48
50
|
# === returns
|
49
|
-
# StateObject::
|
50
|
-
|
51
|
+
# StateObject:: new StateObject instance
|
52
|
+
# === raises
|
53
|
+
def initialize( *options )
|
51
54
|
|
52
|
-
|
55
|
+
# clone original options array; array is modified below
|
56
|
+
options = options.clone
|
57
|
+
|
58
|
+
# determine is method called with new or deprecated API
|
59
|
+
|
60
|
+
if options.count == 1 and options.first.kind_of?( Hash )
|
53
61
|
|
54
|
-
|
62
|
+
# retrieve first array element
|
63
|
+
options = options.shift
|
55
64
|
|
56
|
-
|
65
|
+
# verify options argument type
|
66
|
+
options.check_type Hash, 'wrong argument type $1 for StateObject options (expected $2)'
|
57
67
|
|
58
|
-
|
68
|
+
# verify that :source_data key exists in hash
|
69
|
+
source_data = options.require_key :source_data
|
59
70
|
|
60
|
-
|
71
|
+
# retrieve reference to parent object
|
72
|
+
parent = options[ :parent ]
|
61
73
|
|
74
|
+
# retrieve reference to test object adapter
|
75
|
+
test_object_adapter = options[ :test_object_adapter ]
|
76
|
+
|
62
77
|
else
|
78
|
+
|
79
|
+
# print warning if deprecated API is used
|
80
|
+
warn_caller '$1:$2 warning: deprecated API; use hash with :source_data, :parent, :test_object_adapter as argument instead of StateObject.new( source_data, parent, test_object_adapter )'
|
81
|
+
|
82
|
+
# retrieve source data
|
83
|
+
source_data = options.shift
|
63
84
|
|
64
|
-
|
85
|
+
# retrieve reference to parent object
|
86
|
+
parent = options.shift
|
87
|
+
|
88
|
+
# retrieve reference to test object adapter
|
89
|
+
test_object_adapter = options.shift
|
65
90
|
|
66
91
|
end
|
67
92
|
|
68
|
-
|
93
|
+
# verify that parent argument type is correct
|
94
|
+
parent.check_type [ NilClass, MobyBase::StateObject, MobyBase::TestObject, MobyBase::SUT ], 'wrong argument type $1 for parent object (expected $2)'
|
95
|
+
|
96
|
+
# verify that test object adapter argument type is correct
|
97
|
+
test_object_adapter.check_type [ NilClass, Class ], 'wrong argument type $1 for test object adapter (expected $2)'
|
98
|
+
|
99
|
+
# verify that source data argument type is correct
|
100
|
+
source_data.check_type [ String, MobyUtil::XML::Element ], 'wrong argument type $1 for source data (expected $2)'
|
101
|
+
|
102
|
+
# parse source data if given argument is type of string
|
103
|
+
source_data = MobyUtil::XML.parse_string( source_data ).root if source_data.kind_of?( String )
|
104
|
+
|
105
|
+
# store reference to parent object
|
106
|
+
@parent = parent
|
107
|
+
|
108
|
+
# store reference to test object adapter
|
109
|
+
if test_object_adapter.nil?
|
110
|
+
|
111
|
+
if @parent.kind_of?( MobyBase::SUT )
|
69
112
|
|
70
|
-
|
113
|
+
@test_object_adapter = @parent.instance_variable_get( :@test_object_adapter )
|
71
114
|
|
115
|
+
else
|
116
|
+
|
117
|
+
@test_object_adapter = TDriver::TestObjectAdapter
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
else
|
122
|
+
|
123
|
+
@test_object_adapter = test_object_adapter
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
# retrieve object attributes
|
128
|
+
method( :xml_data= ).call( source_data )
|
129
|
+
|
130
|
+
# initialize child objects cache for state object
|
72
131
|
@child_object_cache = TDriver::TestObjectCache.new
|
73
132
|
|
74
|
-
#
|
75
|
-
|
133
|
+
# create accessor methods for any child state objects.
|
134
|
+
@test_object_adapter.create_child_accessors!( source_data, self )
|
76
135
|
|
77
136
|
end
|
78
137
|
|
@@ -164,7 +223,7 @@ module MobyBase
|
|
164
223
|
|
165
224
|
@_xml_data = xml_object
|
166
225
|
|
167
|
-
unused_xpath, @name, @type, @id =
|
226
|
+
unused_xpath, @name, @type, @id = @test_object_adapter.get_test_object_identifiers( xml_object )
|
168
227
|
|
169
228
|
end
|
170
229
|
|
@@ -195,7 +254,7 @@ module MobyBase
|
|
195
254
|
begin
|
196
255
|
|
197
256
|
# retrieve attribute(s) from test object; never access ui state xml data directly from behaviour implementation
|
198
|
-
|
257
|
+
@test_object_adapter.test_object_attribute( @_xml_data, name.to_s )
|
199
258
|
|
200
259
|
rescue MobyBase::AttributeNotFoundError
|
201
260
|
|
@@ -261,7 +320,7 @@ module MobyBase
|
|
261
320
|
dynamic_attributes = rules.strip_dynamic_attributes!
|
262
321
|
|
263
322
|
# retrieve application object from sut.xml_data
|
264
|
-
matches, unused_rule =
|
323
|
+
matches, unused_rule = @test_object_adapter.get_objects( @_xml_data, rules, true )
|
265
324
|
|
266
325
|
if matches.count == 0
|
267
326
|
|
@@ -280,8 +339,12 @@ module MobyBase
|
|
280
339
|
|
281
340
|
# create state objects
|
282
341
|
matches = matches.collect{ | object_xml |
|
283
|
-
|
284
|
-
result = StateObject.new(
|
342
|
+
|
343
|
+
result = StateObject.new(
|
344
|
+
:source_data => object_xml,
|
345
|
+
:parent => self,
|
346
|
+
:test_object_adapter => @test_object_adapter
|
347
|
+
)
|
285
348
|
|
286
349
|
# use cached state object if once already retrieved
|
287
350
|
get_cached_test_object!( result ).tap{ | found_in_cache |
|