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.
Files changed (108) hide show
  1. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +1 -1
  2. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +11 -7
  3. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +8 -0
  4. data/lib/tdriver/base/behaviour/factory.rb +229 -209
  5. data/lib/tdriver/base/errors.rb +3 -0
  6. data/lib/tdriver/base/state_object.rb +11 -20
  7. data/lib/tdriver/base/sut/controller.rb +4 -4
  8. data/lib/tdriver/base/sut/factory.rb +205 -170
  9. data/lib/tdriver/base/sut/generic/behaviours/application.rb +256 -174
  10. data/lib/tdriver/base/sut/generic/behaviours/find.rb +17 -11
  11. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +57 -66
  12. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +578 -497
  13. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +41 -15
  14. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +48 -19
  15. data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
  16. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +25 -13
  17. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +16 -10
  18. data/lib/tdriver/base/sut/generic/plugin.rb +9 -3
  19. data/lib/tdriver/base/sut/sut.rb +41 -33
  20. data/lib/tdriver/base/test_object/abstract.rb +26 -3
  21. data/lib/tdriver/base/test_object/adapter.rb +399 -0
  22. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +56 -14
  23. data/lib/tdriver/base/test_object/behaviours/test_object.rb +663 -197
  24. data/lib/tdriver/base/test_object/cache.rb +132 -0
  25. data/lib/tdriver/base/test_object/factory.rb +677 -426
  26. data/lib/tdriver/base/test_object/factory_new.rb +202 -0
  27. data/lib/tdriver/base/test_object/identificator.rb +24 -17
  28. data/lib/tdriver/base/test_object/loader.rb +9 -3
  29. data/lib/tdriver/base/test_object/verification.rb +181 -0
  30. data/lib/tdriver/loader.rb +1 -1
  31. data/lib/tdriver/report/report.rb +2 -0
  32. data/lib/tdriver/report/report_api.rb +4 -4
  33. data/lib/tdriver/report/report_creator.rb +29 -3
  34. data/lib/tdriver/report/report_data_presentation.rb +7 -3
  35. data/lib/tdriver/report/report_execution_statistics.rb +80 -21
  36. data/lib/tdriver/report/report_javascript.rb +192 -0
  37. data/lib/tdriver/report/report_test_case_run.rb +22 -0
  38. data/lib/tdriver/report/report_test_run.rb +62 -55
  39. data/lib/tdriver/report/report_writer.rb +57 -56
  40. data/lib/tdriver/tdriver.rb +14 -41
  41. data/lib/tdriver/util/common/error.rb +1 -0
  42. data/lib/tdriver/util/common/exceptions.rb +12 -0
  43. data/lib/tdriver/util/common/file.rb +12 -6
  44. data/lib/tdriver/util/common/gem.rb +2 -1
  45. data/lib/tdriver/util/common/hash.rb +152 -0
  46. data/lib/tdriver/util/common/kernel.rb +49 -34
  47. data/lib/tdriver/util/common/loader.rb +21 -17
  48. data/lib/tdriver/util/common/numeric.rb +39 -0
  49. data/lib/tdriver/util/common/object.rb +115 -0
  50. data/lib/tdriver/util/common/string.rb +55 -2
  51. data/lib/tdriver/util/dbaccess/dbaccess.rb +194 -161
  52. data/lib/tdriver/util/dynamic_attribute_filter.rb +6 -0
  53. data/lib/tdriver/util/hooking.rb +2 -2
  54. data/lib/tdriver/util/loader.rb +2 -2
  55. data/lib/tdriver/util/localisation/localisation.rb +277 -18
  56. data/lib/tdriver/util/logger.rb +142 -13
  57. data/lib/tdriver/util/parameter/parameter_hash.rb +8 -5
  58. data/lib/tdriver/util/parameter/parameter_xml.rb +18 -2
  59. data/lib/tdriver/util/recorder.rb +17 -12
  60. data/lib/tdriver/util/user_data/user_data.rb +3 -2
  61. data/lib/tdriver/util/{video_rec.rb → video_utils.rb} +136 -16
  62. data/lib/tdriver/util/xml/abstraction.rb +7 -0
  63. data/lib/tdriver/util/xml/attribute.rb +32 -0
  64. data/lib/tdriver/util/xml/loader.rb +8 -2
  65. data/lib/tdriver/util/xml/nil_node.rb +95 -0
  66. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +46 -7
  67. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +19 -9
  68. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +1 -1
  69. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +13 -1
  70. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +6 -0
  71. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +27 -15
  72. data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +57 -0
  73. data/lib/tdriver/util/xml/text.rb +32 -0
  74. data/lib/tdriver/util/xml/xml.rb +35 -22
  75. data/lib/tdriver/version.rb +1 -1
  76. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +41 -34
  77. data/lib/tdriver-devtools/doc/generate.rb +31 -6
  78. data/lib/tdriver-devtools/doc/xslt/template.xsl +46 -25
  79. data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
  80. data/lib/tdriver-devtools/tests/feature_tests/update +1 -1
  81. data/lib/tdriver.rb +0 -3
  82. data/xml/behaviours/generic.xml +1 -1
  83. data/xml/defaults/generic.xml +4 -90
  84. data/xml/templates/generic.xml +33 -25
  85. metadata +21 -29
  86. data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +0 -245
  87. data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +0 -964
  88. data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +0 -68
  89. data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +0 -1865
  90. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +0 -1
  91. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +0 -3
  92. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +0 -4
  93. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +0 -4
  94. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +0 -4
  95. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +0 -3
  96. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +0 -3
  97. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +0 -1
  98. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +0 -3
  99. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +0 -3
  100. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +0 -12
  101. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +0 -5
  102. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +0 -1
  103. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +0 -2
  104. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +0 -7
  105. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +0 -14
  106. data/lib/tdriver-devtools/behaviour/xml_generator/update +0 -3
  107. data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +0 -233
  108. data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +0 -194
