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
@@ -23,6 +23,32 @@ module MobyController
23
23
  # Abstract class SutAdapter. Not supposed to be instantiated as is
24
24
  class SutAdapter
25
25
 
26
+ def add_hook( id, &block )
27
+
28
+ raise ArgumentError, 'Unable to add hook due to no block was given' unless block_given?
29
+ @hooks = {} unless @hooks
30
+ @hooks[ id ] = block
31
+
32
+ end
33
+
34
+ private
35
+
36
+ # TODO: document me
37
+ def execute_hook( id, *arguments )
38
+
39
+ @hooks[ id ].call( *arguments )
40
+
41
+ end
42
+
43
+ # TODO: document me
44
+ def hooked? ( id )
45
+ @hooks = {} unless @hooks
46
+ @hooks.has_key?( id )
47
+
48
+ end
49
+
50
+
51
+
26
52
  end # SutAdapter
27
53
 
28
54
  end # MobyController
@@ -21,7 +21,7 @@ module MobyBase
21
21
 
22
22
  class SutController
23
23
 
24
- attr_accessor :sut_controllers, :execution_order
24
+ attr_accessor :sut_controllers, :execution_order #, :test_object_adapter, :test_object_factory
25
25
 
26
26
  # Creating new SutController associates SutAdapter to the controller
27
27
  # == params
@@ -135,42 +135,23 @@ module MobyBehaviour
135
135
  close_options[ :force_kill ] = close_options[ :force_kill ].to_boolean if close_options[ :force_kill ].kind_of?( String )
136
136
 
137
137
  # verify :force_kill value type
138
- close_options[ :force_kill ].check_type( [ NilClass, TrueClass, FalseClass ], "Wrong argument type $1 for :force_kill (expected $2)" )
138
+ close_options[ :force_kill ].check_type( [ NilClass, TrueClass, FalseClass ], 'Wrong argument type $1 for :force_kill (expected $2)' )
139
139
 
140
140
  # workaround/backwards compatibility: allow string as hash key value
141
141
  close_options[ :check_process ] = close_options[ :check_process ].to_boolean if close_options[ :check_process ].kind_of?( String )
142
142
 
143
143
  # verify :check_process value type
144
- close_options[ :check_process ].check_type( [ TrueClass, FalseClass ], "Wrong argument type $1 for :check_process (expected $2)" )
144
+ close_options[ :check_process ].check_type( [ TrueClass, FalseClass ], 'Wrong argument type $1 for :check_process (expected $2)' )
145
145
 
146
146
  if close_options[ :force_kill ] != nil
147
147
 
