testability-driver 0.9.2

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 (214) hide show
  1. data/README +1 -0
  2. data/bin/start_app_perf +199 -0
  3. data/bin/tdriver-devtools +3 -0
  4. data/config/sut_parameters.rb +39 -0
  5. data/ext/extconf.rb +67 -0
  6. data/ext/native_extensions.c +70 -0
  7. data/lib/matti.rb +30 -0
  8. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +223 -0
  9. data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
  10. data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
  11. data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
  12. data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
  13. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
  14. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
  15. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
  16. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
  17. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
  18. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
  19. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
  20. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
  21. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
  22. data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
  23. data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
  24. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1924 -0
  25. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
  26. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
  27. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
  28. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
  29. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
  30. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
  31. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
  32. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
  33. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
  34. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
  35. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
  36. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
  37. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
  38. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
  39. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
  40. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
  41. data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +245 -0
  42. data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +964 -0
  43. data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +68 -0
  44. data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +1865 -0
  45. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +1 -0
  46. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +3 -0
  47. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +4 -0
  48. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +4 -0
  49. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +4 -0
  50. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +3 -0
  51. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +3 -0
  52. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +1 -0
  53. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +3 -0
  54. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +3 -0
  55. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +12 -0
  56. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +5 -0
  57. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +1 -0
  58. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +2 -0
  59. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +7 -0
  60. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +14 -0
  61. data/lib/tdriver-devtools/behaviour/xml_generator/update +3 -0
  62. data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
  63. data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
  64. data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
  65. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
  66. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
  67. data/lib/tdriver-devtools/doc/generate.rb +892 -0
  68. data/lib/tdriver-devtools/doc/update +1 -0
  69. data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
  70. data/lib/tdriver-devtools/doc/xslt/template.xsl +1861 -0
  71. data/lib/tdriver-devtools/doc/xslt/update +3 -0
  72. data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
  73. data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
  74. data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +233 -0
  75. data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +194 -0
  76. data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
  77. data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
  78. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
  79. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
  80. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
  81. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
  82. data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
  83. data/lib/tdriver.rb +26 -0
  84. data/lib/tdriver/base/behaviour/behaviour.rb +32 -0
  85. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +94 -0
  86. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +262 -0
  87. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +111 -0
  88. data/lib/tdriver/base/behaviour/factory.rb +380 -0
  89. data/lib/tdriver/base/behaviour/loader.rb +28 -0
  90. data/lib/tdriver/base/command_data/command_data.rb +51 -0
  91. data/lib/tdriver/base/command_data/loader.rb +25 -0
  92. data/lib/tdriver/base/errors.rb +131 -0
  93. data/lib/tdriver/base/loader.rb +38 -0
  94. data/lib/tdriver/base/state_object.rb +270 -0
  95. data/lib/tdriver/base/sut/adapter.rb +28 -0
  96. data/lib/tdriver/base/sut/controller.rb +119 -0
  97. data/lib/tdriver/base/sut/factory.rb +287 -0
  98. data/lib/tdriver/base/sut/generic/behaviours/application.rb +243 -0
  99. data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
  100. data/lib/tdriver/base/sut/generic/behaviours/find.rb +96 -0
  101. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +346 -0
  102. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1268 -0
  103. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +182 -0
  104. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +119 -0
  105. data/lib/tdriver/base/sut/generic/commands/application.rb +219 -0
  106. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +82 -0
  107. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +58 -0
  108. data/lib/tdriver/base/sut/generic/plugin.rb +96 -0
  109. data/lib/tdriver/base/sut/loader.rb +35 -0
  110. data/lib/tdriver/base/sut/sut.rb +67 -0
  111. data/lib/tdriver/base/test_object/abstract.rb +179 -0
  112. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +94 -0
  113. data/lib/tdriver/base/test_object/behaviours/test_object.rb +787 -0
  114. data/lib/tdriver/base/test_object/factory.rb +618 -0
  115. data/lib/tdriver/base/test_object/identificator.rb +511 -0
  116. data/lib/tdriver/base/test_object/loader.rb +37 -0
  117. data/lib/tdriver/env.rb +21 -0
  118. data/lib/tdriver/loader.rb +36 -0
  119. data/lib/tdriver/matti.rb +35 -0
  120. data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
  121. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +158 -0
  122. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +98 -0
  123. data/lib/tdriver/report/report.rb +47 -0
  124. data/lib/tdriver/report/report_api.rb +207 -0
  125. data/lib/tdriver/report/report_combine.rb +86 -0
  126. data/lib/tdriver/report/report_crash_file_capture.rb +167 -0
  127. data/lib/tdriver/report/report_creator.rb +571 -0
  128. data/lib/tdriver/report/report_cucumber.rb +158 -0
  129. data/lib/tdriver/report/report_cucumber_listener.rb +337 -0
  130. data/lib/tdriver/report/report_cucumber_reporter.rb +335 -0
  131. data/lib/tdriver/report/report_data_presentation.rb +152 -0
  132. data/lib/tdriver/report/report_data_table.rb +64 -0
  133. data/lib/tdriver/report/report_execution_statistics.rb +284 -0
  134. data/lib/tdriver/report/report_file_capture.rb +159 -0
  135. data/lib/tdriver/report/report_grouping.rb +539 -0
  136. data/lib/tdriver/report/report_junit_xml.rb +147 -0
  137. data/lib/tdriver/report/report_rspec.rb +108 -0
  138. data/lib/tdriver/report/report_test_case_run.rb +621 -0
  139. data/lib/tdriver/report/report_test_run.rb +1286 -0
  140. data/lib/tdriver/report/report_test_unit.rb +175 -0
  141. data/lib/tdriver/report/report_writer.rb +1405 -0
  142. data/lib/tdriver/tdriver.rb +158 -0
  143. data/lib/tdriver/util/common.rb +24 -0
  144. data/lib/tdriver/util/common/array.rb +39 -0
  145. data/lib/tdriver/util/common/crc16.rb +100 -0
  146. data/lib/tdriver/util/common/environment.rb +153 -0
  147. data/lib/tdriver/util/common/error.rb +39 -0
  148. data/lib/tdriver/util/common/file.rb +315 -0
  149. data/lib/tdriver/util/common/gem.rb +108 -0
  150. data/lib/tdriver/util/common/kernel.rb +189 -0
  151. data/lib/tdriver/util/common/loader.rb +39 -0
  152. data/lib/tdriver/util/common/retryable.rb +98 -0
  153. data/lib/tdriver/util/common/string.rb +77 -0
  154. data/lib/tdriver/util/dbaccess/dbaccess.rb +188 -0
  155. data/lib/tdriver/util/dbaccess/dbconnection.rb +41 -0
  156. data/lib/tdriver/util/dbaccess/error.rb +35 -0
  157. data/lib/tdriver/util/dbaccess/loader.rb +29 -0
  158. data/lib/tdriver/util/dynamic_attribute_filter.rb +182 -0
  159. data/lib/tdriver/util/hooking.rb +434 -0
  160. data/lib/tdriver/util/loader.rb +65 -0
  161. data/lib/tdriver/util/localisation.rb +24 -0
  162. data/lib/tdriver/util/localisation/error.rb +32 -0
  163. data/lib/tdriver/util/localisation/loader.rb +28 -0
  164. data/lib/tdriver/util/localisation/localisation.rb +479 -0
  165. data/lib/tdriver/util/logger.rb +377 -0
  166. data/lib/tdriver/util/operator_data/error.rb +29 -0
  167. data/lib/tdriver/util/operator_data/loader.rb +26 -0
  168. data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
  169. data/lib/tdriver/util/other/config.rb +221 -0
  170. data/lib/tdriver/util/parameter.rb +24 -0
  171. data/lib/tdriver/util/parameter/error.rb +45 -0
  172. data/lib/tdriver/util/parameter/loader.rb +37 -0
  173. data/lib/tdriver/util/parameter/parameter.rb +285 -0
  174. data/lib/tdriver/util/parameter/parameter_hash.rb +101 -0
  175. data/lib/tdriver/util/parameter/parameter_template.rb +120 -0
  176. data/lib/tdriver/util/parameter/parameter_user_api.rb +84 -0
  177. data/lib/tdriver/util/parameter/parameter_xml.rb +247 -0
  178. data/lib/tdriver/util/plugin/abstract.rb +60 -0
  179. data/lib/tdriver/util/plugin/error.rb +25 -0
  180. data/lib/tdriver/util/plugin/loader.rb +28 -0
  181. data/lib/tdriver/util/plugin/service.rb +200 -0
  182. data/lib/tdriver/util/recorder.rb +292 -0
  183. data/lib/tdriver/util/stats.rb +90 -0
  184. data/lib/tdriver/util/user_data/error.rb +29 -0
  185. data/lib/tdriver/util/user_data/loader.rb +26 -0
  186. data/lib/tdriver/util/user_data/user_data.rb +103 -0
  187. data/lib/tdriver/util/video_rec.rb +264 -0
  188. data/lib/tdriver/util/xml/abstraction.rb +47 -0
  189. data/lib/tdriver/util/xml/builder.rb +54 -0
  190. data/lib/tdriver/util/xml/document.rb +32 -0
  191. data/lib/tdriver/util/xml/element.rb +32 -0
  192. data/lib/tdriver/util/xml/error.rb +46 -0
  193. data/lib/tdriver/util/xml/loader.rb +46 -0
  194. data/lib/tdriver/util/xml/nil_element.rb +89 -0
  195. data/lib/tdriver/util/xml/nodeset.rb +32 -0
  196. data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
  197. data/lib/tdriver/util/xml/parsers/loader.rb +22 -0
  198. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +111 -0
  199. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +54 -0
  200. data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +58 -0
  201. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +58 -0
  202. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +147 -0
  203. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +42 -0
  204. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +187 -0
  205. data/lib/tdriver/util/xml/xml.rb +170 -0
  206. data/lib/tdriver/verify/verify.rb +687 -0
  207. data/lib/tdriver/verify/verify.rb_org +630 -0
  208. data/lib/tdriver/version.rb +21 -0
  209. data/xml/behaviours/generic.xml +495 -0
  210. data/xml/defaults/generic.xml +97 -0
  211. data/xml/defaults/sut_generic.xml +36 -0
  212. data/xml/parameters/tdriver_parameters.xml +23 -0
  213. data/xml/templates/generic.xml +227 -0
  214. metadata +327 -0
