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.
Files changed (71) hide show
  1. data/config/sut_parameters.rb +21 -8
  2. data/config/tdriver_custom_error_recovery.rb +83 -0
  3. data/ext/extconf.rb +3 -2
  4. data/ext/native_extensions.c +60 -2
  5. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +2 -105
  6. data/lib/tdriver/base/behaviour/factory.rb +154 -89
  7. data/lib/tdriver/base/behaviour/factory_new.rb +409 -0
  8. data/lib/tdriver/base/errors.rb +3 -3
  9. data/lib/tdriver/base/state_object.rb +85 -22
  10. data/lib/tdriver/base/sut/adapter.rb +26 -0
  11. data/lib/tdriver/base/sut/controller.rb +1 -1
  12. data/lib/tdriver/base/sut/generic/behaviours/application.rb +89 -118
  13. data/lib/tdriver/base/sut/generic/behaviours/find.rb +67 -62
  14. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +296 -187
  15. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +7 -7
  16. data/lib/tdriver/base/sut/generic/commands/application.rb +366 -295
  17. data/lib/tdriver/base/sut/sut.rb +19 -3
  18. data/lib/tdriver/base/test_object/abstract.rb +41 -21
  19. data/lib/tdriver/base/test_object/adapter.rb +62 -9
  20. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +10 -6
  21. data/lib/tdriver/base/test_object/behaviours/test_object.rb +84 -47
  22. data/lib/tdriver/base/test_object/factory.rb +124 -68
  23. data/lib/tdriver/base/test_object/loader.rb +3 -4
  24. data/lib/tdriver/base/test_object/verification.rb +3 -3
  25. data/lib/tdriver/base/test_object/xml/adapter.rb +734 -0
  26. data/lib/tdriver/loader.rb +12 -0
  27. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +3 -2
  28. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +14 -14
  29. data/lib/tdriver/report/report.rb +4 -8
  30. data/lib/tdriver/report/report_api.rb +9 -0
  31. data/lib/tdriver/report/report_crash_file_capture.rb +4 -4
  32. data/lib/tdriver/report/report_creator.rb +57 -35
  33. data/lib/tdriver/report/report_cucumber.rb +1 -1
  34. data/lib/tdriver/report/report_cucumber_listener.rb +5 -158
  35. data/lib/tdriver/report/report_cucumber_reporter.rb +7 -161
  36. data/lib/tdriver/report/report_execution_statistics.rb +4 -4
  37. data/lib/tdriver/report/report_file_capture.rb +5 -5
  38. data/lib/tdriver/report/report_grouping.rb +24 -22
  39. data/lib/tdriver/report/report_junit_xml.rb +5 -5
  40. data/lib/tdriver/report/report_test_case_run.rb +31 -22
  41. data/lib/tdriver/report/report_test_run.rb +107 -104
  42. data/lib/tdriver/report/report_writer.rb +150 -83
  43. data/lib/tdriver/tdriver.rb +147 -103
  44. data/lib/tdriver/util/common/boolean.rb +51 -0
  45. data/lib/tdriver/util/common/crc16.rb +110 -68
  46. data/lib/tdriver/util/common/hash.rb +63 -7
  47. data/lib/tdriver/util/common/kernel.rb +46 -1
  48. data/lib/tdriver/util/common/loader.rb +1 -0
  49. data/lib/tdriver/util/common/object.rb +20 -8
  50. data/lib/tdriver/util/common/string.rb +21 -2
  51. data/lib/tdriver/util/logger/logger.rb +4 -4
  52. data/lib/tdriver/util/parameter/loader.rb +2 -19
  53. data/lib/tdriver/util/parameter/parameter.rb +874 -177
  54. data/lib/tdriver/util/plugin/service.rb +1 -1
  55. data/lib/tdriver/util/recorder/recorder.rb +7 -1
  56. data/lib/tdriver/util/xml/abstraction.rb +13 -1
  57. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +63 -10
  58. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +8 -2
  59. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +16 -3
  60. data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +36 -32
  61. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +19 -22
  62. data/lib/tdriver/util/xml/xml.rb +147 -32
  63. data/lib/tdriver/verify/verify.rb +1112 -289
  64. data/lib/tdriver/version.rb +1 -1
  65. data/xml/templates/generic.xml +14 -2
  66. metadata +51 -24
  67. data/lib/tdriver/util/parameter/parameter_hash.rb +0 -104
  68. data/lib/tdriver/util/parameter/parameter_new.rb +0 -869
  69. data/lib/tdriver/util/parameter/parameter_template.rb +0 -120
  70. data/lib/tdriver/util/parameter/parameter_user_api.rb +0 -116
  71. data/lib/tdriver/util/parameter/parameter_xml.rb +0 -261