148
- =begin
149
148
  @sut.execute_command(
150
149
  MobyCommand::Application.new(
151
- :Close, # command_type
152
- self.name, # app_name
153
- self.uid, # app_uid
154
- self.sut, # sut
155
- nil, # arguments
156
- nil, # environment
157
- nil, # working directory
158
- nil, # events_to_listen
159
- nil, # signals_to_listen
160
- { # flags
161
- :force_kill => close_options[ :force_kill ]
162
- }
163
- )
164
- )
165
- =end
166
-
167
- @sut.execute_command(
168
- MobyCommand::Application.new(
169
- :Close, # command_type
150
+ :Close,
170
151
  {
171
- :application_name => self.name,
172
- :application_uid => self.uid,
173
- :sut => self.sut,
152
+ :application_name => @name,
153
+ :application_uid => @id,
154
+ :sut => @sut,
174
155
  :flags => { :force_kill => close_options[ :force_kill ] }
175
156
  }
176
157
  )
@@ -178,24 +159,13 @@ module MobyBehaviour
178
159
 
179
160
  else
180
161
 
181
- =begin
182
- @sut.execute_command(
183
- MobyCommand::Application.new(
184
- :Close,
185
- self.name,
186
- self.uid,
187
- self.sut
188
- )
189
- )
190
- =end
191
-
192
162
  @sut.execute_command(
193
163
  MobyCommand::Application.new(
194
164
  :Close,
195
165
  {
196
- :application_name => self.name,
197
- :application_uid => self.uid,
198
- :sut => self.sut
166
+ :application_name => @name,
167
+ :application_uid => @id,
168
+ :sut => @sut
199
169
  }
200
170
  )
201
171
  )
@@ -212,7 +182,10 @@ module MobyBehaviour
212
182
  $logger.enabled = false
213
183
 
214
184
  # retrieve application synchronization timeout value
215
- timeout_time = $parameters[ self.sut.id ][ :application_synchronization_timeout, '60' ].to_f
185
+ timeout_time = sut_parameters[ :application_synchronization_timeout, '60' ].to_f
186
+
187
+ # retrieve application synchronization timeout retry interval value
188
+ refresh_interval = sut_parameters[ :application_synchronization_retry_interval, '0.25' ].to_f
216
189
 
217
190
  # create application identification hash
218
191
  application_identification_hash = { :type => 'application', :id => @id }
@@ -222,7 +195,7 @@ module MobyBehaviour
222
195
  # verify close results
223
196
  MobyUtil::Retryable.until(
224
197
  :timeout => timeout_time,
225
- :interval => $parameters[ self.sut.id ][ :application_synchronization_retry_interval, '0.25' ].to_f,
198
+ :interval => refresh_interval,
226
199
  :exception => MobyBase::VerificationError,
227
200
  :unless => [ MobyBase::TestObjectNotFoundError, MobyBase::ApplicationNotAvailableError ]
228
201
  ){
@@ -231,7 +204,7 @@ module MobyBehaviour
231
204
  @sut.refresh( application_identification_hash, [ {:className => 'application', :tasId => @id } ] )
232
205
 
233
206
  # retrieve application object from sut.xml_data
234
- matches, unused_rule = TDriver::TestObjectAdapter.get_objects( @sut.xml_data, application_identification_hash, true )
207
+ matches, unused_rule = @test_object_adapter.get_objects( @sut.xml_data, application_identification_hash, true )
235
208
 
236
209
  # check if the application is still found or not
237
210
  if ( close_options[ :check_process ] == true )
@@ -243,7 +216,7 @@ module MobyBehaviour
243
216
 
244
217
  if matches.count > 0
245
218
 
246
- if TDriver::TestObjectAdapter.test_object_element_attribute( matches.first, 'id' ) == @id
219
+ if @test_object_adapter.test_object_element_attribute( matches.first, 'id' ) == @id
247
220
 
248
221
  # the application was still in the foreground
249
222
  raise MobyBase::VerificationError, "Verification of close failed. The application that was to be closed was still in the foreground."
@@ -316,25 +289,25 @@ module MobyBehaviour
316
289
 
317
290
  begin
318
291
 
319
- exe_name = self.attribute( 'FullName' ).to_s
292
+ name = attribute('FullName')
320
293
 
321
294
  rescue MobyBase::AttributeNotFoundError
322
295
 
323
296
  begin
324
297
 
325
- exe_name = self.attribute( 'exepath' ).to_s
298
+ name = attribute('exepath')
326
299
 
327
300
  rescue MobyBase::AttributeNotFoundError
328
301
 
329
- exe_name = ""
302
+ name = ''
330
303
 
331
304
  end
332
305
 
333
306
  end
334
307
 
335
- Kernel::raise RuntimeError.new( "Application does not have 'FullName' or 'exepath' attribute defined" ) if exe_name.empty?
308
+ name.not_empty 'Application does not have "FullName" or "exepath" attribute', RuntimeError
336
309
 
337
- File.basename( exe_name.gsub( /\\/, '/' ) )
310
+ File.basename( name.gsub( /\\/, '/' ) )
338
311
 
339
312
  end
340
313
 
@@ -348,7 +321,7 @@ module MobyBehaviour
348
321
  # puts @sut.application.uid #prints foreground executable uid to console
349
322
  def uid
350
323
 
351
- id
324
+ @id
352
325
 
353
326
  end
354
327
 
@@ -377,79 +350,77 @@ module MobyBehaviour
377
350
  true
378
351
 
379
352
  end
353
+
354
+ # == description
355
+ # Bring the application to foreground.\n
356
+ # \n
357
+ # [b]NOTE:[/b] Currently this works only for Symbian OS target!
358
+ #
359
+ # == returns
360
+ # NilClass
361
+ # description: -
362
+ # example: -
363
+ #
364
+ #
365
+ def bring_to_foreground
366
+
367
+ @sut.execute_command(
368
+ MobyCommand::Application.new(
369
+ :BringToForeground,
370
+ {
371
+ :application_uid => @id,
372
+ :sut => @sut
373
+ }
374
+ )
375
+ )
376
+
377
+ end
380
378
 
381
-
382
- # == description
383
- # Bring the application to foreground.\n
384
- # \n
385
- # [b]NOTE:[/b] Currently this works only for Symbian OS target!
386
- #
387
- # == returns
388
- # NilClass
389
- # description: -
390
- # example: -
391
- #
392
- #
393
- def bring_to_foreground
394
-
395
- #@sut.execute_command(MobyCommand::Application.new(:BringToForeground, nil, self.uid, self.sut))
396
-
397
- @sut.execute_command(
398
- MobyCommand::Application.new(
399
- :BringToForeground,
400
- {
401
- :application_uid => self.uid,
402
- :sut => self.sut
403
- }
379
+ # == description
380
+ # Kills the application process
381
+ #
382
+ # == returns
383
+ # NilClass
384
+ # description: -
385
+ # example: -
386
+ #
387
+ def kill
388
+
389
+ @sut.execute_command(
390
+ MobyCommand::Application.new(
391
+ :Kill,
392
+ {
393
+ :application_name => executable_name,
394
+ :application_uid => @id,
395
+ :sut => @sut
396
+ }
397
+ )
404
398
  )
405
- )
406
-
407
- end
408
-
409
- # == description
410
- # Kills the application process
411
- #
412
- # == returns
413
- # NilClass
414
- # description: -
415
- # example: -
416
- #
417
- def kill
418
-
419
- #@sut.execute_command( MobyCommand::Application.new( :Kill, self.executable_name, self.uid, self.sut ) )
420
-
421
- @sut.execute_command(
422
- MobyCommand::Application.new(
423
- :Kill,
424
- {
425
- :application_name => self.executable_name,
426
- :application_uid => self.uid,
427
- :sut => self.sut
428
- }
429
- )
430
- )
431
-
432
-
433
- end
434
-
435
- # == description
436
- # Returns the mem usage of the application if the information is available.
437
- # Will return -1 if the information is not available.
438
- #
439
- # == returns
440
- # Integer
441
- # description: Current memory usage
442
- # example: 124354
443
- #
444
- def mem_usage
445
- mem = -1
446
- begin
447
- mem = self.attribute('memUsage')
448
- rescue
399
+
449
400
  end
450
- mem
451
- end
452
401
 
402
+ # == description
403
+ # Returns the mem usage of the application if the information is available.
404
+ # Will return -1 if the information is not available.
405
+ #
406
+ # == returns
407
+ # Integer
408
+ # description: Current memory usage
409
+ # example: 124354
410
+ #
411
+ def mem_usage
412
+
413
+ begin
414
+
415
+ attribute('memUsage').to_i
416
+
417
+ rescue
418
+
419
+ -1
420
+
421
+ end
422
+
423
+ end
453
424
 
454
425
  # enable hooking for performance measurement & debug logging
455
426
  TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
@@ -21,82 +21,87 @@
21
21
  # Methods for finding test objects on the suttest objet state
22
22
  module MobyBehaviour
23
23
 
24
- # == description
25
- # This module contains generic find behaviour
26
- #
27
- # == behaviour
28
- # GenericFind
29
- #
30
- # == requires
31
- # *
32
- #
33
- # == input_type
34
- # *
35
- #
36
- # == sut_type
37
- # *
38
- #
39
- # == sut_version
40
- # *
41
- #
42
- # == objects
43
- # *;sut
44
- module Find
24
+ # == description
25
+ # This module contains generic find behaviour
26
+ #
27
+ # == behaviour
28
+ # GenericFind
29
+ #
30
+ # == requires
31
+ # *
32
+ #
33
+ # == input_type
34
+ # *
35
+ #
36
+ # == sut_type
37
+ # *
38
+ #
39
+ # == sut_version
40
+ # *
41
+ #
42
+ # == objects
43
+ # *;sut
44
+ module Find
45
+
46
+ include MobyBehaviour::Behaviour
45
47
 
46
- include MobyBehaviour::Behaviour
47
48
  # == nodoc
48
- # == description
49
- # Finds a child test_object given its name and type and returns it as a reference
50
- #
51
- # == arguments
52
- # attributes
53
- # Hash
54
- # description: one or more attributes defining the rules for the test object search. Must not be empty.
55
- # example: { :name => 'oneButton' }
56
- # default: {}
57
- #
58
- # == returns
59
- # MobyBase::TestObject
60
- # description: found test object
49
+ # == description
50
+ # Finds a child test_object given its name and type and returns it as a reference
51
+ #
52
+ # == arguments
53
+ # attributes
54
+ # Hash
55
+ # description: one or more attributes defining the rules for the test object search. Must not be empty.
56
+ # example: { :name => 'oneButton' }
57
+ # default: {}
58
+ #
59
+ # == returns
60
+ # MobyBase::TestObject
61
+ # description: found test object
61
62
  # example: -
62
- #
63
- # == exceptions
64
- # TypeError
65
- # description: Wrong argument type %s for attributes (expected Hash)
66
- #
67
- # ArgumentError
68
- # description: Attributes hash must not be empty
69
- #
70
- # == info
71
- # Same as calling child method.
72
- def find( attributes = {} )
63
+ #
64
+ # == exceptions
65
+ # TypeError
66
+ # description: Wrong argument type %s for attributes (expected Hash)
67
+ #
68
+ # ArgumentError
69
+ # description: Attributes hash must not be empty
70
+ #
71
+ # == info
72
+ # Same as calling child method.
73
+ def find( attributes = {} )
73
74
 
74
- begin
75
+ begin
75
76
 
76
- attributes.check_type( Hash, "Wrong argument type $1 for attributes (expected $2)" )
77
+ # verify that attributes argument type is correct
78
+ attributes.check_type Hash, 'Wrong argument type $1 for attributes (expected $2)'
77
79
 
78
- attributes.not_empty( 'Attributes hash must not be empty' )
79
-
80
- #raise ArgumentError.new( 'Attributes hash must not be empty' ) if attributes.empty?
80
+ # verify that attributes hash is not empty
81
+ attributes.not_empty 'Attributes hash must not be empty'
81
82
 
82
- search_result = child( attributes )
83
+ # retrieve desired object
84
+ result = child( attributes )
85
+
86
+ rescue
83
87
 
84
- rescue Exception => e
88
+ $logger.behaviour "FAIL;Failed to find test object.;#{ id.to_s };sut;{};find;#{ attributes.kind_of?( Hash ) ? attributes.inspect : attributes.class.to_s }"
85
89
 
86
- $logger.log "behaviour", "FAIL;Failed to find test object.;#{id.to_s};sut;{};find;" << ( attributes.kind_of?( Hash ) ? attributes.inspect : attributes.class.to_s )
90
+ # raise original exception
91
+ raise
87
92
 
88
- Kernel::raise e
93
+ end
89
94
 
90
- end
95
+ $logger.behaviour "PASS;Test object found.;#{ id.to_s };sut;{};application;#{ attributes.inspect }"
91
96
 
92
- $logger.log "behaviour", "PASS;Test object found.;#{id.to_s};sut;{};application;" << attributes.inspect
97
+ # pass the result object
98
+ result
93
99
 
94
- search_result
95
- end
100
+ end
96
101
 
97
- # enable hooking for performance measurement & debug logging
98
- TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
102
+ # enable hooking for performance measurement & debug logging
103
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
99
104
 
100
- end # Find
105
+ end # Find
101
106
 
102
107
  end # MobyBehaviour