cutedriver-driver 2.0.0.20210120164037

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 (226) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +16 -0
  3. data/bin/start_app_perf +200 -0
  4. data/bin/tdriver-devtools +3 -0
  5. data/config/sut_parameters.rb +52 -0
  6. data/config/sut_setup.rb +32 -0
  7. data/config/sut_teardown.rb +32 -0
  8. data/config/tdriver_custom_error_recovery.rb +83 -0
  9. data/ext/extconf.rb +70 -0
  10. data/ext/native_extensions.c +315 -0
  11. data/lib/matti.rb +25 -0
  12. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +120 -0
  13. data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
  14. data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
  15. data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
  16. data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
  17. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
  18. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
  19. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
  20. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
  21. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
  22. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
  23. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
  24. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
  25. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
  26. data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
  27. data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
  28. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1945 -0
  29. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
  30. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
  31. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
  32. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
  33. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
  34. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
  35. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
  36. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
  37. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
  38. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
  39. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
  40. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
  41. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
  42. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
  43. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
  44. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
  45. data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
  46. data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
  47. data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
  48. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
  49. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
  50. data/lib/tdriver-devtools/doc/generate.rb +917 -0
  51. data/lib/tdriver-devtools/doc/update +1 -0
  52. data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
  53. data/lib/tdriver-devtools/doc/xslt/template.xsl +2170 -0
  54. data/lib/tdriver-devtools/doc/xslt/update +3 -0
  55. data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
  56. data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
  57. data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
  58. data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
  59. data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
  60. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
  61. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
  62. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
  63. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
  64. data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
  65. data/lib/tdriver.rb +23 -0
  66. data/lib/tdriver/base/behaviour/abstract.rb +29 -0
  67. data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
  68. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +99 -0
  69. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +278 -0
  70. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +119 -0
  71. data/lib/tdriver/base/behaviour/factory.rb +495 -0
  72. data/lib/tdriver/base/behaviour/loader.rb +46 -0
  73. data/lib/tdriver/base/command_data/command_data.rb +51 -0
  74. data/lib/tdriver/base/command_data/loader.rb +29 -0
  75. data/lib/tdriver/base/controller/abstraction.rb +56 -0
  76. data/lib/tdriver/base/controller/loader.rb +21 -0
  77. data/lib/tdriver/base/errors.rb +134 -0
  78. data/lib/tdriver/base/loader.rb +47 -0
  79. data/lib/tdriver/base/state_object.rb +373 -0
  80. data/lib/tdriver/base/sut/adapter.rb +54 -0
  81. data/lib/tdriver/base/sut/controller.rb +151 -0
  82. data/lib/tdriver/base/sut/factory.rb +339 -0
  83. data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
  84. data/lib/tdriver/base/sut/generic/behaviours/application.rb +427 -0
  85. data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
  86. data/lib/tdriver/base/sut/generic/behaviours/find.rb +107 -0
  87. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +337 -0
  88. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1888 -0
  89. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +210 -0
  90. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +222 -0
  91. data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
  92. data/lib/tdriver/base/sut/generic/commands/application.rb +274 -0
  93. data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
  94. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +94 -0
  95. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +64 -0
  96. data/lib/tdriver/base/sut/generic/plugin.rb +97 -0
  97. data/lib/tdriver/base/sut/loader.rb +35 -0
  98. data/lib/tdriver/base/sut/sut.rb +98 -0
  99. data/lib/tdriver/base/test_object/abstract.rb +208 -0
  100. data/lib/tdriver/base/test_object/adapter.rb +740 -0
  101. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +144 -0
  102. data/lib/tdriver/base/test_object/behaviours/test_object.rb +1047 -0
  103. data/lib/tdriver/base/test_object/cache.rb +134 -0
  104. data/lib/tdriver/base/test_object/factory.rb +684 -0
  105. data/lib/tdriver/base/test_object/loader.rb +51 -0
  106. data/lib/tdriver/base/test_object/verification.rb +178 -0
  107. data/lib/tdriver/base/test_object/xml/abstraction.rb +63 -0
  108. data/lib/tdriver/base/test_object/xml/adapter.rb +773 -0
  109. data/lib/tdriver/env.rb +21 -0
  110. data/lib/tdriver/loader.rb +57 -0
  111. data/lib/tdriver/matti.rb +35 -0
  112. data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
  113. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +168 -0
  114. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +106 -0
  115. data/lib/tdriver/report/report.rb +61 -0
  116. data/lib/tdriver/report/report_api.rb +348 -0
  117. data/lib/tdriver/report/report_combine.rb +86 -0
  118. data/lib/tdriver/report/report_crash_file_capture.rb +178 -0
  119. data/lib/tdriver/report/report_creator.rb +665 -0
  120. data/lib/tdriver/report/report_cucumber.rb +158 -0
  121. data/lib/tdriver/report/report_cucumber_listener.rb +184 -0
  122. data/lib/tdriver/report/report_cucumber_reporter.rb +181 -0
  123. data/lib/tdriver/report/report_data_presentation.rb +156 -0
  124. data/lib/tdriver/report/report_data_table.rb +64 -0
  125. data/lib/tdriver/report/report_execution_statistics.rb +400 -0
  126. data/lib/tdriver/report/report_file_capture.rb +159 -0
  127. data/lib/tdriver/report/report_graph_generator.rb +59 -0
  128. data/lib/tdriver/report/report_grouping.rb +541 -0
  129. data/lib/tdriver/report/report_javascript.rb +199 -0
  130. data/lib/tdriver/report/report_junit_xml.rb +147 -0
  131. data/lib/tdriver/report/report_rspec.rb +108 -0
  132. data/lib/tdriver/report/report_test_case_run.rb +725 -0
  133. data/lib/tdriver/report/report_test_run.rb +1476 -0
  134. data/lib/tdriver/report/report_test_unit.rb +223 -0
  135. data/lib/tdriver/report/report_writer.rb +1621 -0
  136. data/lib/tdriver/tdriver.rb +209 -0
  137. data/lib/tdriver/util/agent/loader.rb +22 -0
  138. data/lib/tdriver/util/agent/service.rb +107 -0
  139. data/lib/tdriver/util/common/array.rb +39 -0
  140. data/lib/tdriver/util/common/boolean.rb +48 -0
  141. data/lib/tdriver/util/common/crc16.rb +149 -0
  142. data/lib/tdriver/util/common/environment.rb +154 -0
  143. data/lib/tdriver/util/common/error.rb +40 -0
  144. data/lib/tdriver/util/common/exception.rb +53 -0
  145. data/lib/tdriver/util/common/exceptions.rb +12 -0
  146. data/lib/tdriver/util/common/file.rb +328 -0
  147. data/lib/tdriver/util/common/gem.rb +109 -0
  148. data/lib/tdriver/util/common/hash.rb +288 -0
  149. data/lib/tdriver/util/common/kernel.rb +253 -0
  150. data/lib/tdriver/util/common/loader.rb +47 -0
  151. data/lib/tdriver/util/common/numeric.rb +159 -0
  152. data/lib/tdriver/util/common/object.rb +159 -0
  153. data/lib/tdriver/util/common/retryable.rb +179 -0
  154. data/lib/tdriver/util/common/stackable.rb +185 -0
  155. data/lib/tdriver/util/common/string.rb +174 -0
  156. data/lib/tdriver/util/database/access.rb +240 -0
  157. data/lib/tdriver/util/database/connection.rb +44 -0
  158. data/lib/tdriver/util/database/error.rb +34 -0
  159. data/lib/tdriver/util/database/loader.rb +28 -0
  160. data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
  161. data/lib/tdriver/util/filters/loader.rb +29 -0
  162. data/lib/tdriver/util/fixture/loader.rb +22 -0
  163. data/lib/tdriver/util/fixture/service.rb +211 -0
  164. data/lib/tdriver/util/hooking/hooking.rb +477 -0
  165. data/lib/tdriver/util/keymap/keymap.rb +81 -0
  166. data/lib/tdriver/util/loader.rb +80 -0
  167. data/lib/tdriver/util/localisation/error.rb +31 -0
  168. data/lib/tdriver/util/localisation/loader.rb +25 -0
  169. data/lib/tdriver/util/localisation/localisation.rb +762 -0
  170. data/lib/tdriver/util/logger/loader.rb +22 -0
  171. data/lib/tdriver/util/logger/logger.rb +591 -0
  172. data/lib/tdriver/util/operator_data/error.rb +29 -0
  173. data/lib/tdriver/util/operator_data/loader.rb +27 -0
  174. data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
  175. data/lib/tdriver/util/other/config.rb +221 -0
  176. data/lib/tdriver/util/parameter/error.rb +48 -0
  177. data/lib/tdriver/util/parameter/loader.rb +25 -0
  178. data/lib/tdriver/util/parameter/parameter.rb +1161 -0
  179. data/lib/tdriver/util/plugin/abstract.rb +61 -0
  180. data/lib/tdriver/util/plugin/error.rb +0 -0
  181. data/lib/tdriver/util/plugin/loader.rb +28 -0
  182. data/lib/tdriver/util/plugin/service.rb +319 -0
  183. data/lib/tdriver/util/recorder/loader.rb +25 -0
  184. data/lib/tdriver/util/recorder/recorder.rb +72 -0
  185. data/lib/tdriver/util/recorder/scripter.rb +294 -0
  186. data/lib/tdriver/util/statistics/statistics.rb +89 -0
  187. data/lib/tdriver/util/user_data/error.rb +28 -0
  188. data/lib/tdriver/util/user_data/loader.rb +25 -0
  189. data/lib/tdriver/util/user_data/user_data.rb +104 -0
  190. data/lib/tdriver/util/video/camera.rb +67 -0
  191. data/lib/tdriver/util/video/camera_linux.rb +153 -0
  192. data/lib/tdriver/util/video/camera_windows.rb +174 -0
  193. data/lib/tdriver/util/video/loader.rb +31 -0
  194. data/lib/tdriver/util/video/video_utils.rb +139 -0
  195. data/lib/tdriver/util/xml/abstraction.rb +117 -0
  196. data/lib/tdriver/util/xml/attribute.rb +32 -0
  197. data/lib/tdriver/util/xml/builder.rb +53 -0
  198. data/lib/tdriver/util/xml/comment.rb +32 -0
  199. data/lib/tdriver/util/xml/document.rb +32 -0
  200. data/lib/tdriver/util/xml/element.rb +32 -0
  201. data/lib/tdriver/util/xml/error.rb +46 -0
  202. data/lib/tdriver/util/xml/loader.rb +62 -0
  203. data/lib/tdriver/util/xml/nil_node.rb +95 -0
  204. data/lib/tdriver/util/xml/nodeset.rb +32 -0
  205. data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
  206. data/lib/tdriver/util/xml/parsers/loader.rb +21 -0
  207. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +167 -0
  208. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +66 -0
  209. data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +64 -0
  210. data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
  211. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +66 -0
  212. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +39 -0
  213. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +58 -0
  214. data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +212 -0
  215. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +237 -0
  216. data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +39 -0
  217. data/lib/tdriver/util/xml/text.rb +32 -0
  218. data/lib/tdriver/util/xml/xml.rb +332 -0
  219. data/lib/tdriver/verify/verify.rb +2398 -0
  220. data/lib/tdriver/version.rb +21 -0
  221. data/xml/behaviours/generic.xml +530 -0
  222. data/xml/defaults/generic.xml +11 -0
  223. data/xml/defaults/sut_generic.xml +8 -0
  224. data/xml/parameters/tdriver_parameters.xml +23 -0
  225. data/xml/templates/generic.xml +292 -0
  226. metadata +324 -0