@@ -30,16 +30,32 @@ module MobyBase
30
30
  :type # type of object ("SUT"), used when applying behaviour
31
31
  )
32
32
 
33
+ #added for now
34
+ attr_reader(
35
+ :test_object_adapter
36
+ )
37
+
33
38
  # Initialize SUT by giving references to the used controller and test object factory
34
39
  # == params
35
40
  # sut_controller:: Controller object that acts as a facade to the device represented by this SUT
36
41
  # test_object_factory:: TestObjectFactory object, a factory for generating creating test objects for this SUT
37
42
  # sut_id:: String representing the identification of this SUT - the identification will need to match with group id in parameters xml
38
- def initialize( sut_controller, test_object_factory, sut_id )
43
+ def initialize( sut_controller, test_object_factory, sut_id, test_object_adapter = nil )
44
+
45
+ @sut_controller = sut_controller
46
+
47
+ #@sut_controller.test_object_factory = test_object_factory
39
48
 
49
+ #@sut_controller.test_object_adapter = test_object_adapter || TDriver::TestObjectAdapter
50
+
51
+ # remove this line when possible
40
52
  @_sutController = sut_controller
53
+
54
+ # remove this line when possible
55
+ @test_object_factory = test_object_factory # @sut_controller.test_object_factory
41
56
 
42
- @test_object_factory = test_object_factory || TDriver::TestObjectFactory.new( :test_object_adapter => TDriver::TestObjectAdapter )
57
+ # remove this line when possible
58
+ @test_object_adapter = test_object_adapter || TDriver::TestObjectAdapter #@sut_controller.test_object_adapter
43
59
 
44
60
  @id = sut_id
45
61
 
@@ -65,7 +81,7 @@ module MobyBase
65
81
  # Boolean:: what ever SutController returns
66
82
  def execute_command( command )
67
83
 
68
- @_sutController.execute_command( command )
84
+ @sut_controller.execute_command( command )
69
85
 
70
86
  end
71
87
 
@@ -23,33 +23,45 @@ module MobyBase
23
23
 
24
24
  attr_reader(
25
25
  :sut, # SUT associated to test object
26
- :type, # test object type (from xml)
27
- :id, # test object id (from xml)
26
+ :type, # test object type (from xml)
27
+ :id, # test object id (from xml)
28
28
  :parent, # parent test object
29
- :name, # test object name (from xml)
30
- :x_path # xpath for test object, used when updating self with fresh ui dump
29
+ :name, # test object name (from xml)
30
+ :x_path # xpath for test object, used when updating self with fresh ui dump
31
31
  )
32
32
 
33
- # Creation of a new TestObject requires a data object to be given to constructor
33
+ # Creation of a new TestObject requires options hash to be given to constructor.
34
34
  # === params
35
- # factory:: TestObjectFactory used for creating test object for the sut this object is associated with
36
- # sut:: SUT object that this test object is associated with
37
- # xml_object:: REXML::Document object describing this test object
35
+ # options:: Hash containing xml object describing the object and all other required configuration values e.g. test object factory, -adapter etc.
38
36
  # === returns
39
37
  # TestObject:: new TestObject instance
40
38
  # === raises
41
- def initialize( test_object_factory, sut, parent = nil, xml_object = nil )
39
+ def initialize( options )
42
40
 