@@ -23,7 +23,8 @@ module MobyUtil
23
23
 
24
24
  def initialize( hash = {} )
25
25
 
26
- Kernel::raise ArgumentError.new( "Unexpected argument type %s, expecting Hash or ParameterHash" % [ hash.class ] ) unless [ Hash, ParameterHash ].include?( hash.class )
26
+ #Kernel::raise ArgumentError.new( "Unexpected argument type %s, expecting Hash or ParameterHash" % [ hash.class ] ) unless [ Hash, ParameterHash ].include?( hash.class )
27
+ hash.check_type( [ Hash, ParameterHash ], "Wrong argument type $1 for hash (expected $2)" )
27
28
 
28
29
  merge!(
29
30
 
@@ -72,13 +73,15 @@ module MobyUtil
72
73
  end
73
74
 
74
75
  # Merge this Hash with another, primary Hash. Any values found in the other hash will overwrite local values and any Hash values will be recursively merged.
75
- def merge_with_hash!( primary_hash )
76
+ def merge_with_hash!( other_hash )
76
77
 
77
- raise ArgumentError.new( "Unable to merge, the other Hash was not a Hash, it was of type \"" + primary_hash.class.to_s + "\"." ) unless primary_hash.kind_of?( Hash )
78
+ #raise ArgumentError.new( "Unable to merge, the other Hash was not a Hash, it was of type \"" + other_hash.class.to_s + "\"." ) unless other_hash.kind_of?( Hash )
78
79
 
79
- primary_hash.each_pair do | key, value |
80
+ other_hash.check_type( Hash, "Wrong argument type $1 for hash (expected $2)" )
80
81
 
81
- if ( self.has_key?( key ) && self[ key ].kind_of?( Hash ) ) and primary_hash[ key ].kind_of?( Hash )
82
+ other_hash.each_pair do | key, value |
83
+
84
+ if ( self.has_key?( key ) && self[ key ].kind_of?( Hash ) ) and other_hash[ key ].kind_of?( Hash )
82
85
 
83
86
  self[ key ].merge_with_hash!( value )
84
87
 
@@ -61,13 +61,20 @@ module MobyUtil
61
61
  # default results
62
62
  results = ParameterHash.new()
63
63
 
64
+ # retrieve platform name
65
+ platform = MobyUtil::EnvironmentHelper.platform
66
+
67
+ # detect is posix platform
68
+ is_posix = MobyUtil::EnvironmentHelper.posix?
69
+
64
70
  begin
71
+
65
72
  # create new xml document
66
73
  document = MobyUtil::XML::parse_string( xml )
67
74
 
68
75
  rescue Exception => exception
69
76
 
70
- Kernel::raise ParameterFileParseError.new( "Error occured while parsing XML. Reason %s (%s)" % [ exception.message, exception.class ] )
77
+ Kernel::raise ParameterFileParseError.new( "Error occured while parsing XML. Reason: %s (%s)" % [ exception.message, exception.class ] )
71
78
 
72
79
  end
73
80
 
@@ -77,18 +84,27 @@ module MobyUtil
77
84
  attribute = element.attributes.to_hash
78
85
 
79
86
  name = attribute[ "name" ].to_s
87
+
88
+ # default value
80
89
  value = attribute[ "value" ].to_s
81
90
 
91
+ # generic posix value - overwrites attribute["value"] if found
92
+ value = attribute["posix"].to_s unless attribute[ "posix" ].nil? if is_posix
93
+
94
+ # platform specific value - overwrites existing value
95
+ value = attribute[ platform.to_s ].to_s unless attribute[ platform.to_s ].nil?
96
+
82
97
  case element.name
83
98
 
84
99
  when 'fixture'
85
100
 
86
101
  plugin = attribute[ "plugin" ].to_s
102
+ env = attribute[ "env" ].to_s unless attribute[ "env" ].nil?
87
103
 
88
104
  Kernel::raise SyntaxError.new( "No name defined for fixture with value %s" % name ) if name.empty?
89
105
  Kernel::raise SyntaxError.new( "No plugin defined for fixture with name %s" % name ) if plugin.empty?
90
106
 
91
- value = plugin
107
+ value = {:plugin => plugin, :env => env}
92
108
 
93
109
  when 'parameter'
94
110
 
@@ -16,8 +16,6 @@
16
16
  ## of this file.
17
17
  ##
18
18
  ############################################################################
19
-
20
-
21
19
 
22
20
  # Class for recording scripts from qt applications.
23
21
  # Complete test script recording not supported.
@@ -29,26 +27,33 @@ module MobyUtil
29
27
  class Recorder
30
28
 
31
29
  #TODO detect app start for later versions...
32
- def self.start_rec(app)
30
+ def self.start_rec( app )
31
+
32
+ #Kernel::raise ArgumentError.new("Application must be defined.") unless app
33
+ app.check_type( MobyBase::TestObject, "Wrong argument type $1 for application object (expected $2)" )
33
34
 
34
- Kernel::raise ArgumentError.new("Application must be defined.") unless app
35
35
  app.start_recording
36
36
 
37
37
  end
38
38
 
39
39
  # Prints the recorded events as an tdriver script fragment.
40
- def self.print_script(sut, app, object_identificators = ['text','icontext','label'])
40
+ def self.print_script( sut, app, object_identificators = ['text','icontext','label'] )
41
+
42
+ # verify that sut type is type of MobyBase::SUT
43
+ #Kernel::raise ArgumentError.new("Sut must be defined.") unless sut
44
+ sut.check_type( MobyBase::SUT, "Wrong argument type $1 for SUT (expected $2)" )
41
45
 
42
- Kernel::raise ArgumentError.new("Sut must be defined.") unless sut
43
- Kernel::raise ArgumentError.new("Application must be defined.") unless app
44
- Kernel::raise ArgumentError.new("Object identificators must be set, use defaults if not sure what the use.") unless object_identificators
46
+ #Kernel::raise ArgumentError.new("Application must be defined.") unless app
47
+ app.check_type( MobyBase::TestObject, "Wrong argument type $1 for application object (expected $2)" )
45
48
 
49
+ #Kernel::raise ArgumentError.new("Object identificators must be set, use defaults if not sure what the use.") unless object_identificators
50
+ object_identificators.check_type( Array, "Wrong argument type $1 for object identificators (expected $2)" )
51
+
46
52
  xml_source = app.print_recordings
47
- app.stop_recording
48
- xml_as_object = MobyBase::StateObject.new( xml_source )
49
- scripter = Scripter.new(sut.id, object_identificators)
50
53
 
51
- scripter.write_fragment(xml_as_object, app.name)
54
+ app.stop_recording
55
+
56
+ Scripter.new( sut.id, object_identificators ).write_fragment( MobyBase::StateObject.new( xml_source ), app.name )
52
57
 
53
58
  end
54
59
 
@@ -39,7 +39,7 @@ module MobyUtil
39
39
  #
40
40
  # table_name
41
41
  # String
42
- # description: String containing the name of table to be used when user information
42
+ # description: Optional string containing the name of table to be used when user information, if empty the parameter user_data_server_database_tablename will be used
43
43
  # example: "user_data_week201042"
44
44
  #
45
45
  # == returns
@@ -59,7 +59,7 @@ module MobyUtil
59
59
  # SqlError
60
60
  # description: If there is and sql error while executing the query
61
61
  #
62
- def self.retrieve( user_data_lname, language, table_name )
62
+ def self.retrieve( user_data_lname, language, table_name = nil )
63
63
 
64
64
  Kernel::raise UserDataNotFoundError.new( "User data logical name can't be empty" ) if user_data_lname == nil
65
65
 
@@ -69,6 +69,7 @@ module MobyUtil
69
69
  username = MobyUtil::Parameter[ :user_data_server_username ]
70
70
  password = MobyUtil::Parameter[ :user_data_server_password ]
71
71
  database_name = MobyUtil::Parameter[ :user_data_server_database_name ]
72
+ table_name = MobyUtil::Parameter[:user_data_server_database_tablename] if table_name.nil? or table_name.empty?
72
73
 
73
74
  db_connection = DBConnection.new( db_type, host, database_name, username, password )
74
75
 
@@ -69,23 +69,35 @@ module MobyUtil
69
69
  # Creates a new recroding object witdh the given recording options
70
70
  # === params
71
71
  # video_file: String, path and name of file where the recorded video is stored
72
- # user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
72
+ # user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
73
73
  def initialize( video_file, user_options = {} )
74
74
 
75
- begin
76
- require 'Win32API'
77
- #OSCARWEBCAMCONTROL_API long OscarWebCamControlStartEx(char* captureFile, double compQuality, DWORD dwBitsPerSec, long lFramesPerSec, long lCapWidth, long lCapHeight, bool bFlipV, bool bFlipH)
78
- @_owcc_startex = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStartEx', [ 'P', 'N', 'N', 'N', 'L', 'L', 'L', 'I', 'I' ], 'L' )
79
- #OSCARWEBCAMCONTROL_API void OscarWebCamControlStop(long pTargetMediaControl)
80
- @_owcc_stop = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStop', [ 'L' ], 'V' )
81
- rescue Exception => e
82
- raise RuntimeError.new( "Failed to connect to video recording DLL file (OscarWebCamControl.dll). Details:\n" + e.message )
83
- end
84
-
85
- if user_options.has_key? :device
86
- puts "WARNING: TDriverWinCam does not support the :device option. This setting is ignored."
87
- end
88
-
75
+ require 'Win32API'
76
+
77
+ begin
78
+
79
+ @_owcc_startex = Win32API.new( 'TDriverWebCamControl', 'OscarWebCamControlStartEx', [ 'P', 'N', 'N', 'N', 'L', 'L', 'L', 'I', 'I' ], 'L' )
80
+ @_owcc_stop = Win32API.new( 'TDriverWebCamControl', 'OscarWebCamControlStop', [ 'L' ], 'V' )
81
+
82
+ rescue Exception => e
83
+
84
+ begin
85
+
86
+ #OSCARWEBCAMCONTROL_API long OscarWebCamControlStartEx(char* captureFile, double compQuality, DWORD dwBitsPerSec, long lFramesPerSec, long lCapWidth, long lCapHeight, bool bFlipV, bool bFlipH)
87
+ @_owcc_startex = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStartEx', [ 'P', 'N', 'N', 'N', 'L', 'L', 'L', 'I', 'I' ], 'L' )
88
+ #OSCARWEBCAMCONTROL_API void OscarWebCamControlStop(long pTargetMediaControl)
89
+ @_owcc_stop = Win32API.new( 'OscarWebCamControl', 'OscarWebCamControlStop', [ 'L' ], 'V' )
90
+
91
+ rescue Exception => ee
92
+ raise RuntimeError.new( "Failed to connect to video recording DLL file (TDriverWebCamControl.dll or OscarWebCamControl.dll). Details:\n" + ee.message )
93
+ end
94
+
95
+ end
96
+
97
+ if user_options.has_key? :device
98
+ puts "WARNING: TDriverWinCam does not support the :device option. This setting is ignored."
99
+ end
100
+
89
101
  @_control_id = nil
90
102
  @_video_file = video_file
91
103
  @_rec_options = DEFAULT_OPTIONS.merge user_options
@@ -183,7 +195,7 @@ module MobyUtil
183
195
  # Creates a new recroding object witdh the given recording options
184
196
  # === params
185
197
  # video_file: String, path and name of file where the recorded video is stored
186
- # user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
198
+ # user_options: (optional) Hash, keys :fps, :width, :height can be used to overwrite defaults
187
199
  def initialize( video_file, user_options = {} )
188
200
 
189
201
  @_control_id = nil
@@ -261,4 +273,112 @@ module MobyUtil
261
273
  end
262
274
 
263
275
  end #TDriverLinuxCam
276
+
277
+
278
+ # Checks if the target video contains enough activity to be considered active or static.
279
+ #
280
+ # === params
281
+ # in_target_video: String, Name and path of video file to analyze
282
+ # in_fps: (optional) Numeric, frames to be analyzed per second
283
+ # in_image_treshold: (optional) Numeric, minimum change between two frames for them to be considered different
284
+ # in_video_treshold: (optional) Numeric, Minimum percentage of frames with changes for the video to be considered alive.
285
+ # in_verbose: (optional) Boolean, True for verbose output including target video statistics
286
+ def self.video_alive?( in_target_video, in_fps = 1, in_image_treshold = 4, in_video_treshold = 35, in_verbose = false )
287
+
288
+ puts "Arguments fps: " << in_fps.inspect << " frame: " << in_image_treshold.inspect << " video: " << in_video_treshold.inspect if in_verbose
289
+ in_change = in_image_treshold / 100.0
290
+
291
+ alive_temp_folder = "temp_target_alive"
292
+
293
+ require 'rmagick'
294
+
295
+ raise ArgumentError.new( "The FPS argument must be an Interger or a Float, it was a #{ in_fps.class }." ) unless in_fps.kind_of? Numeric
296
+ raise ArgumentError.new( "The frame treshold argument must be an Interger or a Float, it was a #{ in_image_treshold.class }." ) unless in_image_treshold.kind_of? Numeric
297
+ raise ArgumentError.new( "The video treshold argument must be an Interger or a Float, it was a #{ in_video_treshold.class }." ) unless in_video_treshold.kind_of? Numeric
298
+
299
+ ts = Time.now if in_verbose
300
+
301
+ begin
302
+ FileUtils.remove_dir alive_temp_folder
303
+ rescue
304
+ # failed to remove dir, do nothing
305
+ end
306
+
307
+ begin
308
+ FileUtils.mkdir_p alive_temp_folder
309
+ rescue
310
+
311
+ end
312
+
313
+ begin
314
+ File.delete 'video_split.log' if File.exist? 'video_split.log'
315
+ rescue
316
+ end
317
+
318
+ if in_verbose
319
+ system('ffmpeg.exe -v 0 -i '+in_target_video.to_s+' -y -f image2 -r '+in_fps.to_s+' '+alive_temp_folder+'/frame-%05d.png')
320
+ else
321
+ system('ffmpeg.exe 2>video_split.log -v 0 -i '+in_target_video.to_s+' -y -f image2 -r '+in_fps.to_s+' '+alive_temp_folder+'/frame-%05d.png')
322
+ end
323
+
324
+ puts "Video processing duration: " << (Time.now - ts).to_s if in_verbose
325
+
326
+ t_start = Time.now
327
+
328
+ im_files = Dir.glob( alive_temp_folder + '/frame-*.png' )
329
+
330
+ raise RuntimeError.new( "No video frames found for analysis." ) if im_files.size == 0
331
+
332
+ d_max = 0.0
333
+ d_min = 1.0
334
+
335
+ d_sum = 0.0
336
+
337
+ dif_count = 0
338
+
339
+ pre_obj = Magick::ImageList.new(im_files[0])
340
+
341
+ (im_files.size-1).times do | im_index |
342
+
343
+ im_file = Magick::ImageList.new(im_files[ im_index ])
344
+ pre_file = pre_obj
345
+
346
+ dif = pre_file.compare_channel(im_file, Magick::RootMeanSquaredErrorMetric)[1]
347
+ if in_verbose
348
+ d_min = dif unless dif >= d_min
349
+ d_max = dif unless dif <= d_max
350
+ d_sum += dif
351
+ end
352
+ dif_count += 1 if dif > in_change
353
+ puts "Processing image: " << im_file.to_s << " I: " << (im_index+1).to_s << " C: " << dif.to_s if in_verbose
354
+
355
+ pre_obj = im_file
356
+
357
+ end
358
+
359
+ if in_verbose
360
+ puts "Max difference: " << d_max.to_s << "\nMin difference: " << d_min.to_s << "\n"
361
+ puts "Mean difference: " << (d_sum/im_files.size).to_s unless im_files.size == 0
362
+ puts "Count of images exceeding difference tolerance: " << dif_count.to_s
363
+
364
+ puts "Fraction of images exceeding difference tolerance: " << (dif_count.to_f/im_files.size).to_s unless im_files.size == 0
365
+ puts "Analysis duration: " << (Time.now - t_start).to_s
366
+ puts "Total duration: " << (Time.now - ts).to_s
367
+ end
368
+
369
+ begin
370
+ FileUtils.remove_dir alive_temp_folder
371
+ rescue
372
+ end
373
+
374
+ begin
375
+ File.delete 'video_split.log' if File.exist? 'video_split.log'
376
+ rescue
377
+ end
378
+
379
+ # Check if enough frames had changes
380
+ return (dif_count.to_f/im_files.size)*100 >= in_video_treshold
381
+
382
+ end
383
+
264
384
  end
@@ -37,6 +37,13 @@ module MobyUtil
37
37
 
38
38
  end
39
39
 
40
+ # print only object type and id hex
41
+ def inspect
42
+
43
+ "#<#{ self.class }:0x#{ ( "%x" % ( self.object_id.to_i << 1 ) )[ 3 .. -1 ] }>"
44
+
45
+ end
46
+
40
47
  # enable hooking for performance measurement & debug logging
41
48
  MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
42
49
 
@@ -0,0 +1,32 @@
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
+ module MobyUtil
21
+
22
+ module XML
23
+
24
+ class Attribute
25
+
26
+ include Abstraction
27
+
28
+ end # Attribute
29
+
30
+ end # XML
31
+
32
+ end # MobyUtil
@@ -32,8 +32,14 @@ require File.expand_path( File.join( File.dirname( __FILE__ ), 'document.rb' ) )
32
32
  # element object
33
33
  require File.expand_path( File.join( File.dirname( __FILE__ ), 'element.rb' ) )
34
34
 
35
- # element object
36
- require File.expand_path( File.join( File.dirname( __FILE__ ), 'nil_element.rb' ) )
35
+ # text object
36
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'text.rb' ) )
37
+
38
+ # attribute object
39
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'attribute.rb' ) )
40
+
41
+ # nil element object
42
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'nil_node.rb' ) )
37
43
 
