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,46 @@
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
+ # behaviour abstract class
21
+ #require File.expand_path( File.join( File.dirname( __FILE__ ), 'abstract.rb' ) )
22
+
23
+ # factory class
24
+ #require File.expand_path( File.join( File.dirname( __FILE__ ), 'factory.rb' ) )
25
+
26
+ [
27
+ # behaviour abstract class
28
+ 'abstract.rb',
29
+
30
+ # behaviour factory class
31
+ 'factory.rb'
32
+
33
+ ].each{ | filename |
34
+
35
+ require File.expand_path(
36
+ File.join( File.dirname( __FILE__ ), filename )
37
+ )
38
+
39
+ }
40
+
41
+ # load generic behaviours
42
+ MobyUtil::FileHelper.load_modules(
43
+ File.expand_path(
44
+ File.join( File.dirname( __FILE__ ), 'behaviours' )
45
+ )
46
+ )
@@ -0,0 +1,51 @@
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
+
22
+
23
+ module MobyCommand
24
+
25
+ # Class to represent Controller interface
26
+
27
+ class CommandData
28
+
29
+ def initialize
30
+ end
31
+
32
+ def set_application_uid( id )
33
+ @_application_id = id
34
+ end
35
+
36
+ def get_application_id
37
+ @_application_id = "" unless @_application_id
38
+ @_application_id
39
+ end
40
+
41
+ def set_sut( sut )
42
+ @_sut = sut
43
+ end
44
+
45
+ def get_sut( sut )
46
+ @_sut
47
+ end
48
+
49
+ end
50
+
51
+ end # module
@@ -0,0 +1,29 @@
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
+
22
+ # command_data abstract class
23
+ 'command_data.rb'
24
+
25
+ ].each{ | filename |
26
+
27
+ require File.expand_path( File.join( File.dirname( __FILE__ ), filename ) )
28
+
29
+ }
@@ -0,0 +1,56 @@
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 MobyController
21
+
22
+ module Abstraction
23
+
24
+ # TODO: document me
25
+ def set_adapter( adapter )
26
+
27
+ @sut_adapter = adapter
28
+
29
+ end
30
+
31
+ # Execute the command(s). Sends output generated by make_message to the device using the @sut_adapter (see base class)
32
+ # == params
33
+ # == returns
34
+ # == raises
35
+ def execute
36
+
37
+ @sut_adapter.send_service_request(
38
+
39
+ *make_message
40
+
41
+ )
42
+
43
+ end
44
+
45
+ private
46
+
47
+ # TODO: document me
48
+ def make_message
49
+
50
+ raise NotImplementedError, "controller not implemented for #{ self.class.name }"
51
+
52
+ end
53
+
54
+ end # Abstraction
55
+
56
+ end # MobyController
@@ -0,0 +1,21 @@
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
+ # command_data controller abstraction class etc.
21
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'abstraction.rb' ) )
@@ -0,0 +1,134 @@
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
+ module MobyBase
22
+
23
+ class Error
24
+
25
+ @@errors = {
26
+ :WrongArgumentType => {:type => "ArgumentError", :text => "Wrong argument type %s (Expected %s)"},
27
+ :WrongArgumentTypeFor => {:type => "ArgumentError", :text => "Wrong argument type %s for %s (Expected %s)"},
28
+ :ArgumentSymbolExpected => {:type => "ArgumentError", :text => "Symbol %s expected in argument(s)"},
29
+ :InvalidStringLengthFor => {:type => "ArgumentError", :text => "Invalid string length (%i) for %s (Expected %s)"},
30
+ :BehaviourErrorOccured => {:type => "RuntimeError", :text => "%s method failed with message: %s. Debug info: %s"}
31
+ }
32
+
33
+ def self.raise( error_id, *params )
34
+
35
+ if @@errors.has_key?( error_id )
36
+
37
+ error_type = eval(@@errors[ error_id ][ :type ])
38
+ error_text = @@errors[ error_id ][ :text ]
39
+
40
+ # Replace %s to given parameters
41
+ message = error_text.gsub( /\%[-]*\d*[disxX]/ ) { | match | ( params.size > 0 ) ? "#{ match }" % params.shift : match }
42
+
43
+ else
44
+
45
+ # Raise ArgumentError if given id is not defined in @@error_base hash table
46
+ error_type = ArgumentError
47
+ message = "No error found for ID '%s' (Parameters: %s)" % [ error_id, params.join( ", " ) ]
48
+
49
+ end
50
+
51
+ error = error_type.new( message )
52
+ raise error
53
+ end
54
+
55
+ # enable hooking for performance measurement & debug logging
56
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
57
+
58
+ end
59
+
60
+ # TODO: document
61
+ class MobyStandardError < StandardError
62
+ # Construct a new error, optionally passing in a message
63
+ def initialize ( message = nil ); super( message ); end
64
+ end
65
+
66
+ # TODO: document
67
+ class TestObjectNotVisibleError < MobyStandardError; end;
68
+
69
+ # TODO: document
70
+ class TestObjectNotFoundError < MobyStandardError; end;
71
+
72
+ # TODO: document
73
+ class MultipleTestObjectsIdentifiedError < MobyStandardError; end;
74
+
75
+ # TODO: document
76
+ class MultipleAttributesFoundError < MobyStandardError; end;
77
+
78
+ # TODO: document
79
+ class AttributeNotFoundError < MobyStandardError; end;
80
+
81
+ # TODO: document
82
+ class TestObjectNotInitializedError < MobyStandardError; end;
83
+
84
+ # TODO: document
85
+ class FileNotFoundError < MobyStandardError; end;
86
+
87
+ # TODO: document
88
+ class TestObjectIdentificatorError < MobyStandardError; end;
89
+
90
+ #Raised when a method is called with an invalid parameter(eg. wrong type, impossible value, nil)
91
+ class InvalidParameterError < MobyStandardError; end;
92
+
93
+ # This error should be raised when verification results were not as expected
94
+ class VerificationError < MobyStandardError; end;
95
+
96
+ # This verification error should overwrite standard verification procedure and fail immediately
97
+ #class ContinuousVerificationError < VerificationError; end;
98
+ class ContinuousVerificationError < MobyStandardError; end;
99
+
100
+ # This error should be raised to indicate that a synchronization timeout has elapsed without
101
+ # synchronization conditions having been met.
102
+ class SyncTimeoutError < MobyStandardError; end;
103
+
104
+ class ControllerError < MobyStandardError; end; #def initialize ( msg = nil ); super( msg ); end; end # class
105
+
106
+ class ControllerNotFoundError < MobyStandardError; end;
107
+
108
+ class CommandNotFoundError < MobyStandardError; end
109
+
110
+
111
+ # TODO: document
112
+ class MobyCustomError < StandardError
113
+ attr_reader :message
114
+ def initialize( message = "" )
115
+ # get backtrace from error
116
+ tmp_trace = ( ( $!.nil? ) ? [] : $!.backtrace )
117
+ # add caller method to backtrace
118
+ set_backtrace( ( ( caller( 2 ).nil? ) ? tmp_trace : tmp_trace.unshift( caller( 2 ).first[ /(.+):in/, 1 ] ) ) )
119
+ @message = message << ( $!.nil? ? "" : ". Exception: #{ $!.message }" )
120
+ super
121
+ end
122
+ end
123
+
124
+ # TODO: document
125
+ class BehaviourError < MobyCustomError
126
+ def initialize ( method_name = nil, description = nil )
127
+ super( "%s failed. %s" % [ method_name, description ] )
128
+ end
129
+ end
130
+
131
+ # TODO: document
132
+ class ApplicationNotAvailableError < MobyStandardError; end;
133
+
134
+ end # MobyBase
@@ -0,0 +1,47 @@
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
+
22
+ # behaviour abstraction class, factory and all other related modules etc
23
+ 'behaviour/loader.rb',
24
+
25
+ # command_data abstraction class etc.
26
+ 'command_data/loader.rb',
27
+
28
+ # command_data controller abstraction class etc.
29
+ 'controller/loader.rb',
30
+
31
+ # sut abstract class, generic sut etc
32
+ 'sut/loader.rb',
33
+
34
+ # error classes
35
+ 'errors.rb',
36
+
37
+ # test object abstraction, factory, identificator behaviours and all other related modules
38
+ 'test_object/loader.rb',
39
+
40
+ # state object
41
+ 'state_object.rb'
42
+
43
+ ].each{ | filename |
44
+
45
+ require File.expand_path( File.join( File.dirname( __FILE__ ), filename ) )
46
+
47
+ }
@@ -0,0 +1,373 @@
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
+ # Static representation of the state of a TestObject or SUT.
23
+ # StateObject are not refreshed or synchronize etc.
24
+ class StateObject
25
+
26
+ include MobyBehaviour::ObjectComposition
27
+
28
+ # The test object factory is needed for populating child object accessor methods
29
+ #@test_object_factory
30
+
31
+ # == description
32
+ # attr_accessor
33
+ #
34
+ # == returns
35
+ # Test Object
36
+ # description: test object that was used as parent when this object was created. Can also be of type SUT if sut was the parent (ie. application objects)
37
+ # example: "@sut"
38
+ attr_accessor :parent
39
+
40
+ # TODO: document me
41
+ attr_reader(
42
+ :type, # object type
43
+ :name, # object name
44
+ :id # object id
45
+ )
46
+
47
+ # Creation of a new StateObject from source data.
48
+ # === params
49
+ # options:: Hash containing source data describing the object and all other required configuration values e.g. test object factory, -adapter etc.
50
+ # === returns
51
+ # StateObject:: new StateObject instance
52
+ # === raises
53
+ def initialize( *options )
54
+
55
+ # clone original options array; array is modified below
56
+ options = options.clone
57
+
58
+ # determine is method called with new or deprecated API
59
+
60
+ if options.count == 1 and options.first.kind_of?( Hash )
61
+
62
+ # retrieve first array element
63
+ options = options.shift
64
+
65
+ # verify options argument type
66
+ options.check_type Hash, 'wrong argument type $1 for StateObject options (expected $2)'
67
+
68
+ # verify that :source_data key exists in hash
69
+ source_data = options.require_key :source_data
70
+
71
+ # retrieve reference to parent object
72
+ parent = options[ :parent ]
73
+
74
+ # retrieve reference to test object adapter
75
+ test_object_adapter = options[ :test_object_adapter ]
76
+
77
+ else
78
+
79
+ # print warning if deprecated API is used
80
+ warn_caller '$1:$2 warning: deprecated API; use hash with :source_data, :parent, :test_object_adapter as argument instead of StateObject.new( source_data, parent, test_object_adapter )'
81
+
82
+ # retrieve source data
83
+ source_data = options.shift
84
+
85
+ # retrieve reference to parent object
86
+ parent = options.shift
87
+
88
+ # retrieve reference to test object adapter
89
+ test_object_adapter = options.shift
90
+
91
+ end
92
+
93
+ # verify that parent argument type is correct
94
+ parent.check_type [ NilClass, MobyBase::StateObject, MobyBase::TestObject, MobyBase::SUT ], 'wrong argument type $1 for parent object (expected $2)'
95
+
96
+ # verify that test object adapter argument type is correct
97
+ test_object_adapter.check_type [ NilClass, Class ], 'wrong argument type $1 for test object adapter (expected $2)'
98
+
99
+ # verify that source data argument type is correct
100
+ source_data.check_type [ String, MobyUtil::XML::Element ], 'wrong argument type $1 for source data (expected $2)'
101
+
102
+ # parse source data if given argument is type of string
103
+ source_data = MobyUtil::XML.parse_string( source_data ).root if source_data.kind_of?( String )
104
+
105
+ # store reference to parent object
106
+ @parent = parent
107
+
108
+ # store reference to test object adapter
109
+ if test_object_adapter.nil?
110
+
111
+ if @parent.kind_of?( MobyBase::SUT )
112
+
113
+ @test_object_adapter = @parent.instance_variable_get( :@test_object_adapter )
114
+
115
+ else
116
+
117
+ # Load the new xml only, so old is not supported
118
+ @test_object_adapter = TDriver::OptimizedXML::TestObjectAdapter
119
+
120
+ end
121
+
122
+ else
123
+
124
+ @test_object_adapter = test_object_adapter
125
+
126
+ end
127
+
128
+ # retrieve object attributes
129
+ method( :xml_data= ).call( source_data )
130
+
131
+ # initialize child objects cache for state object
132
+ @child_object_cache = TDriver::TestObjectCache.new
133
+
134
+ # create accessor methods for any child state objects.
135
+ @test_object_adapter.create_child_accessors!( source_data, self )
136
+
137
+ end
138
+
139
+ # Tries to use the missing method id as a child object type and find an object based on it
140
+ def method_missing( method_id, *method_arguments )
141
+
142
+ rules_hash = method_arguments.first
143
+
144
+ rules_hash = Hash.new unless rules_hash.kind_of? Hash
145
+
146
+ rules_hash[ :type ] = method_id
147
+
148
+ begin
149
+
150
+ return child( rules_hash )
151
+
152
+ rescue MobyBase::TestObjectNotFoundError, MobyBase::TestObjectNotVisibleError
153
+
154
+ rules_hash_clone = rules_hash.clone
155
+
156
+ rules_hash_clone.delete( :type )
157
+
158
+ # string representation of used rule hash
159
+ search_attributes_string = rules_hash_clone.collect{ | key, value | ":#{ key } => #{ value.inspect }" }.join( ', ')
160
+
161
+ # construct literal representation of object identifiers
162
+ object_attributes = []
163
+ object_attributes << "id: #{ @id }" if @id
164
+ object_attributes << "type: #{ @type.inspect }" if @type
165
+ object_attributes << "name: #{ @name.inspect }" if @name
166
+
167
+ if search_attributes_string.empty?
168
+
169
+ # do not show any attribute details if none given
170
+ search_attributes_string = ""
171
+
172
+ else
173
+
174
+ # show used attributes
175
+ search_attributes_string = " (attributes #{ search_attributes_string })"
176
+
177
+ end
178
+
179
+ # raise exception
180
+ raise MobyBase::TestObjectNotFoundError.new(
181
+ "The state object (#{ object_attributes.join(", ") }) has no child object with type or behaviour method with name #{ method_id.to_s.inspect }#{ search_attributes_string }"
182
+ )
183
+
184
+ end
185
+
186
+ end
187
+
188
+ # Verifies that another StateObject contains the same data as this object.
189
+ # type, id and name must match.
190
+ #
191
+ # == param
192
+ # other_state_object:: StateObject that this object is compared to.
193
+ # == returns
194
+ # true:: The other StateObject contains the same data as this one.
195
+ # false:: The other StateObject does notcontain the same data as this one.
196
+ # == raises
197
+ # nothing
198
+ def ==( test_object )
199
+
200
+ # optimized version
201
+ test_object.instance_of?( MobyBase::StateObject ) && ( @type == test_object.type ) && ( @id == test_object.id ) && ( @name == test_object.name )
202
+
203
+ end
204
+
205
+ # Check to StateObject objects for equality (ie. contents, not if they are the same object).
206
+ # === param
207
+ # other_state_object:: StateObject this object is compared to.
208
+ # === returns
209
+ # true:: other_state_object is equal to this StateObject.
210
+ # false:: other_state_object is not equal to this StateObject.
211
+ def eql? (other_state_object)
212
+
213
+ self == other_state_object
214
+
215
+ end
216
+
217
+
218
+ # Sets the XML content of this state object. Also sets identification attributes based
219
+ # on the contents of the XML.
220
+ #
221
+ # === params
222
+ # xml_object:: MobyUtil::XML::Element. State as XML.
223
+ def xml_data=( xml_object )
224
+
225
+ @_xml_data = xml_object
226
+
227
+ unused_xpath, @name, @type, @id = @test_object_adapter.get_test_object_identifiers( xml_object )
228
+
229
+ end
230
+
231
+
232
+ # Returns a XML element representing this state object.
233
+ #
234
+ # === returns
235
+ # MobyUtil::XML::Element:: XML representation of this state object
236
+ def xml_data
237
+
238
+ @_xml_data
239
+
240
+ end
241
+
242
+ # Function provides access to parameters of the state object
243
+ # === params
244
+ # name:: String defining the name of the attribute to get
245
+ # === returns
246
+ # String:: Value of the attribute as a string
247
+ # === raises
248
+ # ArgumentError:: name is not a String.
249
+ # AttributeNotFoundError:: if the requested attribute can not be found in the xml data of the object
250
+ def attribute( name )
251
+
252
+ # check argument variable type
253
+ name.check_type( String, "wrong argument type $1 for attribute name (expected $2)" )
254
+
255
+ begin
256
+
257
+ # retrieve attribute(s) from test object; never access ui state xml data directly from behaviour implementation
258
+ @test_object_adapter.test_object_attribute( @_xml_data, name.to_s )
259
+
260
+ rescue MobyBase::AttributeNotFoundError
261
+
262
+ raise MobyBase::AttributeNotFoundError, "Could not find attribute '#{ name.to_s }' for state object of type '#{ type.to_s }'"
263
+
264
+ end
265
+
266
+ end
267
+
268
+ def get_cached_test_object!( object )
269
+
270
+ if @child_object_cache.has_object?( object )
271
+
272
+ object = @child_object_cache[ object ]
273
+
274
+ true
275
+
276
+ else
277
+
278
+ false
279
+
280
+ end
281
+
282
+ end
283
+
284
+ # Creates a state object for a child object of this state object
285
+ # Associates child object as current object's child.
286
+ # and associates self as child object's parent.
287
+ #
288
+ # NOTE:
289
+ # Subsequent calls to #child always returns reference to same child
290
+ # === params
291
+ # attributes:: Hash object holding information for identifying which child to create, eg. :type => :slider
292
+ # === returns
293
+ # StateObject:: new child state object or reference to existing child
294
+ def child( attributes )
295
+
296
+ get_objects( attributes, false )
297
+
298
+ end
299
+
300
+ # TODO: document me
301
+ def children( attributes )
302
+
303
+ get_objects( attributes, true )
304
+
305
+ end
306
+
307
+ # TODO: document me
308
+ def inspect
309
+
310
+ "#<#{ self.class }:0x#{ ( "%x" % ( object_id.to_i << 1 ) )[ 3 .. -1 ] } @id=#{ @id.inspect } @type=\"#{ @type }\" @name=\"#{ @name }\">"
311
+
312
+ end
313
+
314
+ private
315
+
316
+ def get_objects( attributes, multiple_objects )
317
+
318
+ rules = attributes.clone
319
+
320
+ # strip dynamic attributes from rules hash
321
+ dynamic_attributes = rules.strip_dynamic_attributes!
322
+
323
+ # retrieve application object from sut.xml_data
324
+ matches, unused_rule = @test_object_adapter.get_objects( @_xml_data, rules, true )
325
+
326
+ if matches.count == 0
327
+
328
+ # raise exception if no matches found
329
+ raise MobyBase::TestObjectNotFoundError
330
+
331
+ elsif matches.count > 1 and multiple_objects == false and dynamic_attributes.has_key?( :__index ) == false
332
+
333
+ # raise exception if multiple maches found
334
+ raise MobyBase::MultipleTestObjectsIdentifiedError, "Multiple objects found with attributes #{ attributes.inspect }"
335
+
336
+ end
337
+
338
+ # fetch matches, use index if given
339
+ matches = [ matches[ dynamic_attributes[ :__index ] || 0 ] ] unless multiple_objects
340
+
341
+ # create state objects
342
+ matches = matches.collect{ | object_xml |
343
+
344
+ result = StateObject.new(
345
+ :source_data => object_xml,
346
+ :parent => self,
347
+ :test_object_adapter => @test_object_adapter
348
+ )
349
+
350
+ # use cached state object if once already retrieved
351
+ get_cached_test_object!( result ).tap{ | found_in_cache |
352
+
353
+ # add child to objects cache
354
+ @child_object_cache.add_object( result ) unless found_in_cache
355
+
356
+ }
357
+
358
+ # pass result object to array
359
+ result
360
+
361
+ }
362
+
363
+ # return results
364
+ multiple_objects ? matches : matches.first
365
+
366
+ end
367
+
368
+ # enable hooking for performance measurement & debug logging
369
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
370
+
371
+ end # StateObject
372
+
373
+ end # MobyBase