43
- # Initializes a test object by assigning it a test object factory and a sut and storing xml data
44
- # describing the object.
45
- @test_object_factory = test_object_factory
46
- @parent = parent
47
- @sut = sut
48
- @object_behaviours = []
41
+ # verify that given argument is type of hash
42
+ options.check_type Hash, 'wrong argument type $1 for TestObject#new (expected $2)'
49
43
 
50
- #self.xml_data = xml_object if xml_object
51
- method( :xml_data= ).call( xml_object ) if xml_object
52
-
44
+ # verify that required keys is found from options hash and initialize the test object with these values.
45
+ @test_object_factory = options.require_key( :test_object_factory )
46
+ @test_object_adapter = options.require_key( :test_object_adapter )
47
+ @creation_attributes = options.require_key( :creation_attributes )
48
+
49
+ @sut = options.require_key( :sut )
50
+
51
+ @sut_id = @sut.instance_variable_get( :@id )
52
+
53
+ @parent = options.require_key( :parent )
54
+ @parent_application = options.require_key( :parent_application )
55
+
56
+ # apply xml object if given; test object type, id and name are retrieved from the xml
57
+ self.xml_data = options[ :xml_object ] if options.has_key?( :xml_object )
58
+
59
+ # initialize cache object
60
+ @child_object_cache = TDriver::TestObjectCache.new
61
+
62
+ # empty test object behaviours list
63
+ @object_behaviours = []
64
+
53
65
  end
54
66
 
55
67
  # Function to verify is DATA of two TestObjects are the same,
@@ -110,7 +122,7 @@ module MobyBase
110
122
  # optimized version
111
123
  #( ( ( 17 * 37 + @id.to_i ) * 37 + @type.hash ) * 37 + @name.hash )
112
124
 
113
- TDriver::TestObjectAdapter.test_object_hash( @id.to_i, @type, @name )
125
+ @test_object_adapter.test_object_hash( @id.to_i, @type, @name )
114
126
 
115
127
  end
116
128
 
@@ -144,7 +156,7 @@ module MobyBase
144
156
  # Function to be renamed, possibly refactored
145
157
  def xml_data=( xml_object )
146
158
 
147
- @x_path, @name, @type, @id, @env = TDriver::TestObjectAdapter.get_test_object_identifiers( xml_object, self )
159
+ @x_path, @name, @type, @id, @env = @test_object_adapter.get_test_object_identifiers( xml_object, self )
148
160
 
149
161
  end
150
162
 
@@ -158,7 +170,7 @@ module MobyBase
158
170
 
159
171
  begin
160
172
 
161
- TDriver::TestObjectAdapter.get_xml_element_for_test_object( self )
173
+ @test_object_adapter.get_xml_element_for_test_object( self )
162
174
 
163
175
  rescue MobyBase::TestObjectNotFoundError
164
176
 
@@ -179,6 +191,14 @@ module MobyBase
179
191
 
180
192
  end
181
193
 
194
+ private
195
+
196
+ def sut_parameters
197
+
198
+ $parameters[ @sut_id ]
199
+
200
+ end
201
+
182
202
  # enable hooking for performance measurement & debug logging
183
203
  TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
184
204
 
@@ -34,7 +34,7 @@ module TDriver
34
34
 
35
35
  # allow multiple values options for attribute, e.g. object which 'text' attribute value is either '1' or '2'
36
36
  ( values.kind_of?( Array ) ? values : [ values ] ).collect{ | value |
37
-
37
+
38
38
  # concatenate string if it contains single and double quotes, otherwise return as is
39
39
  value = xpath_literal_string( value )
40
40
 
@@ -71,7 +71,7 @@ module TDriver
71
71
  }.join( ' or ' ) # join attribute alternative values
72
72
 
73
73
  }.join( ' and ' ) # join all required attributes
74
-
74
+
75
75
  # return created xpath or nil if no attributes given
76
76
  if attributes.empty?
77
77
 