38
44
  # nodeset object
39
45
  require File.expand_path( File.join( File.dirname( __FILE__ ), 'nodeset.rb' ) )
@@ -0,0 +1,95 @@
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
+ module MobyUtil
21
+
22
+ module XML
23
+
24
+ class NilNode
25
+
26
+ include Abstraction
27
+
28
+ def method_missing( method, *method_arguments )
29
+
30
+ raise RuntimeError.new( "Method '%s' is not supported by %s (%s)" % [ method, self.class, @parser ] )
31
+
32
+ end
33
+
34
+ def xml=( value )
35
+
36
+ @xml = nil
37
+
38
+ end
39
+
40
+ def name
41
+
42
+ nil
43
+
44
+ end
45
+
46
+ def size
47
+
48
+ 0
49
+
50
+ end
51
+
52
+ def nil?
53
+
54
+ true
55
+
56
+ end
57
+
58
+ def eql?( object )
59
+
60
+ nil == object.xml.content
61
+
62
+ end
63
+
64
+ def empty?
65
+
66
+ true
67
+
68
+ end
69
+
70
+ def content
71
+
72
+ nil
73
+
74
+ end
75
+
76
+ def to_s
77
+
78
+ ""
79
+
80
+ end
81
+
82
+ def inner_xml
83
+
84
+ ""
85
+
86
+ end
87
+
88
+ # enable hooking for performance measurement & debug logging
89
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
90
+
91
+ end # NilElement
92
+
93
+ end # XML
94
+
95
+ end # MobyUtil