testability-driver 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,194 @@
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
+ # generated behaviour implementation
21
+ module MobyBehaviour
22
+
23
+ # == description
24
+ # This module contains example implementation containing tags for documentation generation
25
+ #
26
+ # == behaviour
27
+ # QtExampleBehaviour
28
+ #
29
+ # == requires
30
+ # testability-driver-sut-qt-plugin
31
+ #
32
+ # == input_type
33
+ # *
34
+ #
35
+ # == sut_type
36
+ # qt
37
+ #
38
+ # == sut_version
39
+ # *
40
+ #
41
+ # == objects
42
+ # *;sut
43
+ #
44
+ module Example
45
+
46
+ include MobyBehaviour::Behaviour
47
+
48
+ private # construction
49
+
50
+ # this method will be called once module is extended to test object
51
+ def self.extended( object )
52
+
53
+ object.instance_exec{
54
+
55
+ # default settings (optional)
56
+ initialize_behaviour_settings
57
+
58
+ }
59
+
60
+ end
61
+
62
+ # this method will be called once behaviour is extended to test object
63
+ def initialize_behaviour_settings
64
+
65
+ end
66
+
67
+ public # behaviours
68
+
69
+ # TODO: jotain
70
+ # this line won't be documented
71
+ #
72
+ # == description
73
+ # Cause a drag operation on the screen. Basically the same as flick or gesture but done slowly.
74
+ #
75
+ # == arguments
76
+ # direction
77
+ # description: Angle of direction of the drag. Supported range is from 0 to 360
78
+ # example: 180
79
+ # default:
80
+ #
81
+ # direction
82
+ # type: Symbol
83
+ # description: Symbol of direction of the drag. See Valid drag direction symbols table for valid values.
84
+ # example: :Right
85
+ # default: :Left
86
+ #
87
+ # distance
88
+ # type: Integer
89
+ # description: Distance in pixels of the drag motion
90
+ # example: 10
91
+ # default:
92
+ #
93
+ # button
94
+ # type: Symbol
95
+ # description: Symbol of button used for drag. See Valid drag button symbols table for valid values.
96
+ # example: :Left
97
+ # default: :Left
98
+ #
99
+ # == returns
100
+ # MobyBase::TestObject
101
+ # description: Target test object
102
+ # example:
103
+ #
104
+ # MobyBase::TestObject2
105
+ # description: Target test object2
106
+ # example: example2
107
+ #
108
+ # == exceptions
109
+ # MobyBase::TestObjectNotFoundError
110
+ # description: If a graphics item is not visible on screen
111
+ # lisäää descriptionia
112
+ #
113
+ # ArgumentError
114
+ # description: If an invalid direction or button is given
115
+ #
116
+ # == example
117
+ # # Drag QGraphicsItem with tooltip 'node1' down 50 pixels
118
+ # @sut.application.GraphWidget.QGraphicsItem(:tooltip => 'node1').drag(:Down, 50)
119
+ #
120
+ # # Drag 'test_object' up 200 pixels
121
+ # @test_object = @sut.application.GraphWidget.QGraphicsItem(:tooltip => 'node1')
122
+ # @test_object.drag(:Up, 200)
123
+ #
124
+ # == see
125
+ # flick, gesture
126
+ def drag( direction, distance, button = :Left )
127
+
128
+ # implementation
129
+
130
+ end
131
+ =begin
132
+ # documentation for the method
133
+ def []=( value )
134
+
135
+ # implementation
136
+
137
+ end
138
+
139
+ # documentation for the method
140
+ def []( value )
141
+
142
+ # implementation
143
+
144
+ end
145
+
146
+ # documentation for the method
147
+ def d
148
+
149
+ # implementation
150
+
151
+ end
152
+
153
+ # documentation for the method
154
+ def <=>( other )
155
+
156
+ # implementation
157
+
158
+ end
159
+
160
+ # documentation for the method
161
+ def e()
162
+
163
+ # implementation
164
+
165
+ end
166
+
167
+ # documentation for the method
168
+ def f!()
169
+
170
+ # implementation
171
+
172
+ end
173
+
174
+ # documentation for the method
175
+ def g?()
176
+
177
+ # implementation
178
+
179
+ end
180
+
181
+ # documentation for the method
182
+ def x# dada
183
+
184
+ # implementation
185
+
186
+ end
187
+ =end
188
+ attr_accessor :xxz
189
+
190
+ attr_reader :yys
191
+
192
+ end # Example
193
+
194
+ end # MobyBehaviour
@@ -0,0 +1,82 @@
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
+ #!/usr/bin/env ruby
20
+ require 'rdoc/rdoc'
21
+
22
+ $templates = {}
23
+
24
+ module RDoc
25
+
26
+ class RDoc
27
+
28
+ # install custom generator to RDoc
29
+ def install_generator( name, filename )
30
+
31
+ GENERATORS[ name.to_s.downcase ] = Generator.new( filename, ( "%sFeatureTestGenerator" % [ name ] ).intern , name.to_s.downcase )
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
39
+ def load_templates
40
+
41
+ Dir.glob( File.join( File.dirname( File.expand_path( __FILE__ ) ), 'templates', '*.template' ) ).each{ | file |
42
+
43
+ name = File.basename( file ).gsub( '.template', '' )
44
+
45
+ $templates[ name.to_sym ] = open( file, 'r' ).read
46
+
47
+ }
48
+
49
+ end
50
+
51
+ if ARGV.count == 0
52
+
53
+ abort "\nUsage: #{ File.basename( $0 ) } filename.rb\n\n"
54
+
55
+ else
56
+
57
+ ARGV.each{ | filename |
58
+
59
+ abort("\nUnable to create feature test due to implementation file %s not found\n\n" % [ filename ] ) unless File.exist?( File.expand_path( filename ) )
60
+
61
+ }
62
+
63
+ begin
64
+
65
+ load_templates
66
+
67
+ RDoc::RDoc.new.tap{ | rdoc |
68
+
69
+ rdoc.install_generator( 'TDriver', File.expand_path( File.join( File.dirname( __FILE__ ), 'lib/custom_rdoc_generator.rb' ) ) )
70
+
71
+ rdoc.document( ['--inline-source', '--op', 'output', '--fmt', 'tdriver'] + ARGV )
72
+
73
+ }
74
+
75
+ rescue RDoc::RDocError => e
76
+
77
+ abort e.message
78
+
79
+ end
80
+
81
+ end
82
+
@@ -0,0 +1,468 @@
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
+ $scenarios = 0
21
+ $templates = {} unless defined?( $templates )
22
+
23
+ $scenario_files = {}
24
+
25
+ module Generators
26
+
27
+ abort("") unless defined?( RDoc )
28
+
29
+ class TDriverFeatureTestGenerator
30
+
31
+ def self.for( options )
32
+
33
+ new( options )
34
+
35
+ end
36
+
37
+ def initialize( options )
38
+
39
+ @options = options
40
+
41
+ @already_processed_files = []
42
+
43
+ @current_module_tests = []
44
+
45
+ @current_module = nil
46
+
47
+ @output = { :files => [], :classes => [], :modules => [], :attributes => [], :methods => [], :aliases => [], :constants => [], :requires => [], :includes => []}
48
+
49
+ end
50
+
51
+ def generate( files )
52
+
53
+ # process files
54
+ files.each{ | file |
55
+
56
+ process_file( file ) unless @already_processed_files.include?( file.file_absolute_name )
57
+
58
+ }
59
+
60
+ p "total scenarios: %s" % $scenarios
61
+
62
+ #p @already_processed_files
63
+
64
+ end
65
+
66
+ def process_file( file )
67
+
68
+ @module_path = []
69
+
70
+ @current_file = file
71
+
72
+ process_modules( file.modules )
73
+
74
+ end
75
+
76
+ def process_modules( modules )
77
+
78
+ modules.each{ | _module |
79
+
80
+ unless @already_processed_files.include?( _module.full_name )
81
+
82
+ @module_path.push( _module.name )
83
+
84
+ process_module( _module )
85
+
86
+ @module_path.pop
87
+
88
+ end
89
+
90
+ }
91
+
92
+ end
93
+
94
+ def process_methods( methods )
95
+
96
+ results = []
97
+
98
+ methods.each{ | method |
99
+
100
+ scenarios = process_method( method )
101
+
102
+ results << { :header => $templates[:feature_method] % [ "%s#%s" % [ @module_path.join("::"), method.name ], method.name, @module_path.join("::") ], :scenarios => scenarios, :file => generate_name( method.name ), :module_path => @module_path, :name => method.name } if scenarios.count > 0
103
+
104
+ }
105
+
106
+ results
107
+
108
+ end
109
+
110
+ def process_arguments( arguments )
111
+
112
+ # tokenize string
113
+ tokenizer = RubyLex.new( arguments )
114
+
115
+ # get first token
116
+ token = tokenizer.token
117
+
118
+ # set previous token to nil by default
119
+ previous_token = nil
120
+
121
+ args = []
122
+
123
+ capture = false
124
+ capture_depth = []
125
+
126
+ # loop while tokens available
127
+ while token
128
+
129
+ if [ RubyToken::TkLBRACE, RubyToken::TkLPAREN, RubyToken::TkLBRACK ].include?( token.class )
130
+
131
+ capture_depth << token
132
+
133
+ capture = true
134
+
135
+ elsif [ RubyToken::TkRBRACE, RubyToken::TkRPAREN, RubyToken::TkRBRACK ].include?( token.class )
136
+
137
+ capture_depth.pop
138
+
139
+ capture = false if capture_depth.empty?
140
+
141
+ # argument name
142
+ elsif capture == false
143
+
144
+ if token.kind_of?( RubyToken::TkIDENTIFIER )
145
+
146
+ args << [ token.name, nil, false ]
147
+
148
+ # &blocks and *arguments are handled as optional parameters
149
+ args.last[ -1 ] = true if [ RubyToken::TkBITAND, RubyToken::TkMULT ].include?( previous_token.class )
150
+
151
+ # detect optional argument
152
+ elsif token.kind_of?( RubyToken::TkASSIGN )
153
+
154
+ # mark arguments as optional
155
+ args.last[ -1 ] = true
156
+
157
+ opt = true
158
+
159
+ end
160
+
161
+ end
162
+
163
+ # store previous token
164
+ previous_token = token
165
+
166
+ # get next token
167
+ token = tokenizer.token
168
+
169
+ end
170
+
171
+ args
172
+
173
+ end
174
+
175
+ def generate_scenarios( mode, arguments_table = nil )
176
+
177
+ results = []
178
+
179
+ # first scenario with all required arguments
180
+ if mode.to_s =~ /method/
181
+
182
+ required_arguments = arguments_table.select{ | argument | argument.last == false }.collect{ | scenario | scenario.first }
183
+
184
+ results << $templates[ mode ] % [ @current_method.name, "required", "(s)", @current_method.name, required_arguments.join(", ") ]
185
+
186
+ elsif mode.to_s =~ /attribute/
187
+
188
+ name = @current_attribute.first.name
189
+
190
+ name << "=" if @current_attribute.count > 1
191
+
192
+ results << $templates[ mode ] % [ name, name ]
193
+
194
+ end
195
+
196
+ unless arguments_table.nil?
197
+
198
+ # scenarios with one of each optional argument.. and eventually with all arguments
199
+ arguments_table.select{ | argument | argument.last == true }.collect{ | scenario | scenario
200
+
201
+ scenario = required_arguments << scenario.first
202
+
203
+ results << $templates[ mode ] % [ @current_method.name, "optional", " '%s'" % scenario.last.first, @current_method.name, scenario.join(", ") ]
204
+
205
+ }
206
+
207
+ end
208
+
209
+ results
210
+
211
+ end
212
+
213
+ def process_method( method )
214
+
215
+ scenarios = []
216
+
217
+ if ( method.visibility == :public && @module_path.first =~ /MobyBehaviour/ )
218
+
219
+ arguments_table = process_arguments( method.params )
220
+
221
+ @current_method = method
222
+
223
+ scenarios = generate_scenarios( :scenario_method, arguments_table )
224
+
225
+ $scenarios += scenarios.count
226
+
227
+ else
228
+
229
+ end
230
+
231
+ scenarios
232
+
233
+ end
234
+
235
+ # verify if
236
+ def has_method?( target, method_name )
237
+
238
+ target.method_list.select{ | method |
239
+
240
+ method.name == method_name
241
+
242
+ }.count > 0
243
+
244
+ end
245
+
246
+ def process_attributes( attributes )
247
+
248
+ results = []
249
+
250
+ attributes.each{ | attribute |
251
+
252
+ scenarios = process_attribute( attribute )
253
+
254
+ attr_name = attribute.name.gsub("=",'')
255
+
256
+ results << { :header => $templates[:feature_attribute] % [ "%s#%s" % [ @module_path.join("::"), attribute.name ], attr_name, @module_path.join("::") ], :scenarios => scenarios, :file => generate_name( attr_name ), :module_path => @module_path, :name => attr_name } if scenarios.count > 0
257
+
258
+ }
259
+
260
+ results
261
+
262
+ end
263
+
264
+ def process_attribute( attribute )
265
+
266
+ result = []
267
+
268
+ if ( @module_path.first =~ /MobyBehaviour/ )
269
+
270
+ @current_attribute = [ attribute ]
271
+
272
+ #p @module_path
273
+
274
+ scenarios = []
275
+
276
+ case attribute.rw
277
+
278
+ when 'RW'
279
+ # verify first that if attribute is overwritten as method
280
+ unless has_method?( @current_module[ :object ], attribute.name )
281
+ scenarios << generate_scenarios( :scenario_attribute )
282
+ scenarios.pop if scenarios.last == []
283
+ end
284
+
285
+ # verify first that if attribute is overwritten as method
286
+ unless has_method?( @current_module[ :object ], "%s=" % attribute.name )
287
+ @current_attribute << "W"
288
+ scenarios << generate_scenarios( :scenario_attribute )
289
+ scenarios.pop if scenarios.last == []
290
+ end
291
+
292
+ when 'W'
293
+ # verify first that if attribute is overwritten as method
294
+ unless has_method?( @current_module[ :object ], "%s=" % attribute.name )
295
+ @current_attribute << "W"
296
+ scenarios << generate_scenarios( :scenario_attribute )
297
+ scenarios.pop if scenarios.last == []
298
+ end
299
+
300
+ when 'R'
301
+
302
+ # verify first that if attribute is overwritten as method
303
+ unless has_method?( @current_module[ :object ], attribute.name )
304
+ scenarios << generate_scenarios( :scenario_attribute )
305
+ scenarios.pop if scenarios.last == []
306
+ end
307
+
308
+ else
309
+
310
+ abort( "Unknown attribute rw status: %s" % attribute.rw )
311
+
312
+ end
313
+
314
+ if scenarios.count > 0
315
+
316
+ #puts $templates[:feature]
317
+ result << scenarios
318
+ #puts scenarios
319
+
320
+ $scenarios += scenarios.count
321
+
322
+ end
323
+
324
+
325
+ else
326
+
327
+ #puts "%s method: %s" % [ method.visibility.to_s, method.name ]
328
+
329
+ end
330
+
331
+ result
332
+
333
+ end
334
+
335
+ def generate_name( method )
336
+
337
+ name = @module_path[ 1 .. -1 ].join("_")
338
+
339
+ begin
340
+
341
+ n = name.bytes.to_a
342
+
343
+ result = ""
344
+
345
+ n.each_with_index{ | byte, index |
346
+
347
+ if byte == 95
348
+
349
+ result << byte.chr
350
+ next
351
+
352
+ end
353
+
354
+ unless index == 0
355
+
356
+ prefix = ""
357
+
358
+ if (65..90).include?( byte ) or (48..57).include?( byte )
359
+
360
+ prefix = "_"
361
+
362
+ unless ( index + 1) > ( n.count - 1 )
363
+
364
+ next_byte = n[ index + 1 ]
365
+
366
+ # do not add underscore if next character is in uppercase or numeric
367
+ prefix = "" if (65..90).include?( next_byte ) or (48..57).include?( next_byte ) or next_byte == 95
368
+
369
+ else
370
+
371
+ prev_byte = n[ index - 1 ]
372
+
373
+ prefix = "" if ( 65..90 ).include?( prev_byte ) or ( 48..57 ).include?( prev_byte ) or prev_byte == 95
374
+
375
+ end
376
+
377
+ end
378
+
379
+ result << prefix + byte.chr.downcase
380
+
381
+ else
382
+
383
+ # first char, don't care if uppercase
384
+ result << byte.chr
385
+
386
+ end
387
+
388
+ }
389
+
390
+ name = result.gsub( /_+/, "_")
391
+
392
+ rescue
393
+
394
+ name = name.downcase
395
+
396
+ end
397
+
398
+ name << "_" << method
399
+
400
+ name.gsub!(/[?!=]/){ | char | char = "_0x%x" % char[0] }
401
+
402
+ ( name + ".feature" ).downcase
403
+
404
+ end
405
+
406
+ def generate_feature( data )
407
+
408
+ path = File.join( data[:file] )
409
+
410
+ open( path, 'w' ){ | file |
411
+
412
+ file << data[:header]
413
+
414
+ file << data[:scenarios]
415
+
416
+ }
417
+
418
+ end
419
+
420
+ def process_module( _module )
421
+
422
+ @already_processed_files << _module.full_name
423
+
424
+ @current_module = { :object => _module, :scenarios => [] }
425
+
426
+ # process methods
427
+ methods = process_methods( _module.method_list )
428
+
429
+ # process attributes
430
+ attributes = process_attributes( _module.attributes )
431
+
432
+ unless ( methods.empty? && attributes.empty? )
433
+
434
+ methods.each{ | method |
435
+
436
+ generate_feature( method )
437
+
438
+ puts method[:file]
439
+
440
+ puts method[:header]
441
+
442
+ puts method[:scenarios]
443
+
444
+ }
445
+
446
+
447
+ attributes.each{ | method |
448
+
449
+ generate_feature( method )
450
+
451
+ puts method[:file]
452
+
453
+ puts method[:header]
454
+
455
+ puts method[:scenarios]
456
+
457
+ }
458
+
459
+ end
460
+
461
+ # process if any child modules
462
+ process_modules( _module.modules ) unless _module.modules.empty?
463
+
464
+ end
465
+
466
+ end
467
+
468
+ end