data/README ADDED
@@ -0,0 +1 @@
1
+ release notes
@@ -0,0 +1,199 @@
1
+ #! /usr/bin/ruby1.8
2
+ # Add '.rb' to work around a bug in IronRuby's File#dirname
3
+ $:.unshift(File.dirname(__FILE__ + '.rb') + '/../lib') unless $:.include?(File.dirname(__FILE__ + '.rb') + '/../lib')
4
+
5
+
6
+ require 'tdriver' # contains the reporter!
7
+ require 'nokogiri'
8
+ require 'date'
9
+ require 'optparse'
10
+
11
+ include TDriverReportDataPresentation
12
+
13
+ ##################################
14
+ ## PARSE COMMAND LINE OPTIONS
15
+ @settings = {}
16
+ @settings[:iterations] = nil
17
+ @settings[:signals] = ["applicationReady()"]
18
+ @settings[:events] = ["Paint"]
19
+ @settings[:output_filename] = "startperf_report.html"
20
+ @settings[:app_name] = ""
21
+ @settings[:objects] = ""
22
+ @settings[:sut_type] = "sut_qt"
23
+ @data = {}
24
+
25
+ begin
26
+ options = OptionParser.new do |opts|
27
+ opts.banner = "Usage: start_app_perf [OPTIONS] <application>\nNote: 'applicationStart()' signal and 'Paint' events will be collected by default.\nOptions:\n"
28
+ opts.on("-n ITERATIONS", "--iterations", "Required. Number of iterations of the start test.") do |s| @settings[:iterations] = s.to_i; end
29
+ opts.on("-s SYGNALS", "--signals", "Comma separated list of signals to collect, don't use spaces.") do |s| @settings[:signals] << s.split(',').collect{|a| a.strip}; end
30
+ opts.on("-e EVENTS", "--events", "Comma separated list of events to collect, don't use spaces.") do |s| @settings[:events] << s.split(',').collect{|a| a.strip}; end
31
+ opts.on("-o FILENAME", "--output", "Filename for the output html report. Defaults to 'startperf_report.html'") do |s| @settings[:output_filename] = s; end
32
+ opts.on("-t SUTTYPE", "--suttype", "Sut type to be used. 'sut_qt' will be used as default type.") do |s| @settings[:sut_type] = s; end
33
+ @settings[:opts] = opts
34
+ end.parse!
35
+ raise OptionParser::MissingArgument.new("number of iterations not provided. use the -n option to provide it.") if @settings[:iterations] == nil
36
+ raise OptionParser::MissingArgument.new("application to run not provided.") if ARGV.length < 1
37
+ raise OptionParser::InvalidArgument.new("too many arguments provided." + ARGV.to_s) if ARGV.length > 1
38
+ @settings[:app_name] = ARGV[0].sub(/\.exe/, '')
39
+ rescue OptionParser::MissingArgument, OptionParser::InvalidArgument, Exception => e
40
+ puts e.message
41
+ puts
42
+ puts @settings[:opts]
43
+ exit
44
+ end
45
+
46
+
47
+ # HARDCODED => Sut type,
48
+ # signals to listen: 'applicationReady()'
49
+ # events to listen: 'Paint'
50
+
51
+ ##################################
52
+ ## METHODS
53
+
54
+ # convert string argument into integer
55
+ def toi(arg)
56
+ while(arg.length > 0 && arg[0] == '0')
57
+ arg = arg[1..-1]
58
+ end
59
+ arg.to_i
60
+ end
61
+
62
+ # Run Application
63
+ def run(iteration)
64
+ # start application and set events & signals to listen. SLEEP prevents other communications to affect the performance of the application while starting
65
+ app = @sut.run(:name => @settings[:app_name], :events_to_listen => @settings[:events].join(','), :signals_to_listen => @settings[:signals].join(','), :sleep_after_launch => 5)
66
+ strOut = ""
67
+
68
+ # process Events
69
+ if !@settings[:events].empty?
70
+ events = app.get_events
71
+ app.disable_events
72
+ #puts events
73
+ doc = Nokogiri::XML.parse(events)
74
+ first_time_stamp = nil
75
+ node_set = doc.xpath('//object[@name = "QtApplicationEvents"]/objects/object')
76
+ timer_counter = 0
77
+ index = 0
78
+ target_object = nil
79
+ while(index < node_set.size)
80
+ node = node_set.at(index)
81
+ time_str = node.xpath("#{node.path}/attributes/attribute[@name = \"timeStamp\"]/value").first.text
82
+ time_stamp = Time.local(toi(time_str[0..3]), toi(time_str[4..5]), toi(time_str[6..7]), toi(time_str[8..9]), toi(time_str[10..11]), toi(time_str[12..13]), toi(time_str[14..16])*1000)
83
+ if (first_time_stamp == nil)
84
+ first_time_stamp = time_stamp
85
+ strOut << "application started at " << first_time_stamp.to_s << "\n"
86
+ strOut << "events:\n"
87
+ else
88
+ event_name = node.attribute("name").text
89
+ delta_time_seconds = time_stamp.to_i-first_time_stamp.to_i
90
+ delta_time_milliseconds = (time_stamp.usec/1000) - (first_time_stamp.usec/1000)
91
+ delta_time = delta_time_seconds*1000
92
+ delta_time = delta_time + delta_time_milliseconds
93
+
94
+ strOut << (delta_time).to_s << "\t" << event_name
95
+ target_object = node.xpath("#{node.path}/objects/object").first
96
+ if(target_object)
97
+ target_object_name = target_object.attribute("name").text
98
+ target_object_type = target_object.attribute("type").text
99
+ strOut << "\t" << target_object_type << "(" << target_object_name << ")"
100
+ end
101
+ strOut << "\n"
102
+
103
+ #DATACOLLECTION!
104
+ event_method_name = target_object.nil? ? event_name : "#{event_name}:#{target_object_type}(#{target_object_name})"
105
+ @data[event_method_name] = Array.new if @data[event_method_name] == nil
106
+ @data[event_method_name][iteration] = delta_time
107
+ end
108
+ index = index + 1
109
+ end
110
+ end
111
+
112
+
113
+ # process signals
114
+ if !@settings[:signals].empty?
115
+ signals = app.fixture('signal', 'get_signal')
116
+ app.fixture('signal', 'remove_signals')
117
+ #puts signals
118
+ doc = Nokogiri::XML.parse(signals)
119
+ first_time_stamp = nil
120
+ node_set = doc.xpath('//tasInfo[@name = "QtSignals"]/object')
121
+ timer_counter = 0
122
+ index = 0
123
+ target_object = nil
124
+ while(index < node_set.size)
125
+ node = node_set.at(index)
126
+ time_str = node.xpath("#{node.path}/attributes/attribute[@name = \"timeStamp\"]/value").first.text
127
+ time_stamp = Time.local(toi(time_str[0..3]), toi(time_str[4..5]), toi(time_str[6..7]), toi(time_str[8..9]), toi(time_str[10..11]), toi(time_str[12..13]), toi(time_str[14..16])*1000)
128
+ if (first_time_stamp == nil)
129
+ first_time_stamp = time_stamp
130
+ strOut << "application started at " << first_time_stamp.to_s << "\n" if (strOut == "")
131
+ strOut << "signals:\n"
132
+ else
133
+ signal_name = node.attribute("name").text
134
+ delta_time_seconds = time_stamp.to_i-first_time_stamp.to_i
135
+ delta_time_milliseconds = (time_stamp.usec/1000) - (first_time_stamp.usec/1000)
136
+ delta_time = delta_time_seconds*1000
137
+ delta_time = delta_time + delta_time_milliseconds
138
+
139
+ #DATACOLLECTION!
140
+ @data[signal_name] = Array.new if @data[signal_name] == nil
141
+ @data[signal_name][iteration] = delta_time
142
+
143
+ strOut << (delta_time).to_s << "\t" << signal_name << "\n"
144
+ end
145
+ index = index + 1
146
+ end
147
+ end
148
+
149
+ # print out the list of events and signals
150
+ puts strOut
151
+ app.close
152
+ end
153
+
154
+ # Create HTML Graph Report
155
+ def gen_html_report
156
+ include TDriverReportWriter
157
+ write_style_sheet("tdriver_report_style.css")
158
+ html_file = File.new(@settings[:output_filename], "w+")
159
+ html_file << '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
160
+ <html xmlns="http://www.w3.org/1999/xhtml">
161
+ <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-eqiv="cache-control" content="no-cache">
162
+ <link rel="stylesheet" title="TDriverReportStyle" href="tdriver_report_style.css"/>
163
+ <title>'+ "Application Start Performance" +'</title>
164
+ </head><body>'
165
+ html_file << insert_graph_css
166
+ html_file << insert_html_graph( @data, nil, nil, "500")
167
+ html_file << insert_html_table( @data , 500)
168
+ html_file << '</body></html>'
169
+ end
170
+
171
+ ##################################
172
+ ## MAIN
173
+ # Print options summary
174
+ puts ">> Application: " + @settings[:app_name]
175
+ puts ">> Iterations: " + @settings[:iterations].to_s
176
+ puts ">> Signals: " + @settings[:signals].to_s
177
+ puts ">> Events: " + @settings[:events].to_s
178
+
179
+ # Connect to TDriver
180
+ @sut = TDriver.sut( :Id => @settings[:sut_type] )
181
+
182
+ # Run iterations
183
+ @settings[:iterations].times do |iteration|
184
+ puts "\nITERATION " + (iteration + 1).to_s + " OF " + @settings[:iterations].to_s
185
+ run(iteration)
186
+ end
187
+
188
+ # Print Summary
189
+ puts "\nDATA Collected"
190
+ @data.each_key do |key|
191
+ puts "Signal/Event: " + key.to_s + " Values: " + @data[key].join(',')
192
+ end
193
+
194
+ # Generate HTML report
195
+ gen_html_report
196
+ puts "\nHTML Report created at " + @settings[:output_filename]
197
+
198
+ # Disconnect from Tdriver
199
+ @sut.disconnect
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path( File.join( File.dirname( __FILE__ ), '../lib/tdriver-devtools/tdriver-devtools.rb' ) )
3
+
@@ -0,0 +1,39 @@
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
+ # Generic configuration file for sut data.
20
+ # Can be used to provide ruby code for sut configurations.
21
+ module SutParameters
22
+ # Verify blocks define the verify_always blocks that are automatically added to given sut.
23
+ # Takes an array of VerifyBlock objects
24
+ # VerifyBlock parameters:
25
+ # - Proc block
26
+ # - Expected return value
27
+ # - Error message
28
+ # Configured verify_always blocks will not return the failed error block code in the error message.
29
+ VERIFY_BLOCKS = [
30
+ # Example block
31
+ MobyUtil::VerifyBlock.new(
32
+ Proc.new { |sut|
33
+ # Verifies that some application is always running
34
+ sut.application.name != "qttasserver"
35
+ },
36
+ true, "Top most application is qttas, no application is running")
37
+ ]
38
+ end
39
+
data/ext/extconf.rb ADDED
@@ -0,0 +1,67 @@
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 File.join( File.dirname(__FILE__), '../lib/tdriver/util/loader' )
21
+
22
+ MobyUtil::GemHelper.install( MobyUtil::FileHelper.tdriver_home ){ | tdriver_home_folder |
23
+
24
+ [
25
+ # default parameters & sut configuration
26
+ [ "../xml/defaults/*.xml", "defaults/", true ],
27
+
28
+ # parameters
29
+ [ "../xml/parameters/tdriver_parameters.xml", "tdriver_parameters.xml", false ],
30
+ [ "../xml/parameters/tdriver_parameters.xml", "default/tdriver_parameters.xml", true ],
31
+ [ "../config/sut_parameters.rb", "sut_parameters.rb", true ],
32
+
33
+ # templates
34
+ [ "../xml/templates/*.xml", "templates/", true ],
35
+ [ "../xml/templates/*.xml", "default/templates/", true ],
36
+
37
+ # behaviours
38
+ [ "../xml/behaviours/*.xml", "behaviours/", true ],
39
+ [ "../xml/behaviours/*.xml", "default/behaviours/", true ],
40
+
41
+ # create logfiles fodler
42
+ [ nil, "logfiles/", false ]
43
+
44
+ # documentation
45
+ #[ "../doc/", "doc/", true ]
46
+
47
+ ].each { | task |
48
+
49
+ source, destination, overwrite = task
50
+
51
+ if source.nil?
52
+
53
+ MobyUtil::FileHelper.mkdir_path( File.join( tdriver_home_folder, destination ) ) unless MobyUtil::FileHelper.folder_exist?( File.join( tdriver_home_folder, destination ) )
54
+
55
+ else
56
+
57
+ MobyUtil::FileHelper.copy_file( source, "#{ tdriver_home_folder }/#{ destination }", false, overwrite, true )
58
+
59
+ end
60
+
61
+ }
62
+
63
+ }
64
+
65
+ MobyUtil::Stats.report( 'install', 'Installed gem' )
66
+
67
+ sleep ( 5 ) # do not remove!!
@@ -0,0 +1,70 @@
1
+ /*
2
+ ############################################################################
3
+ ##
4
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5
+ ## All rights reserved.
6
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
7
+ ##
8
+ ## This file is part of Testability Driver.
9
+ ##
10
+ ## If you have questions regarding the use of this file, please contact
11
+ ## Nokia at testabilitydriver@nokia.com .
12
+ ##
13
+ ## This library is free software; you can redistribute it and/or
14
+ ## modify it under the terms of the GNU Lesser General Public
15
+ ## License version 2.1 as published by the Free Software Foundation
16
+ ## and appearing in the file LICENSE.LGPL included in the packaging
17
+ ## of this file.
18
+ ##
19
+ ############################################################################
20
+ */
21
+
22
+ #include "ruby.h"
23
+
24
+ static const CRC_16[ 16 ] = {
25
+
26
+ 0x0000, 0x1081, 0x2102, 0x3183,
27
+ 0x4204, 0x5285, 0x6306, 0x7387,
28
+ 0x8408, 0x9489, 0xa50a, 0xb58b,
29
+ 0xc60c, 0xd68d, 0xe70e, 0xf78f
30
+
31
+ };
32
+
33
+ static VALUE crc16_ibm( VALUE self, VALUE string ) {
34
+
35
+ // verify argument type
36
+ Check_Type( string, T_STRING );
37
+
38
+ const char* data = RSTRING_PTR( string );
39
+
40
+ int len = RSTRING_LEN( string );
41
+
42
+ int crc = 0xffff;
43
+
44
+ int c = 0;
45
+
46
+ while( len-- != 0 ){
47
+
48
+ c = *data++;
49
+
50
+ crc = ( ( crc >> 4 ) & 0x0fff ) ^ CRC_16[ ( ( crc ^ c ) & 15 ) ];
51
+
52
+ crc = ( ( crc >> 4 ) & 0x0fff ) ^ CRC_16[ ( ( crc ^ ( c >> 4 )) & 15 ) ];
53
+ }
54
+
55
+
56
+ return INT2FIX( ~crc & 0xffff );
57
+
58
+ }
59
+
60
+ void Init_native_extensions() {
61
+
62
+ VALUE mTDriver = rb_define_module( "TDriver" );
63
+
64
+ VALUE mNativeExtensions = rb_define_module_under( mTDriver, "NativeExtensions" );
65
+
66
+ VALUE mCRC = rb_define_module_under( mNativeExtensions, "CRC" );
67
+
68
+ rb_define_singleton_method( mCRC, "crc16_ibm", crc16_ibm, 1 );
69
+
70
+ }
data/lib/matti.rb ADDED
@@ -0,0 +1,30 @@
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
+ =begin
21
+ file, line = ( caller.first || "%s:%s" % [ __FILE__, __LINE__ ] ).split(":")
22
+ $stderr.puts "%s:%s warning: require 'matti' deprecated, use require 'tdriver' instead also 'MATTI' is deprecated, use 'TDriver' instead " % [ file, line]
23
+ =end
24
+
25
+ $stderr.puts "%s:%s warning: require 'matti' deprecated, use require 'tdriver' instead. Please note that class 'MATTI' is also deprecated, use 'TDriver' instead " % ( caller.first || "%s:%s" % [ __FILE__, __LINE__ ] ).split(":")[ 0..1 ]
26
+
27
+ # load matti resources and framework
28
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'tdriver/env' ) )
29
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'tdriver/version' ) )
30
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'tdriver/matti' ) )
@@ -0,0 +1,223 @@
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 TDriver.
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 MobyBehaviour
21
+
22
+ module QT
23
+
24
+ # == description
25
+ # This module contains demonstration implementation containing tags for documentation generation using gesture as an example
26
+ #
27
+ # == behaviour
28
+ # QtExampleGestureBehaviour
29
+ #
30
+ # == requires
31
+ # testability-driver-sut-qt-plugin
32
+ #
33
+ # == input_type
34
+ # touch
35
+ #
36
+ # == sut_type
37
+ # qt
38
+ #
39
+ # == sut_version
40
+ # *
41
+ #
42
+ # == objects
43
+ # *;sut
44
+ #
45
+ module Gesture
46
+
47
+ include MobyBehaviour::QT::Behaviour
48
+
49
+ # == description
50
+ # Cause a flick operation on the screen.
51
+ #
52
+ # == arguments
53
+ # argument1
54
+ # Integer
55
+ # description: Example argument1
56
+ # example: 10
57
+ # default:
58
+ # Hash
59
+ # description: Example argument 1 type 2
60
+ # example: { :optional_1 => "value_1", :optional_2 => "value_2" }
61
+ # default:
62
+ #
63
+ # argument2
64
+ # String
65
+ # description: Example argument2
66
+ # example: "Hello"
67
+ # default:
68
+ #
69
+ # == returns
70
+ # String
71
+ # description: Return value type
72
+ # example: "World"
73
+ #
74
+ # == exceptions
75
+ # RuntimeError
76
+ # description: example exception
77
+ #
78
+ # ArgumentError
79
+ # description: example exception
80
+ #
81
+ # == example
82
+ # flick( :Down, :Left, { :optional_1 => "value_1", :optional_2 => "value_2" } )
83
+ #
84
+ # == info
85
+ # See method X, table at Y
86
+ #
87
+ # == howto
88
+ # Example1
89
+ # description: Basic use
90
+ # code: @sut = TDriver.sut( :Id => "sut_qt" )
91
+ # app = @sut.application
92
+ # app.QPushButton( :text => "Close" ).flick :Left
93
+ #
94
+ def flick( direction, button = :Left, optional_params = {} )
95
+
96
+ begin
97
+ use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
98
+ optional_params[:use_tap_screen].to_s
99
+ optional_params[:useTapScreen] = use_tap_screen
100
+
101
+ speed = calculate_speed(@sut.parameter(:gesture_flick_distance), @sut.parameter(:gesture_flick_speed))
102
+ distance = @sut.parameter(:gesture_flick_distance).to_i
103
+ params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => button, :useTapScreen => use_tap_screen}
104
+ params.merge!(optional_params)
105
+
106
+ do_gesture(params)
107
+ do_sleep(speed)
108
+
109
+ rescue Exception => e
110
+
111
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed flick with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
112
+ Kernel::raise e
113
+ end
114
+
115
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation flick executed successfully with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
116
+
117
+ nil
118
+ end
119
+
120
+
121
+ private
122
+
123
+ # Performs the actual gesture operation.
124
+ # Verifies that the parameters are correct and send the command
125
+ # to the sut.
126
+ # gesture_type: :MouseGesture, :MouseGestureTo, :MouseGestureToCoordinates
127
+ # params = {:direction => :Up, duration => 2, :distance =>100, :isDrag =>false, :isMove =>false }
128
+ def do_gesture(params)
129
+ validate_gesture_params!(params)
130
+
131
+ if attribute('objectType') == 'Embedded'
132
+ params['x'] = center_x
133
+ params['y'] = center_y
134
+ params['useCoordinates'] = 'true'
135
+ end
136
+
137
+ command = command_params #in qt_behaviour
138
+ command.command_name(params[:gesture_type].to_s)
139
+ command.command_params( params )
140
+ @sut.execute_command( command )
141
+ end
142
+
143
+ def validate_gesture_params!(params)
144
+ #direction
145
+ if params[:gesture_type] == :MouseGesture
146
+ if params[:direction].kind_of?(Integer)
147
+ raise ArgumentError.new( "Invalid direction." ) unless 0 <= params[:direction].to_i and params[:direction].to_i <= 360
148
+ else
149
+ raise ArgumentError.new( "Invalid direction." ) unless @@_valid_directions.include?(params[:direction])
150
+ params[:direction] = @@_direction_map[params[:direction]]
151
+ end
152
+ #distance
153
+ params[:distance] = params[:distance].to_i unless params[:distance].kind_of?(Integer)
154
+ raise ArgumentError.new( "Distance must be an integer and greater than zero." ) unless params[:distance] > 0
155
+ elsif params[:gesture_type] == :MouseGestureToCoordinates
156
+ raise ArgumentError.new("X and Y must be integers.") unless params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
157
+ elsif params[:gesture_type] == :MouseGestureTo
158
+ raise ArgumentError.new("targetId and targetType must be defined.") unless params[:targetId] and params[:targetType]
159
+ end
160
+
161
+ #duration/speed
162
+ params[:speed] = params[:speed].to_f unless params[:speed].kind_of?(Numeric)
163
+ raise ArgumentError.new( "Duration must be a number and greated than zero, was:" + params[:speed].to_s) unless params[:speed] > 0
164
+ duration_secs = params[:speed].to_f
165
+ duration_secs = duration_secs*1000
166
+ params[:speed] = duration_secs.to_i
167
+
168
+ #mouseMove true always
169
+ params[:mouseMove] = true
170
+
171
+ params[:button] = :Left unless params[:button]
172
+ raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(params[:button])
173
+ params[:button] = @@_buttons_map[params[:button]]
174
+
175
+ if params[:isMove] == true
176
+ params[:press] = 'false'
177
+ params[:release] = 'false'
178
+ end
179
+
180
+ end
181
+
182
+
183
+ def do_sleep(time)
184
+
185
+ if MobyUtil::Parameter[ @sut.id ][ :sleep_disabled, nil ] != 'true'
186
+ time = time.to_f
187
+ time = time * 1.3
188
+ #for flicks the duration of the gesture is short but animation (scroll etc..) may not
189
+ #so wait at least one second
190
+ time = 1 if time < 1
191
+ sleep time
192
+ end
193
+
194
+ end
195
+
196
+ def calculate_speed(distance, speed)
197
+
198
+ distance = distance.to_f
199
+ speed = speed.to_f
200
+ duration = distance/speed
201
+ duration
202
+
203
+ end
204
+
205
+ def distance_to_point(x, y)
206
+
207
+ x = x.to_i
208
+ y = y.to_i
209
+ dist_x = x - center_x.to_i
210
+ dist_y = y - center_y.to_i
211
+
212
+ return 0 if dist_y == 0 and dist_x == 0
213
+ distance = Math.hypot( dist_x, dist_y )
214
+ distance
215
+
216
+ end
217
+
218
+ end
219
+
220
+ end
221
+ end
222
+
223
+ MobyUtil::Logger.instance.hook_methods( MobyBehaviour::QT::Gesture )