@@ -113,9 +113,24 @@ module TDriver
113
113
 
114
114
  # convert hash keys to downcased string
115
115
  rules = Hash[
116
+
116
117
  rules.collect{ | key, value |
117
- [ key.to_s.downcase, value.kind_of?( Regexp ) ? value : value.to_s ]
118
+
119
+ case value
120
+
121
+ # pass the value as is if type of regexp or array; array is used in localisation cases e.g. [ 'one', 'yksi', 'uno' ] # etc
122
+ when Regexp, Array
123
+
124
+ [ key.to_s.downcase, value ]
125
+
126
+ else
127
+
128
+ [ key.to_s.downcase, value.to_s ]
129
+
130
+ end
131
+
118
132
  }
133
+
119
134
  ]
120
135
 
121
136
  # xpath container array
@@ -236,12 +251,26 @@ module TDriver
236
251
  # Sort XML nodeset of test objects with layout direction
237
252
  def self.sort_elements( nodeset, layout_direction = 'LeftToRight' )
238
253
 
239
- attribute_pattern = './attributes/attribute[@name="%s"]/value/text()'
254
+ # cache for x_absolute and y_absolute values; reduces dramatically number of xpath calls
255
+ cache = {}
256
+
257
+ # xpath pattern to be used for x_absolute attribute value
258
+ x_absolute_pattern = './attributes/attribute[@name="x_absolute"]/value/text()'
259
+
260
+ # xpath pattern to be used for x_absolute attribute value
261
+ y_absolute_pattern = './attributes/attribute[@name="y_absolute"]/value/text()'
240
262
 
241
263
  # collect only nodes that has x_absolute and y_absolute attributes
