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,618 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module MobyBase
21
+
22
+ # class to represent TestObjectFactory.
23
+ #
24
+ # when a SUT asks for factory to create test objects, it shall give reference to the SUT so that
25
+ # factory can make a call back for SUT object dump (in xml)
26
+ class TestObjectFactory
27
+
28
+ include Singleton
29
+
30
+ attr_reader :timeout
31
+
32
+ # TODO: Document me (TestObjectFactory::check_verify_always_reporting_settings)
33
+ def check_verify_always_reporting_settings()
34
+ @reporter_attached = MobyUtil::Parameter[ :report_attach_continuous_verification_to_reporter, 'false' ]
35
+
36
+ @rcv_raise_errors = MobyUtil::Parameter[ :report_continuous_verification_raise_errors, 'true' ]
37
+
38
+ @rcv_fail_test_case = MobyUtil::Parameter[ :report_continuous_verification_fail_test_case_on_error, 'true' ]
39
+
40
+ @rvc_capture_screen = MobyUtil::Parameter[ :report_continuous_verification_capture_screen_on_error, 'true' ]
41
+ end
42
+
43
+ # TODO: Document me (TestObjectFactory::restore_verify_always_reporting_settings)
44
+ def restore_global_verify_always_reporting_settings()
45
+ @reporter_attached = @global_reporter_attached
46
+
47
+ @rcv_raise_errors = @rcv_global_raise_errors
48
+
49
+ @rcv_fail_test_case = @rcv_global_fail_test_case
50
+
51
+ @rvc_capture_screen = @rvc_global_capture_screen
52
+ end
53
+
54
+ # TODO: Document me (TestObjectFactory::initialize)
55
+ def initialize
56
+
57
+ # TODO maybe set elsewhere used for defaults
58
+ # TODO: Remove from here, to be initialized by the environment.
59
+
60
+ reset_timeout
61
+
62
+ @global_reporter_attached = MobyUtil::Parameter[ :report_attach_continuous_verification_to_reporter, 'false' ]
63
+
64
+ @rcv_global_raise_errors = MobyUtil::Parameter[ :report_continuous_verification_raise_errors, 'true' ]
65
+
66
+ @rcv_global_fail_test_case = MobyUtil::Parameter[ :report_continuous_verification_fail_test_case_on_error, 'true' ]
67
+
68
+ @rvc_global_capture_screen = MobyUtil::Parameter[ :report_continuous_verification_capture_screen_on_error, 'true' ]
69
+
70
+ @test_object_cache = {}
71
+
72
+ @inside_verify = false
73
+
74
+ end
75
+
76
+ #TODO: Team TE review @ Wheels
77
+ # Function to set timeout for TestObjectFactory
78
+ # This should be used only in unit testing, otherwise should not be used
79
+ # sets timeout used in identifying TestObjects to new timeout
80
+ #
81
+ # == params
82
+ # new_timeout:: Fixnum which defines the new timeout
83
+ # == raises
84
+ # ArgumentError:: if parameter is not kind of Fixnum
85
+ def timeout=( value )
86
+
87
+ Kernel::raise ArgumentError.new( "Value for timeout should be of numeric. It was %s" % [ value.class ] ) unless value.kind_of?( Numeric )
88
+
89
+ @timeout = value
90
+
91
+ end
92
+
93
+ #TODO: Team TE review @ Engine
94
+ # Function to reset timeout to default
95
+ # This is needed, as TOFactory is singleton.
96
+ # == params
97
+ # --
98
+ # == returns
99
+ # --
100
+ # == raises
101
+ # --
102
+ def reset_timeout()
103
+
104
+ @timeout = MobyUtil::Parameter[ :application_synchronization_timeout, "20" ].to_i
105
+
106
+ @_retry_interval = MobyUtil::Parameter[ :application_synchronization_retry_interval, "1" ].to_i
107
+
108
+ end
109
+
110
+ #TODO: update documetation
111
+ # Function to make a test object.
112
+ # Queries from the sut an xml dump which is used to generate TestObjects.
113
+ # Once XML dump is retrieved, a TestObject is identified by the TestObjectIdentificator.
114
+ # TestObject is populated with data and activated.
115
+ # The behaviour is added, as described in BehaviourGenerator#apply_behaviour
116
+ # Lastly the created TestObject instance is associated to the SUT and vice versa.
117
+ #
118
+ # TODO: proper synchronization
119
+ #
120
+ # == params
121
+ # sut:: SUT object with which the new test object is to be associated
122
+ # test_object_identificator:: TestObjectIdentificator which is used to identify the required test object from the xml data
123
+ # == returns
124
+ # TestObject new, initialized and ready to use test object with associated data and behaviours
125
+ # == raises, as defined in TestObjectIdentificator
126
+ # ArgumentError:: if test_object_identificator is not of type LibXML::XML::Node,
127
+ # MultipleTestObjectsIdentifiedError:: if multiple TestObjects can be identified using the test_object_identificator
128
+ # TestObjectNotFoundError:: if no TestObjects are identified using the test_object_identificator
129
+ def make( sut, test_object_identificator )
130
+
131
+ test_object = make_test_object(
132
+ self,
133
+ sut,
134
+ sut,
135
+ _make_xml( sut, test_object_identificator )
136
+ )
137
+
138
+ sut.add_child( test_object )
139
+
140
+ test_object
141
+
142
+ end
143
+
144
+ # Function for dynamically creating methods for accessing child objects of a test object
145
+ # == params
146
+ # test_object:: test_object where access methods should be added
147
+ # == returns
148
+ # test_object:: test_object with added access methods
149
+ def create_child_accessors!( test_object )
150
+
151
+ created_accessors = []
152
+
153
+ test_object.xml_data.xpath( 'objects/object' ).each{ | objectElement |
154
+
155
+ objectElement.attribute( "type" ).tap{ | objType |
156
+
157
+ unless created_accessors.include?( objType ) || objType.empty? then
158
+
159
+ test_object.instance_eval(
160
+
161
+ "def %s( rules={} ); raise TypeError, 'parameter <rules> should be hash' unless rules.kind_of?( Hash ); rules[:type] = :%s; child( rules ); end;" % [ objType, objType ]
162
+
163
+
164
+ )
165
+
166
+ created_accessors << objType
167
+
168
+ end
169
+
170
+ }
171
+
172
+ }
173
+
174
+ end
175
+
176
+
177
+ def verify_ui_dump( sut )
178
+
179
+ return if @inside_verify
180
+
181
+ begin
182
+ @inside_verify = true
183
+
184
+ logging_enabled = MobyUtil::Logger.instance.enabled
185
+
186
+ sut.verify_blocks.each do | verify |
187
+ check_verify_always_reporting_settings()
188
+ begin
189
+
190
+ MobyUtil::Logger.instance.enabled = false
191
+
192
+ begin
193
+ result = verify.block.call( sut )
194
+
195
+ rescue Exception => e
196
+
197
+ if @rcv_raise_errors=='true' || @reporter_attached=='false'
198
+ raise MobyBase::ContinuousVerificationError.new(
199
+ "Verification failed as an exception was thrown when the verification block was executed. %s\nDetails: %s\nNested exception:\n%s" % [ verify.source, ( verify.message || "none" ), e.inspect ]
200
+ )
201
+ elsif @reporter_attached=='true' && @rcv_raise_errors=='false'
202
+ TDriverReportAPI::tdriver_report_set_test_case_status('failed') if @rcv_fail_test_case=='true'
203
+ if @rvc_capture_screen=='true'
204
+ TDriverReportAPI::tdriver_capture_state
205
+ else
206
+ TDriverReportAPI::tdriver_capture_state(false)
207
+ end
208
+ TDriverReportAPI::tdriver_report_log("Verification failed as an exception was thrown when the verification block was executed. %s\nDetails: %s\nNested exception:\n%s" % [ verify.source, ( verify.message || "none" ), e.inspect ])
209
+ TDriverReportAPI::tdriver_report_log("<hr />")
210
+ MobyUtil::Logger.instance.enabled = logging_enabled
211
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{verify.message.nil? ? '' : '\"' << verify.message << '\" '}failed:#{e.to_s}.\n#{verify.timeout.nil? ? '' : ' using timeout ' + verify.timeout.to_s}.;#{sut.id.to_s+';sut'};{};verify_always;" << verify.expected.to_s
212
+ end
213
+ end
214
+
215
+ unless result == verify.expected
216
+
217
+ if @rcv_raise_errors=='true' || @reporter_attached=='false'
218
+ raise MobyBase::ContinuousVerificationError.new(
219
+ "Verification failed. %s\nDetails: %s\nThe block did not return %s. It returned: %s" % [ verify.source, ( verify.message || "none" ), verify.expected.inspect, result.inspect ]
220
+ )
221
+ elsif @reporter_attached=='true' && @rcv_raise_errors=='false'
222
+ TDriverReportAPI::tdriver_report_set_test_case_status('failed') if @rcv_fail_test_case=='true'
223
+ if @rvc_capture_screen=='true'
224
+ TDriverReportAPI::tdriver_capture_state
225
+ else
226
+ TDriverReportAPI::tdriver_capture_state(false)
227
+ end
228
+ TDriverReportAPI::tdriver_report_log("Verification failed. %s\nDetails: %s\nThe block did not return %s. It returned: %s " % [ verify.source, ( verify.message || "none" ), verify.expected.inspect, result.inspect])
229
+ TDriverReportAPI::tdriver_report_log("<hr />")
230
+ MobyUtil::Logger.instance.enabled = logging_enabled
231
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{verify.message.nil? ? '' : '\"' << verify.message << '\" '}failed:#{e.to_s}.\n#{verify.timeout.nil? ? '' : ' using timeout ' + verify.timeout.to_s}.;#{sut.id.to_s+';sut'};{};verify_always;" << verify.expected.to_s
232
+ end
233
+ end
234
+
235
+
236
+ rescue Exception => e
237
+
238
+ MobyUtil::Logger.instance.enabled = logging_enabled
239
+
240
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Verification #{verify.message.nil? ? '' : '\"' << verify.message << '\" '}failed:#{e.to_s}.\n#{verify.timeout.nil? ? '' : ' using timeout ' + verify.timeout.to_s}.;#{sut.id.to_s+';sut'};{};verify_always;" << verify.expected.to_s
241
+
242
+ @inside_verify = false
243
+
244
+ Kernel::raise e
245
+ end
246
+
247
+ # Do NOT report PASS cases, like other verify blocks do. This would clog the log with useless info.
248
+ restore_global_verify_always_reporting_settings()
249
+ end
250
+
251
+ ensure
252
+ MobyUtil::Logger.instance.enabled = logging_enabled
253
+ @inside_verify = false
254
+
255
+ end
256
+ end
257
+
258
+ # Function for making a child test object (a test object that is not directly a accessible from the sut)
259
+ # Creates accessors for children of the new object, applies any behaviours applicable for its type.
260
+ # Does not associate child object to parent / vice versa - leaves that to the client.
261
+ #
262
+ # == params
263
+ # parent_test_object:: TestObject thas is the parent of the child object being created
264
+ # test_object_identificator:: TestObjectIdentificator which is used to identify the child object from the xml data
265
+ # == returns
266
+ # TestObject:: new child test object, could be eql? to an existing TO
267
+ # == raises
268
+ # == raises, as defined in TestObjectIdentificator
269
+ # ArgumentError:: if test_object_identificator is not of type LibXML::XML::Node,
270
+ # MultipleTestObjectsIdentifiedError:: if multiple TestObjects can be identified using the test_object_identificator
271
+ # TestObjectNotFoundError:: The TestObject cannot be found or the parent object is no longer visible on the SUT
272
+ def make_child_objects( rules )
273
+
274
+ # make array of matching child test objects
275
+ get_test_objects( rules ).collect{ | test_object_xml |
276
+
277
+ make_test_object(
278
+
279
+ self, # test object factory
280
+ rules[ :sut ], # sut object to t_o
281
+ rules[ :parent ], # parent object to t_o
282
+ test_object_xml # t_o xml
283
+
284
+ )
285
+
286
+ }
287
+
288
+ end
289
+
290
+ def make_object_search_params(creation_attributes)
291
+ object_search_params = {}
292
+ if creation_attributes[:type] != 'application'
293
+ object_search_params.merge!(creation_attributes)
294
+ object_search_params[:className] = object_search_params.delete(:type) if creation_attributes.has_key?(:type)
295
+ object_search_params[:objectName] = object_search_params.delete(:name) if creation_attributes.has_key?(:name)
296
+ end
297
+ object_search_params
298
+ end
299
+
300
+ def get_parent_params(test_object)
301
+ search_params = []
302
+ if test_object.type != 'application' and test_object.type != 'sut'
303
+ search_params.concat(get_parent_params(test_object.parent)) if test_object.parent
304
+ search_params.concat([{:className => test_object.type, :tasId => test_object.id}]) if test_object
305
+ end
306
+ search_params
307
+ end
308
+
309
+ private
310
+
311
+ # TODO: This method should be in application test object
312
+ def get_layout_direction( sut )
313
+
314
+ sut.xml_data.xpath('*//object[@type="application"]/attributes/attribute[@name="layoutDirection"]/value/text()').first.content || 'LeftToRight'
315
+
316
+ end
317
+
318
+ # TODO: Documentation
319
+ def get_test_objects( rules )
320
+
321
+ # get parent object
322
+ parent = rules[ :parent ]
323
+
324
+ # determine which application to refresh when identifying desired object(s)
325
+ refresh_arguments = rules.fetch( :application, {} )
326
+
327
+ # get associated sut object
328
+ sut = rules.fetch( :sut )
329
+
330
+ # determine that are we going to retrieve multiple test objects
331
+ multiple_objects = rules.fetch( :multiple_objects, false )
332
+
333
+ # determine that should all child objects childrens be retrieved
334
+ find_all_children = rules.fetch( :find_all_children, true )
335
+
336
+ # creation attributes for test object
337
+ creation_attributes = rules.fetch( :attributes )
338
+
339
+ # dynamic attributes for test object
340
+ #dynamic_attributes = rules.fetch( :dynamic_attributes )
341
+ dynamic_attributes = rules.fetch( :dynamic_attributes, {} )
342
+
343
+ # sorting is disabled by default
344
+ sorting = MobyUtil::KernelHelper.to_boolean( dynamic_attributes[ :__xy_sorting ], false )
345
+
346
+ # determine that did user give index value
347
+ index_given = dynamic_attributes.has_key?( :__index )
348
+
349
+ # index for test object, default is 0 (first) if not defined by caller
350
+ index = dynamic_attributes.fetch( :__index, 0 ).to_i
351
+
352
+ # create test object identificator object with given creation attributes
353
+ test_object_identificator = MobyBase::TestObjectIdentificator.new( creation_attributes )
354
+
355
+ MobyUtil::Retryable.until(
356
+
357
+ # maximum time used for retrying, if timeout exceeds pass last raised exception
358
+ :timeout => ( rules[ :timeout ] || @timeout ),
359
+
360
+ # interval used before retrying
361
+ :interval => ( rules[ :interval ] || @_retry_interval ),
362
+
363
+ # following exceptions are allowed; Retry until timeout exceeds or other exception type is raised
364
+ :exception => [ MobyBase::TestObjectNotFoundError, MobyBase::MultipleTestObjectsIdentifiedError ] ) {
365
+
366
+ #make search params
367
+ object_search_params = make_object_search_params(creation_attributes)
368
+ search_params = get_parent_params(parent)
369
+ search_params.push(object_search_params)
370
+
371
+ # refresh sut ui state
372
+ sut.refresh( refresh_arguments, search_params )
373
+
374
+ # identify test objects from xml
375
+ matches, rule = test_object_identificator.find_objects( parent.xml_data, find_all_children )
376
+
377
+ # raise exception if multiple objects flag is false and more than one match found
378
+ raise MobyBase::MultipleTestObjectsIdentifiedError.new( "Multiple test objects found with rule:\n%s" % creation_attributes.merge( dynamic_attributes ).inspect ) if ( !multiple_objects ) && ( matches.count > 1 && !index_given )
379
+
380
+ # raise exception if no matching object(s) found
381
+ raise MobyBase::TestObjectNotFoundError.new( "Cannot find object with rule:\n%s" % creation_attributes.merge( dynamic_attributes ).inspect ) if matches.empty?
382
+
383
+ # sort elements
384
+ test_object_identificator.sort_elements_by_xy_layout!( matches, get_layout_direction( sut ) ) if sorting
385
+
386
+ # return result
387
+ multiple_objects && !index_given ? matches.to_a : [ matches[ index ] ]
388
+
389
+
390
+ }
391
+
392
+ end
393
+
394
+ # Function to get the xml element for a test object
395
+ # TODO: Remove TestObjectFactory::makeXML function & refactor the 'user' of this function!
396
+ def _make_xml( sut, test_object_identificator )
397
+
398
+ attributes = test_object_identificator.get_identification_rules
399
+
400
+ refresh_args = nil
401
+ if attributes[ :type ] == 'application'
402
+ refresh_args = { :name => attributes[ :name ], :id => attributes[ :id ], :applicationUid => attributes[ :applicationUid ] }
403
+ else
404
+ refresh_args = { :id => sut.current_application_id }
405
+ end
406
+
407
+ MobyUtil::Retryable.until(
408
+
409
+ :timeout => @timeout, :interval => @_retry_interval, :exception => MobyBase::TestObjectNotFoundError ) {
410
+
411
+ sut.refresh( refresh_args, [attributes.clone] ); test_object_identificator.find_object_data( sut.xml_data )
412
+
413
+ }
414
+
415
+ end
416
+
417
+ def make_test_object( test_object_factory, sut, parent, xml_object )
418
+
419
+ # retrieve test object type from xml
420
+ object_type = xml_object.kind_of?( MobyUtil::XML::Element ) ? xml_object.attribute( 'type' ) : nil
421
+
422
+ # if !@test_object_cache.has_key?( object_type )
423
+
424
+ test_object = MobyBase::TestObject.new( test_object_factory, sut, parent, xml_object )
425
+
426
+ # apply behaviours to test object
427
+ test_object.extend( MobyBehaviour::ObjectBehaviourComposition )
428
+
429
+ # apply behaviours to test object
430
+ test_object.apply_behaviour!(
431
+ :object_type => [ '*', object_type ],
432
+ :sut_type => [ '*', sut.ui_type ],
433
+ :input_type => [ '*', sut.input.to_s ],
434
+ :version => [ '*', sut.ui_version ]
435
+ )
436
+ =begin
437
+ Removed object cache usage
438
+ # now test object has all required behaviours, store it to cache
439
+ @test_object_cache[ object_type ] = test_object.clone
440
+
441
+ else
442
+
443
+
444
+ # retreieve test object with behaviours from cache and clone it
445
+ ( test_object = @test_object_cache[ object_type ].clone ).instance_exec{
446
+
447
+ @test_object_factory = test_object_factory
448
+ @sut = sut
449
+ @parent = parent
450
+ self.xml_data = xml_object
451
+
452
+ }
453
+
454
+ end
455
+ =end
456
+ create_child_accessors!( test_object )
457
+
458
+ # do not make test object verifications if we are operating on the
459
+ # base sut itself (allow run to pass)
460
+ unless parent.kind_of?( MobyBase::SUT )
461
+
462
+ verify_ui_dump( sut ) unless sut.verify_blocks.empty?
463
+
464
+ end
465
+
466
+ test_object
467
+
468
+ end
469
+
470
+ public # deprecated methods
471
+
472
+ # Function for making a child test object (a test object that is not directly a accessible from the sut)
473
+ # Creates accessors for children of the new object, applies any behaviours applicable for its type.
474
+ # Does not associate child object to parent / vice versa - leaves that to the client.
475
+ #
476
+ # == params
477
+ # parent_test_object:: TestObject thas is the parent of the child object being created
478
+ # test_object_identificator:: TestObjectIdentificator which is used to identify the child object from the xml data
479
+ # == returns
480
+ # TestObject:: new child test object, could be eql? to an existing TO
481
+ # == raises
482
+ # == raises, as defined in TestObjectIdentificator
483
+ # ArgumentError:: if test_object_identificator is not of type LibXML::XML::Node,
484
+ # MultipleTestObjectsIdentifiedError:: if multiple TestObjects can be identified using the test_object_identificator
485
+ # TestObjectNotFoundError:: The TestObject cannot be found or the parent object is no longer visible on the SUT
486
+ def make_child( parent_test_object, test_object_identificator )
487
+
488
+ identified_object_xml = nil
489
+
490
+ layout_direction = nil
491
+
492
+ MobyUtil::Retryable.until(
493
+ :timeout => @timeout,
494
+ :interval => @_retry_interval,
495
+ :exception => [ MobyBase::TestObjectNotFoundError, MobyBase::MultipleTestObjectsIdentifiedError ] ) {
496
+
497
+ parent_test_object.refresh( :id => parent_test_object.get_application_id )
498
+
499
+ if test_object_identificator.dynamic_attributes.include?( :__xy_sorting )
500
+
501
+ begin
502
+
503
+ layout_direction = parent_test_object.sut.application( :id => parent_test_object.get_application_id ).attribute("layoutDirection")
504
+
505
+ rescue MobyBase::AttributeNotFoundError
506
+
507
+ layout_direction = nil
508
+
509
+ end
510
+
511
+ end
512
+
513
+ identified_object_xml = test_object_identificator.find_object_data( parent_test_object.xml_data, layout_direction )
514
+
515
+ }
516
+
517
+
518
+ make_test_object(
519
+ self,
520
+ parent_test_object.sut,
521
+ parent_test_object,
522
+ identified_object_xml
523
+ )
524
+
525
+ end
526
+
527
+
528
+ # Same as def make_child, but creates an array of test objects
529
+ # == params
530
+ # parent_test_object:: TestObject thas is the parent of the child object being created
531
+ # test_object_identificator:: TestObjectIdentificator which is used to identify the child object from the xml data
532
+ #find_all_children:: Boolean specifying whether all children under the test node or just immediate children should be retreived.
533
+ # == returns
534
+ # An array of Test Objects.
535
+ # == raises
536
+ # == raises, as defined in TestObjectIdentificator
537
+ # ArgumentError:: if test_object_identificator is not of type LibXML::XML::Node,
538
+ # TestObjectNotFoundError:: The TestObject cannot be found or the parent object is no longer visible on the SUT
539
+ def make_multiple_children( parent_test_object, test_object_identificator, find_all_children)
540
+
541
+ identified_object_xml = Array.new
542
+
543
+ ret_array = Array.new
544
+
545
+ layout_direction = nil
546
+
547
+ begin
548
+
549
+ MobyUtil::Retryable.until(
550
+ :timeout => @timeout,
551
+ :interval => @_retry_interval,
552
+ :exception => [ MobyBase::TestObjectNotFoundError ] ) {
553
+
554
+ parent_test_object.refresh( :id => parent_test_object.get_application_id )
555
+
556
+ if test_object_identificator.dynamic_attributes.include?( :__xy_sorting )
557
+
558
+ begin
559
+
560
+ layout_direction = parent_test_object.sut.application( :id => parent_test_object.get_application_id ).attribute("layoutDirection")
561
+
562
+ rescue MobyBase::AttributeNotFoundError
563
+
564
+ layout_direction = nil
565
+
566
+ end
567
+
568
+ end
569
+
570
+ identified_object_xml = test_object_identificator.find_multiple_object_data( parent_test_object.xml_data, find_all_children, layout_direction )
571
+
572
+ }
573
+
574
+ rescue MobyBase::TestObjectNotFoundError
575
+
576
+ Kernel::raise MobyBase::TestObjectNotFoundError.new(
577
+ "The parent test object was no available on the SUT.\n" <<
578
+ "Expected object type: '#{ parent_test_object.type }' id: '#{ parent_test_object.id }'"
579
+ )
580
+
581
+ end
582
+
583
+ identified_object_xml.each do |child_xml|
584
+
585
+ ret_array << make_test_object( self, parent_test_object.sut, parent_test_object, child_xml )
586
+
587
+ end
588
+
589
+ ret_array
590
+
591
+ end
592
+
593
+ def set_timeout( new_timeout )
594
+
595
+ warn( "Deprecated method: use timeout=(value) instead of TestObjectFactory#set_timeout( value )" )
596
+
597
+ self.timeout = new_timeout
598
+
599
+ end
600
+
601
+ # Function gets the timeout used in TestObjectFactory
602
+ #
603
+ # === returns
604
+ # Numeric:: Timeout
605
+ def get_timeout
606
+
607
+ warn( "Deprecated method: use timeout instead of TestObjectFactory#get_timeout" )
608
+
609
+ @timeout
610
+
611
+ end
612
+
613
+ # enable hooking for performance measurement & debug logging
614
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
615
+
616
+ end # TestObjectFactory
617
+
618
+ end # MobyBase