@@ -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 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
+
21
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'report' ) )
22
+ #Report module which contains the Test::Unit report formatter
23
+ def create_global_reporter_hook_for_test_unit()
24
+ eval("
25
+ module Test #:nodoc:all
26
+ module Unit
27
+ module UI
28
+ module Console
29
+ class TestRunner
30
+ def create_mediator(suite)
31
+ # swap in TDriver custom mediator
32
+ return TDriverReportTestUnit::TestUnit.new(suite)
33
+ end
34
+ end #TestRunner
35
+ end #Console
36
+ end #UI
37
+ end #Unit
38
+ end #Test
39
+ ")
40
+ end
41
+ module TDriverReportTestUnit
42
+ def create_test_unit_formatter()
43
+ eval "
44
+ require 'test/unit'
45
+ require 'test/unit/ui/console/testrunner'
46
+ #class for listening test unit execution process
47
+ class TestUnit < Test::Unit::UI::TestRunnerMediator
48
+ include TDriverReportCreator
49
+ def initialize(suite, report_mgr = nil)
50
+ super(suite)
51
+ @tc_result=nil
52
+ @current_suite_name=suite.name
53
+ @current_test_name=nil
54
+ add_listener(Test::Unit::UI::TestRunnerMediator::STARTED, &method(:started))
55
+ add_listener(Test::Unit::TestCase::STARTED, &method(:test_started))
56
+ add_listener(Test::Unit::TestCase::FINISHED, &method(:test_finished))
57
+ add_listener(Test::Unit::TestResult::FAULT, &method(:fault))
58
+ end
59
+ def get_class_name(full_test_name) #:nodoc:
60
+ begin
61
+ name=full_test_name
62
+ name=name.gsub(/[)]/,'')
63
+ name_arr=name.split('(')
64
+ return [name_arr[1].gsub(/[:]/,'_'),name_arr[0].gsub(/[:]/,'_')]
65
+ rescue
66
+ return ['Ruby test',full_test_name]
67
+ end
68
+ end
69
+ #This method initializes new test run
70
+ #
71
+ # === params
72
+ # === returns
73
+ # === raises
74
+ def started(result)
75
+ start_run()
76
+ add_report_group(@current_suite_name+'|')
77
+ end
78
+ #This method starts a new test case
79
+ #
80
+ # === params
81
+ # === returns
82
+ # === raises
83
+ def test_started(name)
84
+ full_name=get_class_name(name)
85
+ @current_test_name=full_name[1]
86
+ add_report_group(@current_suite_name+':'+full_name[0]+'|')
87
+ start_test_case(@current_test_name)
88
+ add_test_case_group(full_name[0])
89
+ @tc_result='passed'
90
+ end
91
+ #This method records the test case result
92
+ #
93
+ # === params
94
+ # === returns
95
+ # === raises
96
+ def test_finished(name)
97
+ if @tc_result=='passed'
98
+ update_test_case('-')
99
+ end
100
+ end_test_case(@current_test_name,@tc_result)
101
+ end
102
+ #This method records the test case fault result
103
+ #
104
+ # === params
105
+ # === returns
106
+ # === raises
107
+ def fault(fault)
108
+ capture_screen_test_case()
109
+ update_test_case(fault)
110
+ @tc_result='failed'
111
+ end
112
+ end
113
+ "
114
+ end
115
+
116
+ def TDriverReportTestUnit.included(mod)
117
+
118
+ create_test_unit_formatter()
119
+ create_global_reporter_hook_for_test_unit()
120
+
121
+ end
122
+
123
+ end
124
+
125
+ module TDriverReport
126
+ def create_test_unit_formatter()
127
+ $stderr.puts "Warning: TDriverReport#create_test_unit_formatter() is deprecated please use only \"include TDriverReportTestUnit\" instead of
128
+ begin
129
+ include TDriverReport
130
+ create_test_unit_formatter()
131
+ end
132
+ module Test #:nodoc:all
133
+ module Unit
134
+ module UI
135
+ module Console
136
+ class TestRunner
137
+ def create_mediator(suite)
138
+ # swap in TDriver custom mediator
139
+ return TDriverReport::TestUnit.new(suite)
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
146
+ "
147
+ eval "
148
+ require 'test/unit'
149
+ require 'test/unit/ui/console/testrunner'
150
+ #class for listening test unit execution process
151
+ class TestUnit < Test::Unit::UI::TestRunnerMediator
152
+ include TDriverReportCreator
153
+ def initialize(suite, report_mgr = nil)
154
+ super(suite)
155
+ @tc_result=nil
156
+ @current_suite_name=suite.name
157
+ @current_test_name=nil
158
+ add_listener(Test::Unit::UI::TestRunnerMediator::STARTED, &method(:started))
159
+ add_listener(Test::Unit::TestCase::STARTED, &method(:test_started))
160
+ add_listener(Test::Unit::TestCase::FINISHED, &method(:test_finished))
161
+ add_listener(Test::Unit::TestResult::FAULT, &method(:fault))
162
+ end
163
+ def get_class_name(full_test_name) #:nodoc:
164
+ begin
165
+ name=full_test_name
166
+ name=name.gsub(/[)]/,'')
167
+ name_arr=name.split('(')
168
+ return [name_arr[1].gsub(/[:]/,'_'),name_arr[0].gsub(/[:]/,'_')]
169
+ rescue
170
+ return ['Ruby test',full_test_name]
171
+ end
172
+ end
173
+ #This method initializes new test run
174
+ #
175
+ # === params
176
+ # === returns
177
+ # === raises
178
+ def started(result)
179
+ start_run()
180
+ add_report_group(@current_suite_name+'|')
181
+ end
182
+ #This method starts a new test case
183
+ #
184
+ # === params
185
+ # === returns
186
+ # === raises
187
+ def test_started(name)
188
+ full_name=get_class_name(name)
189
+ @current_test_name=full_name[1]
190
+ add_report_group(@current_suite_name+':'+full_name[0]+'|')
191
+ start_test_case(@current_test_name)
192
+ add_test_case_group(full_name[0])
193
+ @tc_result='passed'
194
+ end
195
+ #This method records the test case result
196
+ #
197
+ # === params
198
+ # === returns
199
+ # === raises
200
+ def test_finished(name)
201
+ if @tc_result=='passed'
202
+ update_test_case('-')
203
+ end
204
+ end_test_case(@current_test_name,@tc_result)
205
+ end
206
+ #This method records the test case fault result
207
+ #
208
+ # === params
209
+ # === returns
210
+ # === raises
211
+ def fault(fault)
212
+ capture_screen_test_case()
213
+ update_test_case(fault)
214
+ @tc_result='failed'
215
+ end
216
+ end
217
+ "
218
+ end
219
+ end
220
+
221
+
222
+
223
+
@@ -0,0 +1,1621 @@
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 TDriverReportWriter
21
+
22
+ def write_style_sheet(page)
23
+ css='body
24
+ {
25
+ background-color:#74C2E1;
26
+ font-family: sans-serif;
27
+ font-size: small;
28
+ }
29
+ .navigation_section
30
+ {
31
+ background-color:#0191C8;
32
+ width:1024px;
33
+ height:40px;
34
+ margin-left : auto;
35
+ margin-right: auto;
36
+ font-family: sans-serif;
37
+ font-size: medium;
38
+ -webkit-box-shadow: 5px 5px 8px #818181;
39
+ -moz-box-shadow: 5px 5px 8px #818181;
40
+ -moz-border-radius: 9px 9px 9px 9px;
41
+ -webkit-border-radius: 9px;
42
+ -webkit-border-top-left-radius: 9px;
43
+ -webkit-border-bottom-right-radius: 9px;
44
+
45
+ }
46
+ .page_navigation_section
47
+ {
48
+ background-color:#0191C8;
49
+ width:1024px;
50
+ height:40px;
51
+ margin-left : auto;
52
+ margin-right: auto;
53
+ font-family: sans-serif;
54
+ font-size: medium;
55
+ -webkit-box-shadow: 5px 5px 8px #818181;
56
+ -moz-box-shadow: 5px 5px 8px #818181;
57
+ -moz-border-radius: 9px 9px 9px 9px;
58
+ -webkit-border-radius: 9px;
59
+ -webkit-border-top-left-radius: 9px;
60
+ -webkit-border-bottom-right-radius: 9px;
61
+
62
+ }
63
+
64
+
65
+ .summary
66
+ {
67
+ background-color:White;
68
+ width:1024px;
69
+ height:100%;
70
+ margin-left : auto;
71
+ margin-right: auto;
72
+ -webkit-box-shadow: 5px 5px 8px #818181;
73
+ -moz-box-shadow: 5px 5px 8px #818181;
74
+ -moz-border-radius: 9px 9px 9px 9px;
75
+ -webkit-border-radius: 9px;
76
+ -webkit-border-top-left-radius: 9px;
77
+ -webkit-border-bottom-right-radius: 9px;
78
+
79
+ }
80
+ .summary_total_run
81
+ {
82
+ background-color:White;
83
+ width:1024px;
84
+ height:100%;
85
+ margin-left : auto;
86
+ margin-right: auto;
87
+ -webkit-box-shadow: 5px 5px 8px #818181;
88
+ -moz-box-shadow: 5px 5px 8px #818181;
89
+ -moz-border-radius: 9px 9px 9px 9px;
90
+ -webkit-border-radius: 9px;
91
+ -webkit-border-top-left-radius: 9px;
92
+ -webkit-border-bottom-right-radius: 9px;
93
+
94
+ }
95
+ .summary_passed
96
+ {
97
+ background-color:White;
98
+ width:1024px;
99
+ height:100%;
100
+ margin-left : auto;
101
+ margin-right: auto;
102
+ -webkit-box-shadow: 5px 5px 8px #818181;
103
+ -moz-box-shadow: 5px 5px 8px #818181;
104
+ -moz-border-radius: 9px 9px 9px 9px;
105
+ -webkit-border-radius: 9px;
106
+ -webkit-border-top-left-radius: 9px;
107
+ -webkit-border-bottom-right-radius: 9px;
108
+
109
+ }
110
+ .summary_crash
111
+ {
112
+ background-color:White;
113
+ width:1024px;
114
+ height:100%;
115
+ margin-left : auto;
116
+ margin-right: auto;
117
+ -webkit-box-shadow: 5px 5px 8px #818181;
118
+ -moz-box-shadow: 5px 5px 8px #818181;
119
+ -moz-border-radius: 9px 9px 9px 9px;
120
+ -webkit-border-radius: 9px;
121
+ -webkit-border-top-left-radius: 9px;
122
+ -webkit-border-bottom-right-radius: 9px;
123
+
124
+ }
125
+ .summary_reboot
126
+ {
127
+ background-color:White;
128
+ width:1024px;
129
+ height:100%;
130
+ margin-left : auto;
131
+ margin-right: auto;
132
+ -webkit-box-shadow: 5px 5px 8px #818181;
133
+ -moz-box-shadow: 5px 5px 8px #818181;
134
+ -moz-border-radius: 9px 9px 9px 9px;
135
+ -webkit-border-radius: 9px;
136
+ -webkit-border-top-left-radius: 9px;
137
+ -webkit-border-bottom-right-radius: 9px;
138
+
139
+ }
140
+ .statistics
141
+ {
142
+ background-color:White;
143
+ width:1024px;
144
+ height:100%;
145
+ margin-left : auto;
146
+ margin-right: auto;
147
+ -webkit-box-shadow: 5px 5px 8px #818181;
148
+ -moz-box-shadow: 5px 5px 8px #818181;
149
+ -moz-border-radius: 9px 9px 9px 9px;
150
+ -webkit-border-radius: 9px;
151
+ -webkit-border-top-left-radius: 9px;
152
+ -webkit-border-bottom-right-radius: 9px;
153
+
154
+ }
155
+ .summary_failed
156
+ {
157
+ background-color:White;
158
+ width:1024px;
159
+ height:100%;
160
+ margin-left : auto;
161
+ margin-right: auto;
162
+ -webkit-box-shadow: 5px 5px 8px #818181;
163
+ -moz-box-shadow: 5px 5px 8px #818181;
164
+ -moz-border-radius: 9px 9px 9px 9px;
165
+ -webkit-border-radius: 9px;
166
+ -webkit-border-top-left-radius: 9px;
167
+ -webkit-border-bottom-right-radius: 9px;
168
+
169
+ }
170
+ .summary_not_run
171
+ {
172
+ background-color:White;
173
+ width:1024px;
174
+ height:100%;
175
+ margin-left : auto;
176
+ margin-right: auto;
177
+ -webkit-box-shadow: 5px 5px 8px #818181;
178
+ -moz-box-shadow: 5px 5px 8px #818181;
179
+ -moz-border-radius: 9px 9px 9px 9px;
180
+ -webkit-border-radius: 9px;
181
+ -webkit-border-top-left-radius: 9px;
182
+ -webkit-border-bottom-right-radius: 9px;
183
+
184
+ }
185
+ .test_passed
186
+ {
187
+ background-color:White;
188
+ width:1024px;
189
+ height:100%;
190
+ margin-left : auto;
191
+ margin-right: auto;
192
+ -webkit-box-shadow: 5px 5px 8px #818181;
193
+ -moz-box-shadow: 5px 5px 8px #818181;
194
+ -moz-border-radius: 9px 9px 9px 9px;
195
+ -webkit-border-radius: 9px;
196
+ -webkit-border-top-left-radius: 9px;
197
+ -webkit-border-bottom-right-radius: 9px;
198
+
199
+ }
200
+ .test_failed
201
+ {
202
+ background-color:White;
203
+ width:1024px;
204
+ height:100%;
205
+ margin-left : auto;
206
+ margin-right: auto;
207
+ -webkit-box-shadow: 5px 5px 8px #818181;
208
+ -moz-box-shadow: 5px 5px 8px #818181;
209
+ -moz-border-radius: 9px 9px 9px 9px;
210
+ -webkit-border-radius: 9px;
211
+ -webkit-border-top-left-radius: 9px;
212
+ -webkit-border-bottom-right-radius: 9px;
213
+
214
+ }
215
+ .test_not_run
216
+ {
217
+ background-color:White;
218
+ width:1024px;
219
+ height:100%;
220
+ margin-left : auto;
221
+ margin-right: auto;
222
+ -webkit-box-shadow: 5px 5px 8px #818181;
223
+ -moz-box-shadow: 5px 5px 8px #818181;
224
+ -moz-border-radius: 9px 9px 9px 9px;
225
+ -webkit-border-radius: 9px;
226
+ -webkit-border-top-left-radius: 9px;
227
+ -webkit-border-bottom-right-radius: 9px;
228
+
229
+ }
230
+ .environment
231
+ {
232
+ background-color:White;
233
+ width:1024px;
234
+ height:100%;
235
+ margin-left : auto;
236
+ margin-right: auto;
237
+ -webkit-box-shadow: 5px 5px 8px #818181;
238
+ -moz-box-shadow: 5px 5px 8px #818181;
239
+ -moz-border-radius: 9px 9px 9px 9px;
240
+ -webkit-border-radius: 9px;
241
+ -webkit-border-top-left-radius: 9px;
242
+ -webkit-border-bottom-right-radius: 9px;
243
+
244
+ }
245
+ .page_title
246
+ {
247
+ background-color:#0191C8;
248
+ width:1024px;
249
+ min-height:100%;
250
+ margin-left : auto;
251
+ margin-right: auto;
252
+ color : white;
253
+ -webkit-box-shadow: 5px 5px 8px #818181;
254
+ -moz-box-shadow: 5px 5px 8px #818181;
255
+ -moz-border-radius: 9px 9px 9px 9px;
256
+ -webkit-border-radius: 9px;
257
+ -webkit-border-top-left-radius: 9px;
258
+ -webkit-border-bottom-right-radius: 9px;
259
+
260
+ }
261
+ .table
262
+ {
263
+ width: 100%;
264
+ -webkit-box-shadow: 5px 5px 8px #818181;
265
+ -moz-box-shadow: 5px 5px 8px #818181;
266
+ -moz-border-radius: 9px 9px 9px 9px;
267
+ -webkit-border-radius: 9px;
268
+ -webkit-border-top-left-radius: 9px;
269
+ -webkit-border-bottom-right-radius: 9px;
270
+
271
+ }
272
+ a:link { color:Black;}
273
+ a:visited { color:Black;}
274
+ a:hover { color:White; background-color:#005B9A;}
275
+
276
+ #navigation
277
+ {
278
+ list-style-type:none;
279
+ padding:10px 10px 20px 10px;
280
+ width: 47em;
281
+ margin: auto;
282
+ }
283
+
284
+ #navigation li {
285
+ float:left;
286
+ margin:0 2px;
287
+ }
288
+ #navigation li a {
289
+ display:block;
290
+ padding:2px 10px;
291
+ background-color:#E0E0E0;
292
+ color:#2E3C1F;
293
+ text-decoration:none;
294
+ }
295
+ #navigation li a.current {
296
+ background-color:#74C2E1;
297
+ color:#FFFFFF;
298
+ }
299
+ #navigation_tabs_ul li a.current {
300
+ background-color:#74C2E1;
301
+ color:Black;
302
+ }
303
+ #navigation li a:hover {
304
+ background-color:#3C72B0;
305
+ color:#FFFFFF;
306
+ }
307
+ #failed_case
308
+ {
309
+ background-color:Red;
310
+ }
311
+ #passed_case
312
+ {
313
+ background-color:Lime;
314
+ }
315
+ #not_run_case
316
+ {
317
+ background-color:#E0E0E0;
318
+ }
319
+
320
+ #statistics_table
321
+ {
322
+ font-size: 12px;
323
+ text-align: left;
324
+ border-collapse: collapse;
325
+ }
326
+ #statistics_table th
327
+ {
328
+ padding: 8px;
329
+ border-bottom: 1px solid Black;
330
+ color: #669;
331
+ border-top: 1px solid transparent;
332
+ }
333
+ #statistics_table td
334
+ {
335
+ padding: 8px;
336
+ border-bottom: 1px solid Black;
337
+ color: #669;
338
+ border-top: 1px solid transparent;
339
+ }
340
+
341
+
342
+ .navigation_tabs{
343
+ width: 100%;
344
+ overflow: hidden;
345
+
346
+ }
347
+
348
+ .navigation_tabs ul{
349
+ margin: 0;
350
+ padding: 0;
351
+ padding-left: 100px; /*offset of tabs relative to browser left edge*/
352
+ font: bold 12px sans-serif;
353
+ list-style-type: none;
354
+ }
355
+
356
+ .navigation_tabs li{
357
+ display: inline;
358
+ margin: 0;
359
+ }
360
+
361
+ .navigation_tabs li a{
362
+ float: left;
363
+ display: block;
364
+ text-decoration: none;
365
+ margin: 0;
366
+ padding: 13px 8px; /*padding inside each tab*/
367
+ border-right: 1px solid white; /*right divider between tabs*/
368
+ color: white;
369
+ background: #0191C8; /*background of tabs (default state)*/
370
+ }
371
+
372
+ .navigation_tabs li a:visited{
373
+ color: white;
374
+ }
375
+
376
+ .navigation_tabs li a:hover, .navigation_tabs li.selected a{
377
+ background: black; /*background of tabs for hover state, plus tab with "selected" class assigned to its LI */
378
+ }
379
+
380
+
381
+ div.img
382
+ {
383
+ margin:2px;
384
+ border:0px;
385
+ height:auto;
386
+ width:auto;
387
+ text-align:left;
388
+ }
389
+ div.img img
390
+ {
391
+ display:inline;
392
+ margin:3px;
393
+ border:0px;
394
+ }
395
+ div.img a:hover img
396
+ {
397
+ border:1px solid #0000ff;
398
+ height:20%;
399
+ width:20%;
400
+ }
401
+ div.desc
402
+ {
403
+ text-align:left;
404
+ font-weight:normal;
405
+ width:120px;
406
+ margin:3px;
407
+ }
408
+
409
+ .togList
410
+ {
411
+
412
+ }
413
+
414
+ .togList dt
415
+ {
416
+
417
+ }
418
+
419
+ .togList dt span
420
+ {
421
+
422
+ }
423
+
424
+ .togList dd
425
+ {
426
+ width: 90%;
427
+ padding-bottom: 15px;
428
+ }
429
+
430
+ FORM { DISPLAY:inline; }
431
+
432
+ html.isJS .togList dd
433
+ {
434
+ display: block;
435
+ }
436
+ input.btn {
437
+ color:#050;
438
+ font: bold 84% \'trebuchet ms\',helvetica,sans-serif;
439
+ border: 1px solid;
440
+ border-color: #696 #363 #363 #696;
441
+ }
442
+ input.btn:hover{
443
+ background-color:#dff4ff;
444
+ border:1px solid #c2e1ef;
445
+ color:#336699;
446
+ }
447
+
448
+ .behaviour_table_title
449
+ {
450
+ background-color:#CCCCCC;
451
+ }
452
+ .user_data_table_title
453
+ {
454
+ background-color:#CCCCCC;
455
+ }
456
+
457
+ '
458
+ File.open(page, 'w') {|f| f.write(css) }
459
+ css=nil
460
+ end
461
+
462
+ def format_duration(seconds)
463
+ begin
464
+ require 'chronic_duration'
465
+ duration_str=ChronicDuration.output(seconds)
466
+ rescue LoadError
467
+ m, s = seconds.divmod(60)
468
+ duration_str="#{m}m#{'%.3f' % s}s"
469
+ end
470
+ duration_str='0' if duration_str==nil
471
+ duration_str
472
+ end
473
+
474
+ def write_stack_file_to_html(file,page,linen)
475
+ code=File.read(file)
476
+ html_code=[]
477
+ code_line=1
478
+ code.each do |line|
479
+ if linen.to_s==code_line.to_s
480
+ html_code << "<b><a style=\"color: #FF0000\" name=\"#{code_line}\">#{code_line}: #{line.gsub(' ','&nbsp;' )} </a></b><br />"
481
+ else
482
+ html_code << "<a name=\"#{code_line}\">#{code_line}: #{line.gsub(' ','&nbsp;' )} </a><br />"
483
+ end
484
+ code_line+=1
485
+ end
486
+ File.open(page, 'w') do |f2|
487
+ f2.puts html_code
488
+ end
489
+ end
490
+
491
+ def copy_code_file_to_test_case_report(file,folder,linen,time_stamp)
492
+ begin
493
+ FileUtils.mkdir_p(folder.to_s+'/stack_files') if File::directory?(folder.to_s+'/stack_files')==false
494
+ if File.directory?("#{Dir.pwd}/#{@report_folder}/#{folder}")
495
+ write_stack_file_to_html(file,"#{Dir.pwd}/#{@report_folder}/#{folder}/stack_files/stk_#{time_stamp}.html",linen)
496
+ FileUtils.copy(file,"#{Dir.pwd}/#{@report_folder}/#{folder}/stack_files/stk_#{time_stamp}.rb")
497
+ else
498
+ write_stack_file_to_html(file,"#{folder}/stack_files/stk_#{time_stamp}.html",linen)
499
+ FileUtils.copy(file,"#{folder}/stack_files/stk_#{time_stamp}.rb")
500
+ end
501
+
502
+ rescue Exception => e
503
+ puts e.message
504
+ puts e.backtrace
505
+ end
506
+ end
507
+
508
+ def reporter_link_to_code(log_line,folder=nil)
509
+ begin
510
+ stackno=0
511
+ log_line.gsub(/([\w \*\/\w\/\.-]+)\:(\d+)/) do |match|
512
+ t = Time.now
513
+ time_stamp="#{t.strftime( "%Y%m%d%H%M%S" )}#{stackno}"
514
+ line=match[/\:(\d+)/]
515
+ f=match[/([\w \*\/\w\/\.-]+)/]
516
+ file="#{File.dirname(f.strip)}/#{File.basename(f.strip)}"
517
+ file = file if File.exist?(file)
518
+ file = "#{Dir.pwd}/#{file}" if File.exist?("#{Dir.pwd}/#{file}")
519
+ if File.exist?(file) && match.include?('testability-driver')==false
520
+ copy_code_file_to_test_case_report(file,folder,line.gsub(':','').strip,time_stamp)
521
+ link_to_stack='<a style="color: #FF0000" href="stack_files/stk_'<<
522
+ time_stamp+'.html#'+line.to_s.gsub(':','')<<
523
+ '">'+match+'</a>'
524
+ log_line=log_line.gsub(match,link_to_stack)
525
+ end
526
+ stackno+=1
527
+ end
528
+ rescue Exception => e
529
+ puts e.message
530
+ puts e.backtrace
531
+ end
532
+ log_line
533
+ end
534
+
535
+ def behaviour_log_summary(log,log_format='string')
536
+ begin
537
+ log_table = Array.new
538
+ pass=0
539
+ fail=0
540
+ #behaviour=0
541
+ warning=0
542
+ debug=0
543
+ info=0
544
+ error=0
545
+ fatal=0
546
+ log_table << '<table width=60% border="1">'
547
+ log_table << '<tr class="behaviour_table_title"><td><b>BEHAVIOUR</b></td><td><b>Total</b></td></tr>'
548
+ log.each do |log_row|
549
+ if log_row[0].include? 'PASS'
550
+ pass+=1
551
+ end
552
+ if log_row[0].include? 'FAIL'
553
+ fail+=1
554
+ end
555
+ #if log_row.include? 'BEHAVIOUR'
556
+ # behaviour+=1
557
+ #end
558
+ if log_row[0].include? 'WARNING'
559
+ warning+=1
560
+ end
561
+ if log_row[0].include? 'DEBUG'
562
+ debug+=1
563
+ end
564
+ if log_row[0].include? 'INFO'
565
+ info+=1
566
+ end
567
+ if log_row[0].include? 'ERROR'
568
+ error+=1
569
+ end
570
+ if log_row[0].include? 'FATAL'
571
+ fatal+=1
572
+ end
573
+ end
574
+ log_table << '<tr><td>PASS:</td><td>'+pass.to_s+'</td></tr>'
575
+ log_table << '<tr><td>FAIL:</td><td>'+fail.to_s+'</td></tr>'
576
+ #log_table << '<tr><td>BEHAVIOUR:</td><td>'+behaviour.to_s+'</td></tr>'
577
+ log_table << '<tr><td>WARNING:</td><td>'+warning.to_s+'</td></tr>'
578
+ log_table << '<tr><td>DEBUG:</td><td>'+debug.to_s+'</td></tr>'
579
+ log_table << '<tr><td>INFO:</td><td>'+info.to_s+'</td></tr>'
580
+ log_table << '<tr><td>ERROR:</td><td>'+error.to_s+'</td></tr>'
581
+ log_table << '<tr><td>FATAL:</td><td>'+fatal.to_s+'</td></tr>'
582
+ log_table << '</table>'
583
+ if log_format=='string'
584
+ log_table.join
585
+ else
586
+ log_table
587
+ end
588
+ rescue
589
+ '-'
590
+ end
591
+ end
592
+ def format_behaviour_log(log,log_format='string')
593
+ begin
594
+ log_table = Array.new
595
+ log_table << '<table border="1">'
596
+ log_table << '<tr class="behaviour_table_title"><td><b>TDriver</b></td><td><b>Log</b></td><td><b>Status</b></td></tr>'
597
+ log.each do |log_row|
598
+ status='-'
599
+ type='-'
600
+ log_entry='-'
601
+ if log_row[0].include? 'PASS'
602
+ status='<b style="color: #00FF00">PASS</b>'
603
+ end
604
+ if log_row[0].include? 'FAIL'
605
+ status='<b style="color: #FF0000">FAIL</b>'
606
+ end
607
+ if log_row[0].include? 'BEHAVIOUR'
608
+ type='<b>BEHAVIOUR</b>'
609
+ end
610
+ if log_row[0].include? 'WARNING'
611
+ type='<b style="color: #FF00FF">WARNING<b>'
612
+ end
613
+ if log_row[0].include? 'DEBUG'
614
+ type='DEBUG'
615
+ end
616
+ if log_row[0].include? 'INFO'
617
+ type='<b style="color: #00FF00">INFO</b>'
618
+ end
619
+ if log_row[0].include? 'ERROR'
620
+ type='<b style="color: #FF0000">ERROR</b>'
621
+ end
622
+ if log_row[0].include? 'FATAL'
623
+ type='<b style="color: #FF0000">FATAL</b>'
624
+ end
625
+
626
+ formatted_log=log_row[0].gsub('PASS;','')
627
+ formatted_log=formatted_log.gsub('FAIL;','')
628
+ formatted_log=formatted_log.gsub('BEHAVIOUR TDriver:','')
629
+ formatted_log=formatted_log.gsub('[TDriver] [BEHAVIOUR]','')
630
+ formatted_log=formatted_log.gsub('WARNING;','')
631
+ formatted_log=formatted_log.gsub('DEBUG TDriver:','')
632
+ formatted_log=formatted_log.gsub('INFO TDriver:','')
633
+ formatted_log=formatted_log.gsub('ERROR TDriver:','')
634
+ formatted_log=formatted_log.gsub('FATAL TDriver:','')
635
+ log_entry=formatted_log
636
+ formatted_log=nil
637
+ if log_row[1] != nil
638
+ log_table << '<tr><td>'+type+'</td><td><a href="'+log_row[1].to_s+'/index.html">'+log_entry+'</a></td><td>'+status+'</td></tr>'
639
+ else
640
+ log_table << '<tr><td>'+type+'</td><td>'+log_entry+'</td><td>'+status+'</td></tr>'
641
+ end
642
+
643
+ end
644
+ log_table << '</table>'
645
+ if log_format=='string'
646
+ log_table.join
647
+ else
648
+ log_table
649
+ end
650
+ rescue
651
+ '-'
652
+ end
653
+ end
654
+
655
+ def format_execution_log(log,folder=nil)
656
+ begin
657
+ formatted_log=Array.new
658
+ log.each do |line|
659
+ line=reporter_link_to_code(line,folder)
660
+ if line.include?('testability-driver')==false
661
+ formatted_log << line.gsub('PASSED','<b style="color: #00FF00">PASSED</b>').gsub('FAILED','<b style="color: #FF0000">FAILED</b>').gsub('SKIPPED','<b>SKIPPED</b>')
662
+ else
663
+ formatted_log << "<b style=\"color: #2554C7\">#{line}</b>".gsub('PASSED','<b style="color: #00FF00">PASSED</b>').gsub('FAILED','<b style="color: #FF0000">FAILED</b>').gsub('SKIPPED','<b>SKIPPED</b>')
664
+ end
665
+ end
666
+ formatted_log.to_s
667
+ rescue
668
+ '-'
669
+ end
670
+ end
671
+
672
+ def write_page_start(page, title,report_page=nil,report_pages=nil)
673
+ case title
674
+ when "TDriver test results"
675
+ stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="tdriver_report_style.css"/>'
676
+ when "TDriver test environment","Total run","Statistics","Passed","Failed","Not run","Crash","Reboot","Connection Errors", "TDriver log"
677
+ stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="../tdriver_report_style.css"/>'
678
+ else
679
+ if title.include?("Test:")
680
+ stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="../tdriver_report_style.css"/>'
681
+ else
682
+ stylesheet='<link rel="stylesheet" title="TDriverReportStyle" href="../../tdriver_report_style.css"/>'
683
+ end
684
+
685
+ end
686
+ html_start='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' <<
687
+ '<html xmlns="http://www.w3.org/1999/xhtml">'<<
688
+ '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">'<<
689
+ stylesheet<<
690
+ get_java_script<<
691
+ '<title>'+title+'</title>'<<
692
+ '</head><body>'
693
+ File.open(page, 'w') do |f2|
694
+ f2.puts html_start
695
+ end
696
+ html_start=nil
697
+ stylesheet=nil
698
+ write_navigation_menu(page,title,report_page,report_pages)
699
+ page=nil
700
+ title=nil
701
+ end
702
+ def write_test_case_body(page,test_case_name,start_time,end_time,run_time,status,index,folder,capture_screen_error,failed_dump_error,reboots=0,total_dump_count=nil,total_data_sent=nil,total_data_received=nil)
703
+ status_style='test_passed' if status=='passed' || @pass_statuses.include?(status)
704
+ status_style='test_failed' if status=='failed' || @fail_statuses.include?(status)
705
+ status_style='test_not_run' if status=='not run' || @not_run_statuses.include?(status)
706
+
707
+ begin
708
+ used_memory_difference=@tc_memory_amount_start.to_i-@tc_memory_amount_end.to_i
709
+ rescue
710
+ used_memory_difference='-'
711
+ end
712
+ formatted_test_case_name=test_case_name.gsub('_',' ')
713
+ if formatted_test_case_name==nil
714
+ formatted_test_case_name=test_case_name
715
+ end
716
+ html_body='<div class="page_title"><center><h1>',formatted_test_case_name,'</h1></center></div>'<<
717
+ '<div class="'<<
718
+ status_style<<
719
+ '"><table align="center" style="width:100%;">'<<
720
+ '<tr>'<<
721
+ '<td style="font-weight: 700">'<<
722
+ 'Case</td>'<<
723
+ '<td>'<<
724
+ index.to_s,'</td>'<<
725
+ '</tr>'<<
726
+ '<tr>'<<
727
+ '<td style="font-weight: 700">'<<
728
+ 'Status</td>'<<
729
+ '<td>'<<
730
+ status,'</td>'<<
731
+ '</tr>'<<
732
+ '<tr>'<<
733
+ '<td style="font-weight: 700">'<<
734
+ 'Started</td>'<<
735
+ '<td>'<<
736
+ start_time.strftime("%d.%m.%Y %H:%M:%S"),'</td>'<<
737
+ '</tr>'<<
738
+ '<tr>'<<
739
+ '<td style="font-weight: 700">'<<
740
+ 'Ended</td>'<<
741
+ '<td>'<<
742
+ end_time.strftime("%d.%m.%Y %H:%M:%S"),'</td>'<<
743
+ '</tr>'<<
744
+ '<tr>'<<
745
+ '<td style="font-weight: 700">'<<
746
+ 'Runtime</td>'<<
747
+ '<td>'<<
748
+ format_duration(run_time)+'</td>'<<
749
+ '</tr>'
750
+
751
+ total_dump_count.each do |item|
752
+ html_body << '<tr>'<<
753
+ '<td style="font-weight: 700">'<<
754
+ "Dump count from sut #{item[0]}</td>"<<
755
+ '<td>'<<
756
+ item[1].to_s+'</td>'<<
757
+ '</tr>'
758
+ end
759
+
760
+ total_data_sent.each do |item|
761
+ html_body << '<tr>' <<
762
+ '<td style="font-weight: 700">'<<
763
+ "Sent bytes from sut #{item[0]}</td>"<<
764
+ '<td>'<<
765
+ item[1].to_s+'</td>'<<
766
+ '</tr>'
767
+ end
768
+
769
+ total_data_received.each do |item|
770
+ html_body << '<tr>' <<
771
+ '<td style="font-weight: 700">'<<
772
+ "Received bytes from sut #{item[0]}</td>"<<
773
+ '<td>'<<
774
+ item[1].to_s+'</td>'<<
775
+ '</tr>'
776
+ end
777
+
778
+ html_body << '<tr><td><b>Total memory</b></td><td>'<<
779
+ @tc_memory_amount_total.to_s<<
780
+ '</td></tr>'<<
781
+ '<tr><td><b>Used memory at beginning</b></td><td>'<<
782
+ @tc_memory_amount_start.to_s<<
783
+ '</td></tr>'<<
784
+ '<tr><td><b>Used memory at end</b></td><td>'<<
785
+ @tc_memory_amount_end.to_s<<
786
+ '</td></tr>'<<
787
+ '<tr><td><b>Used memory difference</b></td><td>'<<
788
+ used_memory_difference.to_s<<
789
+ '</td></tr>' <<
790
+ '<tr><td><b>Device reboots</b></td><td>'<<
791
+ reboots.to_s <<
792
+ '</td></tr>'
793
+ if $parameters[ :report_generate_rdoc, 'false' ]=='true' && test_case_name.include?('test_')
794
+ html_body << '<tr>' <<
795
+ '<td style="font-weight: 700">'<<
796
+ 'RDoc</td>'<<
797
+ '<td style="font-size: small; font-weight: bold">'<<
798
+ get_rdoc_for_method(test_case_name)<<
799
+ '</td></tr>'
800
+ end
801
+
802
+ html_body << '<tr>' <<
803
+ '<td style="font-weight: 700">'<<
804
+ 'Details</td>'<<
805
+ '<td style="font-size: small; font-weight: bold">'<<
806
+ format_execution_log(@test_case_execution_log,folder.to_s)<<
807
+ '</td></tr>'
808
+
809
+ if File::directory?(folder.to_s+'/crash_files')==true
810
+ d=Dir.entries(folder.to_s+'/crash_files')
811
+ d.each do |x|
812
+ if (x !='.' && x != '..')
813
+ html_body=html_body<<
814
+ '<tr>'<<
815
+ '<td style="font-weight: 700">'<<
816
+ '&nbsp;</td>'<<
817
+ '<td>'<<
818
+ '<a href="crash_files/'<<
819
+ x<<
820
+ '">'+x+'</a></td>'<<
821
+ '</tr>'
822
+ end
823
+ end
824
+ end
825
+ if File::directory?(folder.to_s+'/trace_files')==true
826
+ d=Dir.entries(folder.to_s+'/trace_files')
827
+ d.each do |x|
828
+ if (x !='.' && x != '..')
829
+ html_body=html_body<<
830
+ '<tr>'<<
831
+ '<td style="font-weight: 700">'<<
832
+ 'Trace files</td>'<<
833
+ '<td>'<<
834
+ '<a href="trace_files/'<<
835
+ x<<
836
+ '">Captured trace files</a></td>'<<
837
+ '</tr>'
838
+ end
839
+ end
840
+ end
841
+ if File::directory?(folder.to_s+'/video')==true
842
+ d=Dir.entries(folder.to_s+'/video')
843
+ html_body=html_body<<
844
+ '<tr>'<<
845
+ '<td style="font-weight: 700">'<<
846
+ 'Video files</td>'<<
847
+ '</tr>'
848
+ d.each do |x|
849
+ if (x !='.' && x != '..')
850
+ html_body=html_body<<
851
+ '<tr>'<<
852
+ '<td style="font-weight: 700">'<<
853
+ '&nbsp;</td>'<<
854
+ '<td>'<<
855
+ '<a href="video/'<<
856
+ x<<
857
+ '">'+x+'</a></td>'<<
858
+ '</tr>'
859
+ end
860
+ end
861
+ end
862
+ if File::directory?(folder.to_s+'/files')==true
863
+ d=Dir.entries(folder.to_s+'/files')
864
+ html_body=html_body<<
865
+ '<tr>'<<
866
+ '<td style="font-weight: 700">'<<
867
+ 'Monitored files</td>'<<
868
+ '</tr>'
869
+ d.each do |x|
870
+ if (x !='.' && x != '..')
871
+ html_body=html_body<<
872
+ '<tr>'<<
873
+ '<td style="font-weight: 700">'<<
874
+ '&nbsp;</td>'<<
875
+ '<td>'<<
876
+ '<a href="files/'<<
877
+ x<<
878
+ '">'+x+'</a></td>'<<
879
+ '</tr>'
880
+ end
881
+ end
882
+ end
883
+ html_body=html_body<<
884
+ '<tr><td style="font-weight: 700">'<<
885
+ '&nbsp;</td>'
886
+ html_body=html_body<<
887
+ '</tr>'<<
888
+ '</table>'
889
+ if @test_case_behaviour_log.length > 0
890
+ html_body=html_body<<
891
+ '<dl class="togList">'<<
892
+ '<dt onclick="tog(this)" style="background-color: #CCCCCC;"><b style="font-size: large"><span><input id="Button1" type="button" value="Close" class="btn" /></span> Behaviours</b></dt>'<<
893
+ '<dd style="font-size: small">'<<
894
+ format_behaviour_log(@test_case_behaviour_log)<<
895
+ '</dd>'<<
896
+ '</dl>'
897
+
898
+ end
899
+ if @test_case_user_data!=nil && !@test_case_user_data.empty?
900
+ html_body=html_body<<
901
+ '<dl class="togList">'<<
902
+ '<dt onclick="tog(this)" style="background-color: #CCCCCC;"><b style="font-size: large"><span><input id="Button1" type="button" value="Close" class="btn" /></span> User Data</b></dt>'<<
903
+ '<dd style="font-size: small">'<<
904
+ format_user_log_table( @test_case_user_data,@test_case_user_data_columns)<<
905
+ '</dd>'<<
906
+ '</dl>'
907
+ if $parameters[ :report_generate_duration_graph, false]=='true'
908
+ graph=ReportGraphGenerator.new(@test_case_user_data_columns,@test_case_user_data)
909
+ graph.generate_graph("#{folder}/graph.png")
910
+ html_body=html_body<<
911
+ '<dl class="togList">'<<
912
+ '<dt onclick="tog(this)" style="background-color: #CCCCCC;"><b style="font-size: large"><span><input id="Button1" type="button" value="Close" class="btn" /></span> Graph</b></dt>'<<
913
+ '<dd style="font-size: small">'<<
914
+ '<img border="0" src="graph.png"/>'<<
915
+ '</dd>'<<
916
+ '</dl>'
917
+ end
918
+ end
919
+ html_body=html_body<<
920
+ '</div>'
921
+ File.open(page, 'a') do |f2|
922
+ f2.puts html_body
923
+ end
924
+ html_body=nil
925
+ @test_case_execution_log=nil
926
+ @test_case_behaviour_log=nil
927
+
928
+ end
929
+ def tog_list_begin(name)
930
+ html_body='<dl class="togList">'<<
931
+ '<dt onclick="tog(this)"><b><span>+</span>'<<
932
+ name<<
933
+ '</b></dt>'<<
934
+ '<dd>'
935
+ html_body
936
+ end
937
+ def tog_list_end()
938
+ html_body='</dd>'<<
939
+ '</dl>'
940
+ html_body
941
+ end
942
+ def write_duration_graph(page, folder, graph_file_name, tc_arr)
943
+
944
+ tdriver_group=ReportingStatistics.new(tc_arr)
945
+ tdriver_group.generate_duration_graph(folder + '/cases/' + graph_file_name)
946
+
947
+ html_body=Array.new
948
+ html_body << '<div>'
949
+ html_body << '<H1 ALIGN=center><img border="0" src="./'+graph_file_name+'"/></H1>'
950
+ html_body << '</div>'
951
+ File.open(page, 'a') do |f2|
952
+ f2.puts html_body
953
+ end
954
+ tdriver_group = nil
955
+ html_body=nil
956
+
957
+ end
958
+ def write_test_case_summary_body(page,status,tc_arr,chronological_page=nil,report_page=nil,test_case_name=nil)
959
+ html_body=Array.new
960
+ if @pass_statuses.include?(status) || status == "passed"
961
+ title='<div class="page_title"><center><h1>Passed</h1></center></div>'<<
962
+ '<div class="summary_passed">' <<
963
+ '<form action="save_total_run_results" >'
964
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr)
965
+ tdriver_group.parse_groups()
966
+ html_result=tdriver_group.generate_report(@pass_statuses.first)
967
+ html_body << title
968
+ html_body << html_result
969
+ html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
970
+ html_body << "</form>"
971
+ html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
972
+ tdriver_group=nil
973
+ html_result=nil
974
+ elsif @fail_statuses.include?(status) || status == "failed"
975
+ title='<div class="page_title"><center><h1>Failed</h1></center></div>'<<
976
+ '<div class="summary_failed">' <<
977
+ '<form action="save_total_run_results" >'
978
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr)
979
+ tdriver_group.parse_groups()
980
+ html_result=tdriver_group.generate_report(@fail_statuses.first)
981
+ html_body << title
982
+ html_body << html_result
983
+ html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
984
+ html_body << "</form>"
985
+ html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
986
+ tdriver_group=nil
987
+ html_result=nil
988
+ elsif @not_run_statuses.include?(status) || status == "not_run"
989
+ title='<div class="page_title"><center><h1>Not run</h1></center></div>'<<
990
+ '<div class="summary_not_run">' <<
991
+ '<form action="save_total_run_results" >'
992
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr)
993
+ tdriver_group.parse_groups()
994
+ html_result=tdriver_group.generate_report(@not_run_statuses.first)
995
+ html_body << title
996
+ html_body << html_result
997
+ html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
998
+ html_body << "</form>"
999
+ html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
1000
+ tdriver_group=nil
1001
+ html_result=nil
1002
+ else
1003
+ case status
1004
+ when 'crash'
1005
+ title='<div class="page_title"><center><h1>Crash</h1></center></div>'<<
1006
+ '<div class="summary_crash">' <<
1007
+ '<form action="save_total_run_results" >'
1008
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false)
1009
+ tdriver_group.parse_groups()
1010
+ html_result=tdriver_group.generate_report('all')
1011
+ html_body << title
1012
+ html_body << html_result
1013
+ html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
1014
+ html_body << "</form>"
1015
+ html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
1016
+ tdriver_group=nil
1017
+ html_result=nil
1018
+ when 'reboot'
1019
+ title='<div class="page_title"><center><h1>Reboot</h1></center></div>'<<
1020
+ '<div class="summary_reboot">' <<
1021
+ '<form action="save_total_run_results" >'
1022
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false)
1023
+ tdriver_group.parse_groups()
1024
+ html_result=tdriver_group.generate_report('all')
1025
+ html_body << title
1026
+ html_body << html_result
1027
+ html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
1028
+ html_body << "</form>"
1029
+ html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
1030
+ tdriver_group=nil
1031
+ html_result=nil
1032
+ when 'connection_errors'
1033
+ title='<div class="page_title"><center><h1>Connection Errors</h1></center></div>'<<
1034
+ '<div class="summary_reboot">' <<
1035
+ '<form action="save_total_run_results" >'
1036
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false)
1037
+ tdriver_group.parse_groups()
1038
+ html_result=tdriver_group.generate_report('all')
1039
+ html_body << title
1040
+ html_body << html_result
1041
+ html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
1042
+ html_body << "</form>"
1043
+ html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
1044
+ tdriver_group=nil
1045
+ html_result=nil
1046
+ when 'statistics'
1047
+ title='<div class="page_title"><center><h1>Statistics</h1></center></div>'<<
1048
+ '<div class="statistics">'
1049
+ tdriver_group=ReportingStatistics.new(tc_arr)
1050
+ html_result=tdriver_group.generate_statistics_table()
1051
+ html_body << title
1052
+ html_body << html_result
1053
+ tdriver_group=nil
1054
+ html_result=nil
1055
+ else
1056
+ chronological_html_body=Array.new
1057
+ title='<div class="page_title"><center><h1>Total run</h1></center></div>'
1058
+ view_selection='<div class="summary_view_select"><center><input type="button" value="Grouped view" ONCLICK="location.assign(\''+report_page.to_s+'_total_run_index.html\');"/>'<<
1059
+ '<input type="button" value="Chronological view" ONCLICK="location.assign(\''+report_page.to_s+'_chronological_total_run_index.html\');"/></center></div>'<<
1060
+ '<div class="summary_total_run">' <<
1061
+ '<form action="save_total_run_results" >'
1062
+ title << view_selection
1063
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr)
1064
+ tdriver_group.parse_groups()
1065
+ html_result=tdriver_group.generate_report('all')
1066
+ html_body << title
1067
+ html_body << html_result
1068
+ html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
1069
+ html_body << "</form>"
1070
+ html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
1071
+ html_body << '<form action="export_results_to_excel" ><input type="submit" name="export_results_to_excel" value="Export to Excel" /></form>' if @report_editable=='true'
1072
+
1073
+ tdriver_group=nil
1074
+ html_result=nil
1075
+ tdriver_group=ReportingGroups.new(@reporting_groups,tc_arr,false)
1076
+ tdriver_group.parse_groups()
1077
+ chronological_html_result=tdriver_group.generate_report('all')
1078
+ chronological_html_body << title
1079
+ chronological_html_body << chronological_html_result
1080
+ chronological_html_body << "<input type=\"submit\" name=\"save_changes\" value=\"Save changes\" />" if @report_editable=='true'
1081
+ chronological_html_body << "</form>"
1082
+ chronological_html_body << '<form action="save_results_to" ><input type="submit" name="save_results_to" value="Download report" /></form>' if @report_editable=='true'
1083
+ chronological_html_body << '<form action="export_results_to_excel" ><input type="submit" name="export_results_to_excel" value="Export to Excel" /></form>' if @report_editable=='true'
1084
+ chronological_html_body << "</div>"
1085
+
1086
+ File.open(chronological_page, 'a') do |f2|
1087
+ f2.puts chronological_html_body
1088
+ end
1089
+ tdriver_group=nil
1090
+ chronological_html_result=nil
1091
+ chronological_html_body=nil
1092
+ end # case
1093
+ end # if
1094
+
1095
+ html_body << '</div>'
1096
+ File.open(page, 'a') do |f2|
1097
+ f2.puts html_body
1098
+ end
1099
+ html_body=nil
1100
+
1101
+ end
1102
+
1103
+ def write_summary_body(page,start_time,end_time,run_time,total_run,total_passed,total_failed,total_not_run,total_crash_files,total_device_resets,connection_errors,summary_arr=nil)
1104
+ fail_rate="0"
1105
+ pass_rate="0"
1106
+ if total_run.to_i > total_not_run.to_i
1107
+ begin
1108
+ fail_rate=(total_failed.to_f/(total_run.to_f-total_not_run.to_f))*100
1109
+ pass_rate=(total_passed.to_f/(total_run.to_f-total_not_run.to_f))*100
1110
+ fail_rate="%0.2f" % fail_rate
1111
+ pass_rate="%0.2f" % pass_rate
1112
+ rescue # Note that 0.0/0.0 does result in NaN, it does not cause an exception
1113
+ fail_rate="0"
1114
+ pass_rate="0"
1115
+ end
1116
+ end
1117
+
1118
+ html_body='<div class="page_title"><center><h1>TDriver test results</h1></center></div>'<<
1119
+ '<div class="summary"><table align="center" style="width:80%;" border="0">'<<
1120
+ '<tr>'<<
1121
+ '<td><b>Started</b></td>'<<
1122
+ '<td>'+start_time.strftime("%d.%m.%Y %H:%M:%S")+'</td>'<<
1123
+ '</tr>'<<
1124
+ '<tr>'<<
1125
+ '<td><a href="exit.html"><b>Ended</b></a></td>'
1126
+ begin
1127
+ html_body+='<td>'+end_time.strftime("%d.%m.%Y %H:%M:%S")+'</td>'
1128
+ rescue
1129
+ html_body+='<td>'+end_time.to_s+'</td>'
1130
+ end
1131
+ html_body+='</tr>'<<
1132
+ '<tr>'<<
1133
+ '<td><b>Runtime</b></td>'<<
1134
+ '<td>'+format_duration(run_time)+'</td>'<<
1135
+ '</tr>'<<
1136
+ '<tr>'<<
1137
+ '<td><a href="cases/1_total_run_index.html"><b>Total run</b></a></td>'<<
1138
+ '<td>'+total_run.to_s+'</td>'<<
1139
+ '</tr>'<<
1140
+ '<tr>'<<
1141
+ '<td><a href="cases/1_passed_index.html"><b>Passed</b></a></td>'<<
1142
+ '<td>'+total_passed.to_s+'</td>'<<
1143
+ '</tr>'<<
1144
+ '<tr>'<<
1145
+ '<td><a href="cases/1_failed_index.html"><b>Failed</b></a></td>'<<
1146
+ '<td>'+total_failed.to_s+'</td>'<<
1147
+ '</tr>'<<
1148
+ '<tr>'<<
1149
+ '<td><a href="cases/1_not_run_index.html"><b>Not run</b></a></td>'<<
1150
+ '<td>'+total_not_run.to_s+'</td>'<<
1151
+ '</tr>'<<
1152
+ '<tr>'<<
1153
+ '<td><b>Total crash files captured</b></td>'<<
1154
+ '<td>'+total_crash_files.to_s+'</td>'<<
1155
+ '</tr>'<<
1156
+ '<tr>'<<
1157
+ '<td><b>Total device resets</b></td>'<<
1158
+ '<td>'+total_device_resets.to_s+'</td>'<<
1159
+ '</tr>'<<
1160
+ '<tr>'<<
1161
+ '<td><b>Total connection errors</b></td>'<<
1162
+ '<td>'+connection_errors.to_s+'</td>'<<
1163
+ '</tr>'
1164
+ if $parameters[ :report_generate_rdoc, 'false' ]=='true'
1165
+ html_body << '<tr>'<<
1166
+ '<td><a href="doc/index.html"><b>Generated RDoc from</b></a></td>'<<
1167
+ '<td>'+Dir.pwd+'</td>'<<
1168
+ '</tr>'
1169
+ end
1170
+ $tdriver_reporter.total_dump_count.each do |item|
1171
+ html_body << '<tr>'<<
1172
+ "<td><b>Total dump count from sut #{item[0].to_s}</b></td>"<<
1173
+ '<td>'+item[1].to_s+'</td>'<<
1174
+ '</tr>'
1175
+ end
1176
+ $tdriver_reporter.total_sent_data.each do |item|
1177
+ html_body << '<tr>'<<
1178
+ "<td><b>Total bytes sent from sut #{item[0].to_s}</b></td>"<<
1179
+ '<td>'+item[1].to_s+'</td>'<<
1180
+ '</tr>'
1181
+ end
1182
+ $tdriver_reporter.total_received_data.each do |item|
1183
+ html_body << '<tr>'<<
1184
+ "<td><b>Total bytes received from sut #{item[0].to_s}</b></td>"<<
1185
+ '<td>'+item[1].to_s+'</td>'<<
1186
+ '</tr>'
1187
+ end
1188
+ html_body << '<tr>'<<
1189
+ '<td><b>Pass %</b></td>'<<
1190
+ '<td>'+pass_rate.to_s+'%</td>'<<
1191
+ '</tr>'<<
1192
+ '<tr>'<<
1193
+ '<td><b>Fail %</b></td>'<<
1194
+ '<td>'+fail_rate.to_s+'%</td>'<<
1195
+ '</tr>'<<
1196
+ '</table></div><p />'
1197
+ if summary_arr
1198
+ html_body << '<div class="statistics">'
1199
+ tdriver_group=ReportingStatistics.new(summary_arr,true)
1200
+ html_result=tdriver_group.generate_statistics_table()
1201
+ html_body << html_result << '</div>'
1202
+ end
1203
+
1204
+ File.open(page, 'a') do |f2|
1205
+ f2.puts html_body
1206
+ end
1207
+ html_body=nil
1208
+ end
1209
+ def create_behaviour_links()
1210
+ folder=@report_folder+'/environment/behaviours'
1211
+ links=' '
1212
+ if File::directory?(folder.to_s)==true
1213
+ d=Dir.entries(folder.to_s)
1214
+ d.each do |x|
1215
+ if (x !='.' && x != '..')
1216
+ if x.include? '.xml'
1217
+ links << '<a href="behaviours/'+x+'">'+x+'</a> <br />'
1218
+ end
1219
+ end
1220
+ end
1221
+ end
1222
+ links
1223
+ end
1224
+
1225
+ def create_templates_links()
1226
+ folder=@report_folder+'/environment/templates'
1227
+ links=' '
1228
+ if File::directory?(folder.to_s)==true
1229
+ d=Dir.entries(folder.to_s)
1230
+ d.each do |x|
1231
+ if (x !='.' && x != '..')
1232
+ if x.include? '.xml'
1233
+ links << '<a href="templates/'+x+'">'+x+'</a> <br />'
1234
+ end
1235
+ end
1236
+ end
1237
+ end
1238
+ links
1239
+ end
1240
+
1241
+ def write_environment_body(page,os,sw,variant,product,language,loc)
1242
+ begin
1243
+ used_memory_difference=@memory_amount_start.to_i-@memory_amount_end.to_i
1244
+ rescue
1245
+ used_memory_difference='-'
1246
+ end
1247
+
1248
+ tdriver_version=ENV['TDRIVER_VERSION']
1249
+ tdriver_version='TDRIVER_VERSION environment variable not found' if tdriver_version==nil
1250
+ html_body='<div class="page_title"><center><h1>TDriver test environment</h1></center></div>'<<
1251
+ '<div class="environment"><table align="center" style="width:80%;" border="0">'<<
1252
+ '<tr><td><b>OS</b></td><td>'<<
1253
+ os<<
1254
+ '</td></tr>'<<
1255
+ '<tr><td><b>TDriver version</b></td><td>'<<
1256
+ tdriver_version<<
1257
+ '</td></tr>'<<
1258
+ '<tr><td><b>SW Version</b></td><td>'<<
1259
+ sw<<
1260
+ '</td></tr>'<<
1261
+ '<tr><td><b>Variant</b></td><td>'<<
1262
+ variant<<
1263
+ '</td></tr>'<<
1264
+ '<tr><td><b>Product</b></td><td>'<<
1265
+ product<<
1266
+ '</td></tr>'<<
1267
+ '<tr><td><b>Language</b></td><td>'<<
1268
+ language<<
1269
+ '</td></tr>'<<
1270
+ '<tr><td><b>Localization</b></td><td>'<<
1271
+ loc<<
1272
+ '</td></tr>'<<
1273
+ '<tr><td><b>Total memory</b></td><td>'<<
1274
+ @memory_amount_total.to_s<<
1275
+ '</td></tr>'<<
1276
+ '<tr><td><b>Used memory at beginning</b></td><td>'<<
1277
+ @memory_amount_start.to_s<<
1278
+ '</td></tr>'<<
1279
+ '<tr><td><b>Used memory at end</b></td><td>'<<
1280
+ @memory_amount_end.to_s<<
1281
+ '</td></tr>'<<
1282
+ '<tr><td><b>Used memory difference</b></td><td>'<<
1283
+ used_memory_difference.to_s<<
1284
+ '</td></tr>'<<
1285
+ "<tr><td><b>Behaviours</b></td><td>#{create_behaviour_links()}</td></tr>"<<
1286
+ '<tr><td><b>Parameters</b></td><td><a href="tdriver_parameters.xml">tdriver_parameters.xml</a></td></tr>'<<
1287
+ "<tr><td><b>Templates</b></td><td>#{create_templates_links()}</td></tr>"<<
1288
+ '</table></div>'
1289
+ create_behaviour_links()
1290
+ File.open(page, 'a') do |f2|
1291
+ f2.puts html_body
1292
+ end
1293
+ html_body=nil
1294
+ end
1295
+
1296
+ def write_exit_body(page,exit_log,folder)
1297
+
1298
+ html_body='<div class="page_title"><center><h1>TDriver execution exit trace</h1></center></div>'<<
1299
+ "<div class=\"environment\">#{format_execution_log(exit_log,folder.to_s)}</div>"
1300
+ create_behaviour_links()
1301
+ File.open(page, 'a') do |f2|
1302
+ f2.puts html_body
1303
+ end
1304
+ html_body=nil
1305
+ end
1306
+
1307
+ def write_tdriver_log_body(page,log)
1308
+ if log.length > 0
1309
+ log_summary=behaviour_log_summary(log,'array')
1310
+ formatted_log=format_behaviour_log(log,'array')
1311
+ File.open(page, 'a') do |f|
1312
+ f.write('<div class="page_title"><center><h1>TDriver Log</h1></center></div>')
1313
+ f.write('<div class="environment">')
1314
+ f.write('<center><H2>Summary</H2>')
1315
+ log_summary.each do |entry|
1316
+ f.write(entry)
1317
+ end
1318
+ f.write('</center><br /><br /></div><br />')
1319
+ f.write('<div class="environment">')
1320
+ formatted_log.each do |entry|
1321
+ f.write(entry)
1322
+ end
1323
+ f.write('</div>')
1324
+ end
1325
+ else
1326
+ File.open(page, 'a') do |f|
1327
+ f.write('<div class="page_title"><center><h1>TDriver Log</h1></center></div>')
1328
+ f.write('<div class="environment">')
1329
+ f.write('<center><H2>Log is empty</H2>')
1330
+ f.write('</center><br /><br /></div><br />')
1331
+ end
1332
+ end
1333
+ end
1334
+ def write_navigation_menu(page,title,report_page=nil,report_pages=nil)
1335
+ case title
1336
+ when "TDriver test results"
1337
+ tdriver_test_results_link='index.html" class="current"'
1338
+ tdriver_test_environment_link='environment/index.html"'
1339
+ tdriver_log_link='cases/tdriver_log_index.html"'
1340
+ total_run_link="cases/1_total_run_index.html\""
1341
+ statistics_link="cases/statistics_index.html\""
1342
+ passed_link="cases/1_passed_index.html\""
1343
+ failed_link="cases/1_failed_index.html\""
1344
+ not_run_link="cases/1_not_run_index.html\""
1345
+ when "TDriver test environment"
1346
+ tdriver_test_results_link='../index.html"'
1347
+ tdriver_test_environment_link='index.html" class="current"'
1348
+ tdriver_log_link='../cases/tdriver_log_index.html"'
1349
+ total_run_link="../cases/1_total_run_index.html\""
1350
+ statistics_link='../cases/statistics_index.html"'
1351
+ passed_link="../cases/1_passed_index.html\""
1352
+ failed_link="../cases/1_failed_index.html\""
1353
+ not_run_link="../cases/1_not_run_index.html\""
1354
+ when "Total run"
1355
+ tdriver_test_results_link='../index.html"'
1356
+ tdriver_test_environment_link='../environment/index.html"'
1357
+ tdriver_log_link='tdriver_log_index.html"'
1358
+ total_run_link="#{report_page}_total_run_index.html\" class=\"current\""
1359
+ statistics_link="statistics_index.html\""
1360
+ passed_link="1_passed_index.html\""
1361
+ failed_link="1_failed_index.html\""
1362
+ not_run_link="1_not_run_index.html\""
1363
+ when "Statistics"
1364
+ tdriver_test_results_link='../index.html"'
1365
+ tdriver_test_environment_link='../environment/index.html"'
1366
+ tdriver_log_link='tdriver_log_index.html"'
1367
+ total_run_link="1_total_run_index.html\""
1368
+ statistics_link='statistics_index.html" class="current"'
1369
+ passed_link="1_passed_index.html\""
1370
+ failed_link="1_failed_index.html\""
1371
+ not_run_link="1_not_run_index.html\""
1372
+ when "Passed"
1373
+ tdriver_test_results_link='../index.html"'
1374
+ tdriver_test_environment_link='../environment/index.html"'
1375
+ tdriver_log_link='tdriver_log_index.html"'
1376
+ total_run_link="1_total_run_index.html\""
1377
+ statistics_link='statistics_index.html"'
1378
+ passed_link="#{report_page}_passed_index.html\" class=\"current\""
1379
+ failed_link="1_failed_index.html\""
1380
+ not_run_link="1_not_run_index.html\""
1381
+ when "Failed","Crash","Reboot", "Connection Errors"
1382
+ tdriver_test_results_link='../index.html"'
1383
+ tdriver_test_environment_link='../environment/index.html"'
1384
+ tdriver_log_link='tdriver_log_index.html"'
1385
+ total_run_link="1_total_run_index.html\""
1386
+ statistics_link='statistics_index.html"'
1387
+ passed_link="1_passed_index.html\""
1388
+ failed_link="#{report_page}_failed_index.html\" class=\"current\""
1389
+ not_run_link="1_not_run_index.html\""
1390
+ when "Not run"
1391
+ tdriver_test_results_link='../index.html"'
1392
+ tdriver_test_environment_link='../environment/index.html"'
1393
+ tdriver_log_link='tdriver_log_index.html"'
1394
+ total_run_link="1_total_run_index.html\""
1395
+ statistics_link='statistics_index.html"'
1396
+ passed_link="1_passed_index.html\""
1397
+ failed_link="1_failed_index.html\""
1398
+ not_run_link="#{report_page}_not_run_index.html\" class=\"current\""
1399
+ when "TDriver log"
1400
+ tdriver_test_results_link='../index.html"'
1401
+ tdriver_test_environment_link='../environment/index.html"'
1402
+ tdriver_log_link='tdriver_log_index.html" class="current"'
1403
+ total_run_link="1_total_run_index.html\""
1404
+ statistics_link='statistics_index.html"'
1405
+ passed_link="1_passed_index.html\""
1406
+ failed_link="1_failed_index.html\""
1407
+ not_run_link="1_not_run_index.html\""
1408
+ else
1409
+ if title.include?("Test:")
1410
+ tdriver_test_results_link='../index.html"'
1411
+ tdriver_test_environment_link='../environment/index.html"'
1412
+ tdriver_log_link='tdriver_log_index.html"'
1413
+ total_run_link="1_total_run_index.html\""
1414
+ statistics_link='statistics_index.html"'
1415
+ passed_link="1_passed_index.html\""
1416
+ failed_link="1_failed_index.html\""
1417
+ not_run_link="1_not_run_index.html\""
1418
+ else
1419
+ tdriver_test_results_link='../../index.html"'
1420
+ tdriver_test_environment_link='../../environment/index.html"'
1421
+ tdriver_log_link='../tdriver_log_index.html"'
1422
+ total_run_link="../1_total_run_index.html\""
1423
+ statistics_link='../statistics_index.html"'
1424
+ passed_link="../1_passed_index.html\""
1425
+ failed_link="../1_failed_index.html\""
1426
+ not_run_link="../1_not_run_index.html\""
1427
+ end
1428
+ end
1429
+ html_body='<div class="navigation_section"><div class="navigation_tabs">'<<
1430
+ '<ul id="navigation_tabs_ul">'<<
1431
+ '<li><a href="'<<
1432
+ tdriver_test_results_link<<
1433
+ '>TDriver test results</a></li>'<<
1434
+ '<li><a href="'<<
1435
+ tdriver_test_environment_link<<
1436
+ '>TDriver test environment</a></li>'<<
1437
+ '<li><a href="'<<
1438
+ statistics_link<<
1439
+ '>Statistics</a></li>'<<
1440
+ '<li><a href="'<<
1441
+ tdriver_log_link<<
1442
+ '>Log</a></li>'<<
1443
+ '<li><a href="'<<
1444
+ total_run_link<<
1445
+ '>Total run</a></li>'<<
1446
+ '<li><a href="'<<
1447
+ passed_link<<
1448
+ '>Passed</a></li>'<<
1449
+ '<li><a href="'<<
1450
+ failed_link<<
1451
+ '>Failed</a></li>'<<
1452
+ '<li><a href="'<<
1453
+ not_run_link<<
1454
+ '>Not run</a></li>'<<
1455
+ '</ul>'<<
1456
+ '</div></div>'
1457
+ File.open(page, 'a') do |f2|
1458
+ f2.puts html_body
1459
+ end
1460
+ html_body=nil
1461
+ end
1462
+
1463
+ def write_page_navigation_div(page,report_page,report_pages)
1464
+ page_with_no_number=page.gsub("#{report_page}_","")
1465
+ page_base_name=File.basename(page_with_no_number)
1466
+ div_body=Array.new
1467
+ div_body<<"<div class=\"page_navigation_section\"><center>"<<
1468
+ "<ul id=\"navigation\">"
1469
+ max=10
1470
+ start_page=report_page/max
1471
+ if start_page==0
1472
+ start_page=1
1473
+ else
1474
+ if (report_page%max)!=0
1475
+ start_page=(start_page*max)+1
1476
+ else
1477
+ start_page=(start_page*max)+1-max
1478
+ end
1479
+ end
1480
+ if (start_page+max)<report_pages
1481
+ end_page=(start_page+max)-1
1482
+ else
1483
+ end_page=report_pages
1484
+ end
1485
+
1486
+ div_body<<"<li><a href=\"#{start_page-max}_#{page_base_name}\">Previous</a></li>" if start_page!=1
1487
+
1488
+ for i in (start_page..end_page)
1489
+ div_body<<"<li><a href=\""
1490
+ if i==report_page
1491
+ div_body<<"#{i}_#{page_base_name}\" class=\"current\""
1492
+ else
1493
+ div_body<<"#{i}_#{page_base_name}\""
1494
+ end
1495
+ div_body<<">#{i}</a></li>"
1496
+ end
1497
+ div_body<<"<li><a href=\"#{end_page+1}_#{page_base_name}\">Next</a></li>" if end_page < report_pages
1498
+ div_body<<"</ul></center></div>"
1499
+ div_body
1500
+ end
1501
+
1502
+ def write_page_end(page,report_page=nil,report_pages=nil)
1503
+ page_ready=nil
1504
+ if report_page!=nil
1505
+ navigation_div="#{write_page_navigation_div(page,report_page,report_pages)}"
1506
+ html_end="#{navigation_div}</body></html>"
1507
+ doc = Nokogiri::HTML(open(page))
1508
+ b_div_found=false
1509
+ doc.xpath('//div[@class="page_navigation_section"]').each do |div|
1510
+ if div.text.include?('Next')
1511
+ page_ready=report_page
1512
+ end
1513
+ b_div_found=true
1514
+ div.replace(Nokogiri.make(navigation_div))
1515
+ end
1516
+ if b_div_found==false
1517
+ File.open(page, 'a') do |f|
1518
+ f.puts html_end
1519
+ end
1520
+ else
1521
+ File.open(page, 'w') do |f|
1522
+ f.puts doc
1523
+ end
1524
+ end
1525
+ else
1526
+ html_end="</body></html>"
1527
+ File.open(page, 'a') do |f|
1528
+ f.puts html_end
1529
+ end
1530
+ end
1531
+ html_end=nil
1532
+ page_ready
1533
+ end
1534
+ def get_java_script()
1535
+ TDriverReportJavascript.get_expand_collapse_java_script()
1536
+ end
1537
+
1538
+ def scan_rdoc_file_for_method(file,method_name)
1539
+ text = File.read(file)
1540
+ if text =~ /\b#{method_name}\b/
1541
+ path=file.split('doc/')
1542
+ return path[1]
1543
+ end
1544
+ end
1545
+
1546
+ def get_rdoc_for_method(method_name)
1547
+ doc=Array.new
1548
+ rdoc_files=[]
1549
+ #Find method documentation from report doc folder
1550
+ if File.directory?("#{$tdriver_reporter.report_folder()}/doc/classes")
1551
+ d = Dir.new("#{$tdriver_reporter.report_folder()}/doc/classes")
1552
+ d.each do |entry|
1553
+ if entry!="." && entry!=".."
1554
+ if File.directory?("#{d.path}/#{entry}")
1555
+ d1=Dir.new("#{d.path}/#{entry}")
1556
+ d1.each do |entry1|
1557
+ if entry1!="." && entry1!=".."
1558
+ if !File.directory?("#{d1.path}/#{entry1}")
1559
+ res=scan_rdoc_file_for_method("#{d1.path}/#{entry1}",method_name)
1560
+ rdoc_files << res if res
1561
+ end
1562
+ end
1563
+ end
1564
+ else
1565
+ res=scan_rdoc_file_for_method("#{d.path}/#{entry}",method_name)
1566
+ rdoc_files << res if res
1567
+ end
1568
+ end
1569
+ end
1570
+
1571
+
1572
+ rdoc_files.each do |rdoc|
1573
+ doc << "<iframe src=\"../../doc/#{rdoc}\"
1574
+ width=\"100%\" height=\"340\"
1575
+ align=\"right\" scrolling=\"yes\">
1576
+ <p><a href=\"../../doc/#{rdoc}\">#{method_name}</a>.</p>
1577
+ </iframe>"
1578
+ end
1579
+ return doc
1580
+ else
1581
+ return '-'
1582
+ end
1583
+ end
1584
+
1585
+ def format_user_log_table(user_data_rows,user_data_columns)
1586
+ begin
1587
+ formatted_user_data=Array.new
1588
+ formatted_user_data << '<div><table align="center" style="width:100%;" border="1">'
1589
+ header='<tr class="user_data_table_title">'
1590
+ user_data_columns.sort.each do |column|
1591
+ header=header+'<td><b>'+column.to_s+'</b></td>'
1592
+ end
1593
+ formatted_user_data << header +'</tr>'
1594
+
1595
+ #first need to add empty values for those columns that donot exist
1596
+
1597
+ user_data_rows.each do |row_hash|
1598
+ keys_need_adding = user_data_columns - row_hash.keys
1599
+ keys_need_adding.each do |new_key|
1600
+ row_hash[new_key] = " - "
1601
+ end
1602
+ end
1603
+
1604
+ #create the table rows
1605
+ user_data_rows.each do |row_hash|
1606
+ row = '<tr>'
1607
+ row_hash.sort{|a,b| a[0]<=>b[0]}.each do |value|
1608
+ row=row+'<td>'+value[1].to_s+'</td>'
1609
+ end
1610
+ formatted_user_data << row+'</tr>'
1611
+ end
1612
+ formatted_user_data << '</table></div>'
1613
+ formatted_user_data.to_s
1614
+ rescue Exception => e
1615
+ '-'
1616
+ end
1617
+ end
1618
+
1619
+ end #end TDriverReportWriter
1620
+
1621
+