242
264
  nodeset.collect!{ | node |
243
265
 
244
- if node.at_xpath( attribute_pattern % 'x_absolute' ).nil? || node.at_xpath( attribute_pattern % 'y_absolute' ).nil?
266
+ # retrieve x_absolute attribute
267
+ x_absolute = node.at_xpath( x_absolute_pattern )
268
+
269
+ # retrieve y_absolute attribute
270
+ y_absolute = node.at_xpath( y_absolute_pattern )
271
+
272
+ # return unmodified nodeset if both attributes was not found
273
+ if x_absolute.nil? || y_absolute.nil?
245
274
 
246
275
  #warn("Warning: Unable to sort object set due to object type of #{ node.attribute( 'type' ).inspect } does not have \"x_absolute\" or \"y_absolute\" attribute")
247
276
 
@@ -249,6 +278,10 @@ module TDriver
249
278
 
250
279
  else
251
280
 
281
+ # store attributes to cache for further processing
282
+ cache[ node ] = [ x_absolute.content.to_i, y_absolute.content.to_i ]
283
+
284
+ # return node as result
252
285
  node
253
286
 
254
287
  end
@@ -256,12 +289,10 @@ module TDriver
256
289
  }.compact!.sort!{ | element_a, element_b |
257
290
 
258
291
  # retrieve element a's attributes x and y
259
- element_a_x = element_a.at_xpath( attribute_pattern % 'x_absolute' ).content.to_i
260
- element_a_y = element_a.at_xpath( attribute_pattern % 'y_absolute' ).content.to_i
292
+ element_a_x, element_a_y = cache[ element_a ]
261
293
 
262
294
  # retrieve element b's attributes x and y
263
- element_b_x = element_b.at_xpath( attribute_pattern % 'x_absolute' ).content.to_i
264
- element_b_y = element_b.at_xpath( attribute_pattern % 'y_absolute' ).content.to_i
295
+ element_b_x, element_b_y = cache[ element_b ]
265
296
 
266
297
  case layout_direction
267
298
 
@@ -650,6 +681,28 @@ module TDriver
650
681
 
651
682
  end
652
683
 
684
+ # TODO: document me
685
+ def self.list_test_objects_as_string( matches )
686
+
687
+ matches.collect{ | object |
688
+
689
+ path = [ object.attribute( 'type' ) ]
690
+
691
+ while object.attribute( 'type' ) != 'application' do
692
+
693
+ # object/objects/object/../..
694
+ object = object.parent.parent
695
+
696
+ path << object.attribute( 'type' )
697
+
698
+ end
699
+
700
+ path.reverse.join( '.' )
701
+
702
+ }.sort
703
+
704
+ end
705
+
653
706
  # enable hooking for performance measurement & debug logging
654
707
  TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
655
708
 
@@ -53,7 +53,7 @@ module MobyBehaviour
53
53
  # description: Hash defining the set of attributes that the child test object must possess.
54
54
  # example: {:text=>'1'}
55
55
  #
56
- # timeout_secs
56
+ # timeout
57
57
  # Fixnum
58
58
  # description: Overriding the default synchronization timeout
59
59
  # example: 30
@@ -84,7 +84,7 @@ module MobyBehaviour
84
84
  # MobyBase::SyncTimeoutError
85
85
  # description: Synchronization timed out (%i) before the defined child object could be found
86
86
  #
87
- def wait_child( attributes = {}, timeout_secs = 10, retry_interval = 0.5 )
87
+ def wait_child( attributes = {}, timeout = 10, retry_interval = 0.5 )
88
88
 
89
89
  # verify that attributes is type of Hash
90
90
  attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
@@ -96,7 +96,7 @@ module MobyBehaviour
96
96
  attributes[ :type ].not_empty( "Attribute :type must not be empty" )
97
97
 
98
98
  # verify timeout type is numeric
99
- timeout_secs.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for timeout (expected $2)" )
99
+ timeout.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for timeout (expected $2)" )
100
100
 
101
101
  # verify timeout type is numeric
102
102
  retry_interval.check_type( [ Integer, Fixnum, Float ], "Wrong argument type $1 for retry interval (expected $2)" )
@@ -109,7 +109,7 @@ module MobyBehaviour
109
109
  @test_object_factory.identify_object(
110
110
  :object_attributes_hash => attributes,
111
111
  :identification_directives => dynamic_attributes.default_values(
112
- :__timeout => timeout_secs,
112
+ :__timeout => timeout,
113
113
  :__retry_interval => retry_interval,
114
114
  :__refresh_arguments => self.kind_of?( MobyBase::SUT ) ? attributes : { :id => self.get_application_id }
115
115
  ),
@@ -119,8 +119,12 @@ module MobyBehaviour
119
119
  rescue MobyBase::TestObjectNotFoundError
120
120
 
121
121
  # the child object was not found in the specified timeout
122
- raise MobyBase::SyncTimeoutError, "Synchronization timed out (#{ timeout_secs }) before the defined child object could be found."
123
-
122
+ raise MobyBase::SyncTimeoutError, "Synchronization timed out (#{ timeout }) before the defined child object could be found."
123
+
124
+ rescue MobyBase::ApplicationNotAvailableError
125
+
126
+ raise
127
+
124
128
  rescue # unexpected errors
125
129
 
126
130
  raise RuntimeError, "Synchronization failed due to #{ $!.message } (#{ $!.class })"
@@ -99,9 +99,6 @@ module MobyBehaviour
99
99
  # attributes_hash = @test_app.Triangle( :name => 'Triangle1' ).attributes # retrieve all attribute for triangle object
100
100
  def attributes
101
101
 
102
- # retrieve sut parameters
103
- sut_parameters = $parameters[ @sut.id ]
104
-
105
102
  # retrieve sut attribute filter type
106
103
  filter_type = sut_parameters[ :filter_type, 'none' ]
107
104
 
@@ -145,7 +142,7 @@ module MobyBehaviour
145
142
  end
146
143
 
147
144
  # return hash of test object attributes
148
- TDriver::TestObjectAdapter.test_object_attributes( _xml_data )
145
+ @test_object_adapter.test_object_attributes( _xml_data )
149
146
 
150
147
  end
151
148
 
@@ -206,10 +203,10 @@ module MobyBehaviour
206
203
  @sut.refresh if disable_optimizer
207
204
 
208
205
  # retrieve parent of current xml element; objects/object/objects/object/../..
209
- parent_element = TDriver::TestObjectAdapter.parent_test_object_element( self )
206
+ parent_element = @test_object_adapter.parent_test_object_element( self )
210
207
 
211
208
  # retrieve parent element attributes
212
- parent_attributes = TDriver::TestObjectAdapter.test_object_element_attributes( parent_element )
209
+ parent_attributes = @test_object_adapter.test_object_element_attributes( parent_element )
213
210
 
214
211
  if self.get_application_id && parent_attributes[ 'type' ] != 'application'
215
212
 
@@ -253,9 +250,20 @@ module MobyBehaviour
253
250
  # @sut.refresh might have a side effect that changes the @_active instance variable.
254
251
  # === raises
255
252
  # TestObjectNotFoundError:: if TestObject is not identified within synch timeout.
256
- def refresh( refresh_args = {} )
253
+ def refresh( refresh_args = nil )
254
+
255
+ refresh_args = @creation_attributes if refresh_args.nil?
256
+
257
+ refresh_args.check_type Hash, "wrong argument type $1 for #{ application? ? 'application' : 'test object' } refresh attributes (expected $2)"
258
+
259
+ @sut.refresh(
260
+
261
+ refresh_args, @test_object_factory.make_object_search_params( parent, @creation_attributes )
262
+
263
+ )
257
264
 
258
- @sut.refresh( refresh_args, @test_object_factory.make_object_search_params( parent, @creation_attributes ) )
265
+ # update childs if required, returns true or false
266
+ update( xml_data )
259
267
 
260
268
  end
261
269
 
@@ -269,7 +277,9 @@ module MobyBehaviour
269
277
  # @sut.force_refresh might have a side effect that changes the @_active instance variable.
270
278
  # === raises
271
279
  # TestObjectNotFoundError:: if TestObject is not identified within synch timeout.
272
- def force_refresh( refresh_args = {} )
280
+ def force_refresh( refresh_args = nil )
281
+
282
+ refresh_args = @creation_attributes if refresh_args.nil?
273
283
 
274
284
  refresh( refresh_args )
275
285
 
@@ -332,22 +342,30 @@ module MobyBehaviour
332
342
  end
333
343
 
334
344
  # == description
335
- # Returns a StateObject containing the current state of this test object as XML.
336
- # The state object is static and thus is not refreshed or synchronized etc.
345
+ # Returns a StateObject containing the current state of this test object as XML. The state object is static and thus is not refreshed or synchronized etc.
346
+ #
337
347
  # == returns
338
348
  # StateObject
339
349
  # description: State of this test object
340
350
  # example: -
351
+ #
341
352
  # == exceptions
342
353
  # ArgumentError
343
354
  # description: If the xml source for the object cannot be read
344
- # == example
345
- # app_state = @sut.application( :name => "calculator" ).state #get the state object for the app
346
- # button_state = app_state.Button( :text => "Backspace" ) #get the state for test object button
347
- # button_text = button_state.attribute( "text" ) #get attribute text from the button state object
348
- def state
355
+ def state_object
349
356
 
350
- MobyBase::StateObject.new( xml_data, self )
357
+ # == example
358
+ # app_state = @sut.application( :name => "calculator" ).state #get the state object for the app
359
+ # button_state = app_state.Button( :text => "Backspace" ) #get the state for test object button
360
+ # button_text = button_state.attribute( "text" ) #get attribute text from the button state object
361
+
362
+ MobyBase::StateObject.new(
363
+
364
+ :source_data => xml_data,
365
+ :parent => self,
366
+ :test_object_adapter => @test_object_adapter
367
+
368
+ )
351
369
 
352
370
  end
353
371
 
@@ -433,16 +451,16 @@ module MobyBehaviour
433
451
  attributes[ :type ] = '*' if attributes.select{ | key, value | key.to_s !~ /^__/ ? true : false }.empty?
434
452
 
435
453
  # children method specific settings
436
- attributes.merge!( :__multiple_objects => true, :__find_all_children => find_all_children )
454
+ attributes.merge!( :__multiple_objects => true, :__find_all_children => find_all_children, :__no_caching => true )
437
455
 
438
456
  # disable optimizer state if enabled
439
- disable_optimizer
457
+ #disable_optimizer -> leave it on, tuukka if breaks take it back...
440
458
 
441
459
  # retrieve child objects
442
460
  result = get_child_objects( attributes )
443
461
 
444
462
  # restore optimizer state if it was enabled
445
- enable_optimizer
463
+ #enable_optimizer
446
464
 
447
465
  # return results
448
466
  result
@@ -466,7 +484,7 @@ module MobyBehaviour
466
484
  begin
467
485
 
468
486
  # find object from new xml data
469
- _xml_data, unused_rule = TDriver::TestObjectAdapter.get_objects( xml_document, { :type => @type, :id => @id, :name => @name }, true )
487
+ _xml_data, unused_rule = @test_object_adapter.get_objects( xml_document, { :type => @type, :id => @id, :name => @name }, true )
470
488
 
471
489
  # deactivate if test object not found or multiple matches found
472
490
  raise unless _xml_data.count == 1
@@ -488,11 +506,14 @@ module MobyBehaviour
488
506
  # remove cached behaviour module
489
507
  MobyBase::BehaviourFactory.instance.reset_modules_cache
490
508
 
509
+ # apply only application behaviours if test object is type of 'application'
510
+ object_type = ( @type == "application" ? [ @type ] : [ '*', @type ] )
511
+
491
512
  # reapply behaviours to test object if environment value has changed
492
513
  MobyBase::BehaviourFactory.instance.apply_behaviour!(
493
514
 
494
515
  :object => self,
495
- :object_type => [ '*', @type ],
516
+ :object_type => object_type,
496
517
  :input_type => [ '*', @sut.input.to_s ],
497
518
  :env => [ '*', *@env.to_s.split(";") ],
498
519
  :version => [ '*', @sut.ui_version.to_s ]
@@ -524,8 +545,6 @@ module MobyBehaviour
524
545
  # TODO: document me
525
546
  def disable_optimizer
526
547
 
527
- sut_parameters = $parameters[ @sut.id ]
528
-
529
548
  # disable optimizer for this call since it will not work
530
549
  @_enable_optimizer = false
531
550
 
@@ -544,7 +563,7 @@ module MobyBehaviour
544
563
  # TODO: document me
545
564
  def enable_optimizer
546
565
 
547
- $parameters[ @sut.id ][ :use_find_object ] = 'true' if @_enable_optimizer
566
+ sut_parameters[ :use_find_object ] = 'true' if @_enable_optimizer
548
567
 
549
568
  @_enable_optimizer = false
550
569
 
@@ -561,7 +580,7 @@ module MobyBehaviour
561
580
  rules_hash = {} unless rules_hash.kind_of?( Hash )
562
581
 
563
582
  # set test object type
564
- rules_hash[ :type ] = method_id #.to_s
583
+ rules_hash[ :type ] = method_id.to_s
565
584
 
566
585
  begin
567
586
 
@@ -753,13 +772,13 @@ module MobyBehaviour
753
772
 
754
773
  refresh_args = ( attributes[ :type ] == 'application' ? { :name => attributes[ :name ], :id => attributes[ :id ] } : { :id => get_application_id } )
755
774
 
756
- refresh( refresh_args)
775
+ refresh( refresh_args )
757
776
 
758
777
  begin
759
778
 
760
779
  @parent.child( :type => @type, :id => @id )
761
780
 
762
- rescue MobyBase::TestObjectNotFoundError => exception
781
+ rescue MobyBase::TestObjectNotFoundError
763
782
 
764
783
  Kernel::raise MobyBase::TestObjectNotVisibleError
765
784
 
@@ -809,8 +828,14 @@ module MobyBehaviour
809
828
 
810
829
  end
811
830
 
812
- #lets refresh if attribute not found on first attempt
813
- refresh( refresh_args )
831
+ #refresh( refresh_args )
832
+
833
+ # lets refresh if attribute not found on first attempt
834
+ @sut.refresh(
835
+
836
+ refresh_args, @test_object_factory.make_object_search_params( parent, @creation_attributes )
837
+
838
+ )
814
839
 
815
840
  # retrieve updated xml data
816
841
  _xml_data = xml_data
@@ -818,18 +843,16 @@ module MobyBehaviour
818
843
  end
819
844
 
820
845
  # raise eception if xml data is empty or nil
821
- Kernel::raise MobyBase::TestObjectNotInitializedError.new if _xml_data.nil? || _xml_data.to_s.empty?
846
+ raise MobyBase::TestObjectNotInitializedError.new if _xml_data.nil? || _xml_data.to_s.empty?
822
847
 
823
848
  begin
824
849
 
825
850
  # retrieve attribute(s) from test object; never access ui state xml data directly from behaviour implementation
826
- TDriver::TestObjectAdapter.test_object_attribute( _xml_data, name )
851
+ @test_object_adapter.test_object_attribute( _xml_data, name )
827
852
 
828
853
  rescue MobyBase::AttributeNotFoundError
829
854
 
830
- Kernel::raise MobyBase::AttributeNotFoundError.new(
831
- "Could not find attribute #{ name.inspect } for test object of type #{ @type.to_s }"
832
- )
855
+ raise MobyBase::AttributeNotFoundError, "Could not find attribute #{ name.inspect } for test object of type #{ @type.to_s }"
833
856
 
834
857
  end
835
858
 
@@ -855,20 +878,19 @@ module MobyBehaviour
855
878
 
856
879
  end
857
880
 
858
- # this method will be automatically invoked after module is extended to sut object
881
+ # this method will be automatically invoked after module is extended to target object
859
882
  def self.extended( target_object )
860
883
 
861
884
  target_object.instance_exec{
862
885
 
863
- # initialize cache object
864
- @child_object_cache = TDriver::TestObjectCache.new
865
-
866
- @parent_application = nil
867
-
868
886
  # defaults
869
- @_application_id = nil
870
- @creation_attributes = nil
871
- @_active = true
887
+ @_application_id ||= nil
888
+
889
+ @creation_attributes ||= nil
890
+
891
+ @_active ||= true
892
+
893
+ @parent_application ||= nil
872
894
 
873
895
  }
874
896
 
@@ -883,7 +905,7 @@ module MobyBehaviour
883
905
  # == description
884
906
  # This method is deprecated, please use TestObject#parent
885
907
  #
886
- def parent_object()
908
+ def parent_object
887
909
 
888
910
  # == description
889
911
  # Returns the actual test object that was used as the parent when this object instance was created.
@@ -892,13 +914,28 @@ module MobyBehaviour
892
914
  #
893
915
  # == returns
894
916
  # TestObject:: test object that was used as parent when this object was created. Can also be of type SUT if sut was the parent (ie. application objects)
895
-
896
- $stderr.puts "warning: TestObject#parent_object is deprecated, please use TestObject#parent instead."
917
+
918
+ warn_caller '$1:$2 warning: TestObject#parent_object is deprecated, please use TestObject#parent instead.'
897
919
 
898
920
  @parent
899
921
 
900
922
  end
901
923
 
924
+ # This method is deprecated, please use [link="#GenericTestObject:state_object"]TestObject#state_object[/link] instead.
925
+ # == deprecated
926
+ # 1.1.1
927
+ #
928
+ # == description
929
+ # This method is deprecated, please use TestObject#state_object
930
+ #
931
+ def state
932
+
933
+ warn_caller '$1:$2 warning: deprecated method TestObject#state; please use TestObject#state_object instead'
934
+
935
+ state_object
936
+
937
+ end
938
+
902
939
  # enable hooking for performance measurement & debug logging
903
940
  TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
904
941