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,182 @@
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 MobyBehaviour
21
+
22
+ # == description
23
+ # SwitchboxBehaviour related behaviour
24
+ #
25
+ # == behaviour
26
+ # GenericSwitchboxBehaviour
27
+ #
28
+ # == requires
29
+ # *
30
+ #
31
+ # == input_type
32
+ # *
33
+ #
34
+ # == sut_type
35
+ # *
36
+ #
37
+ # == sut_version
38
+ # *
39
+ #
40
+ # == objects
41
+ # sut
42
+ #
43
+ module SwitchboxBehaviour
44
+
45
+ include MobyBehaviour::Behaviour
46
+
47
+ # Instructs the SUT to reboot
48
+ # === params
49
+ # === returns
50
+ # === raises
51
+ def reset
52
+ str_sleep_time_before_powerup = parameter(:switchbox_sleep_before_powerup_in_reboot)
53
+ Kernel::raise BehaviourError.new("reboot", "switchbox_sleep_before_powerup_in_reboot not defined for sut in tdriver_parameters.xml") if str_sleep_time_before_powerup == nil
54
+
55
+ str_sleep_time_after_powerup = parameter(:switchbox_sleep_after_powerup_in_reboot)
56
+ Kernel::raise BehaviourError.new("reboot", "switchbox_sleep_after_powerup_in_reboot not defined for sut in tdriver_parameters.xml") if str_sleep_time_after_powerup == nil
57
+
58
+ str_commands_after_powerup = parameter(:switchbox_commands_after_powerup_in_reboot)
59
+
60
+ begin
61
+ sleep_time_before_powerup = str_sleep_time_before_powerup.to_i
62
+ Kernel::raise BehaviourError.new("reboot", "switchbox_sleep_before_powerup_in_reboot need to be non-negative integer smaller than 50 seconds") if sleep_time_before_powerup < 0 or sleep_time_before_powerup > 50
63
+
64
+ rescue
65
+ Kernel::raise BehaviourError.new("reboot", "switchbox_sleep_in_reboot could not be converted to integer")
66
+ end
67
+
68
+ begin
69
+ sleep_time_after_powerup = str_sleep_time_after_powerup.to_i
70
+ Kernel::raise BehaviourError.new("reboot", "switchbox_sleep_after_powerup_in_reboot need to be non-negative integer smaller than 500 seconds") if sleep_time_after_powerup < 0 or sleep_time_after_powerup > 500
71
+
72
+ rescue
73
+ Kernel::raise BehaviourError.new("reboot", "switchbox_sleep_after_powerup_in_reboot could not be converted to integer")
74
+ end
75
+
76
+
77
+
78
+ power_down
79
+ begin
80
+ disconnect
81
+ rescue
82
+ end
83
+ sleep sleep_time_before_powerup
84
+ power_up
85
+ sleep sleep_time_after_powerup
86
+
87
+ MobyUtil::Retryable.until( :timeout => 60, :retry_timeout => 5 ) {
88
+ system(str_commands_after_powerup) if str_commands_after_powerup != nil
89
+ if MobyUtil::Parameter[ :ats4_error_recovery_enabled, false ]=='true'
90
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;TDriver attempting reconnect"
91
+ self.connect(self.id)
92
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;TDriver connected"
93
+ else
94
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;ATS4 handling reconnection"
95
+ end
96
+
97
+ }
98
+ end
99
+
100
+ # Instructs the switchbox to power down the sut
101
+ # === params
102
+ # === returns
103
+ # === raises
104
+ def power_down
105
+ str_command_arr = []
106
+
107
+ str_command = parameter(:switchbox_powerdown_command_sequence)
108
+
109
+ switchbox_sequence_timeout = parameter(:switchbox_timeout_between_command_sequence)
110
+
111
+ Kernel::raise BehaviourError.new("power_down", "switchbox_timeout_between_command_sequence not defined for sut in tdriver_parameters.xml") if switchbox_sequence_timeout == nil
112
+
113
+ Kernel::raise BehaviourError.new("power_down", "switchbox_powerdown_command not defined for sut in tdriver_parameters.xml") if str_command == nil
114
+
115
+ str_result = parameter(:switchbox_powerdown_command_success_string)
116
+ Kernel::raise BehaviourError.new("power_down", "switchbox_powerdown_command_success string not defined for sut in tdriver_parameters.xml") if str_result == nil
117
+
118
+ #generate the sequence
119
+ str_command_arr = str_command.split('|')
120
+
121
+ #execute switchbox command
122
+ str_command_arr.each do |foobox_command|
123
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Executing powerdown command #{foobox_command}"
124
+ std_out = system(foobox_command)
125
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Powerdown command #{foobox_command} executed"
126
+ sleep switchbox_sequence_timeout.to_i
127
+ Kernel::raise BehaviourError.new("power_down", "Failed to power down") unless std_out.to_s.downcase.include?(str_result.to_s.downcase)
128
+ end
129
+ @switch_box_power_status = false
130
+ end
131
+
132
+ # Instructs the switchbox to power up the sut
133
+ # === params
134
+ # === returns
135
+ # === raises
136
+ def power_up
137
+ str_command_arr = []
138
+
139
+ switchbox_sequence_timeout = parameter(:switchbox_timeout_between_command_sequence)
140
+
141
+ Kernel::raise BehaviourError.new("power_down", "switchbox_timeout_between_command_sequence not defined for sut in tdriver_parameters.xml") if switchbox_sequence_timeout == nil
142
+
143
+ str_command = parameter(:switchbox_powerup_command_sequence)
144
+ Kernel::raise BehaviourError.new("power_up", "switchbox_powerup_command not defined for sut in tdriver_parameters.xml") if str_command == nil
145
+
146
+ str_result = parameter(:switchbox_powerup_command_success_string)
147
+ Kernel::raise BehaviourError.new("power_up", "switchbox_powerup_command_success string not defined for sut in tdriver_parameters.xml") if str_result == nil
148
+
149
+ #generate the sequence
150
+ str_command_arr = str_command.split('|')
151
+
152
+ #execute switchbox command
153
+ str_command_arr.each do |foobox_command|
154
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Executing powerup command #{foobox_command}"
155
+ std_out = system(foobox_command)
156
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Ppowerup command #{foobox_command} executed"
157
+ sleep switchbox_sequence_timeout.to_i
158
+ Kernel::raise BehaviourError.new("power_up", "Failed to power up") unless std_out.to_s.downcase.include?(str_result.to_s.downcase)
159
+ end
160
+
161
+ @switch_box_power_status = true
162
+ end
163
+
164
+ # Gets the current power status of the switchbox
165
+ # === params
166
+ # === returns
167
+ # === raises
168
+ def power_status
169
+ if @switch_box_power_status == nil
170
+ false
171
+ else
172
+ @switch_box_power_status
173
+ end
174
+ end
175
+
176
+ # enable hooking for performance measurement & debug logging
177
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
178
+
179
+ end
180
+
181
+ end
182
+
@@ -0,0 +1,119 @@
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 MobyBehaviour
21
+
22
+ # == description
23
+ # Defines methods for verification of sut and test object state
24
+ #
25
+ # == behaviour
26
+ # GenericVerification
27
+ #
28
+ # == requires
29
+ # *
30
+ #
31
+ # == input_type
32
+ # *
33
+ #
34
+ # == sut_type
35
+ # *
36
+ #
37
+ # == sut_version
38
+ # *
39
+ #
40
+ # == objects
41
+ # *;sut
42
+ #
43
+ module Verification
44
+
45
+ include MobyBehaviour::Behaviour
46
+
47
+ # == description
48
+ # Checks if a child test object matching the given criteria can be found on the sut
49
+ # === params
50
+ # type:: String defining the type of the object
51
+ # attributes:: (optional) Hash containing attributes that the object must have
52
+ # === returns
53
+ # Boolean:: true if the object exists on the sut display
54
+ # === raises
55
+ # ArgumentError:: The type argument was not a non-empty String or attributes argument (if provided) was not a Hash
56
+ # === example
57
+ # @calc = @sut.run(:name => 'calculator') # launches calculator
58
+ # testobj_exists = @calc.test_object_exists?('Button',{:text => '+',:objectName => 'plusButton'} # check if test object with given criteria exists in calculator
59
+
60
+ def test_object_exists?(type, attributes = Hash.new)
61
+
62
+ Kernel::raise ArgumentError.new "The type argument must be a non empty String." unless (type.kind_of? String and !type.empty?)
63
+ Kernel::raise ArgumentError.new "The attributes argument must be a Hash." unless attributes.kind_of? Hash
64
+
65
+ #attributes_with_type = {}.merge attributes
66
+ attributes_with_type = attributes.clone
67
+ attributes_with_type[:type] = type
68
+ attributes_with_type.delete(:__logging)
69
+
70
+ #translate the symbol values into string using sut's localisation setting
71
+ translate!( attributes_with_type )
72
+
73
+ identificator = MobyBase::TestObjectIdentificator.new( attributes_with_type )
74
+
75
+ original_logging = MobyUtil::Logger.instance.enabled
76
+ desired_logging = (attributes[:__logging] == nil || attributes[:__logging] == 'false') ? false : true
77
+ MobyUtil::Logger.instance.enabled = false
78
+
79
+
80
+ begin
81
+
82
+ self.child( attributes_with_type )
83
+ MobyUtil::Logger.instance.enabled = desired_logging
84
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Test object of type #{type} with attributes #{attributes.inspect} was found.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s : ''};test_object_exist;"
85
+
86
+ rescue MobyBase::MultipleTestObjectsIdentifiedError
87
+
88
+ MobyUtil::Logger.instance.enabled = desired_logging
89
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Multiple objects of type #{type} with attributes #{attributes.inspect} were found.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s : ''};test_object_exist;"
90
+ return true
91
+
92
+ rescue MobyBase::TestObjectNotFoundError
93
+
94
+ MobyUtil::Logger.instance.enabled = desired_logging
95
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Test object of type #{type} with attributes #{attributes.inspect} was not found.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s : ''};test_object_exist;"
96
+ return false
97
+
98
+ rescue Exception => e
99
+
100
+ MobyUtil::Logger.instance.enabled = desired_logging
101
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Test object of type #{type} with attributes #{attributes.inspect} was not found.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s : ''};test_object_exist;"
102
+ Kernel::raise e
103
+
104
+ ensure
105
+
106
+ MobyUtil::Logger.instance.enabled = original_logging
107
+
108
+ end
109
+
110
+ return true
111
+
112
+ end
113
+
114
+ # enable hooking for performance measurement & debug logging
115
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
116
+
117
+ end # module VerificationBehaviour
118
+
119
+ end # module MobyBase
@@ -0,0 +1,219 @@
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 MobyCommand
22
+
23
+ class Application < MobyCommand::CommandData
24
+
25
+ #TODO: Team TE review @ Wheels
26
+ #Application command types
27
+ #Launch application = :Run
28
+ #Close application = :Close
29
+ #List of running applications = :List
30
+ #Current state of the UI = :State
31
+ #Kill = :Kill
32
+ #Kill All = :KillAll
33
+ #
34
+ # Constructs a new Application CommandData object
35
+ # == params
36
+ # command_type:: (optional) Symbol, defines the command to perform on the application
37
+ # app_name:: (optional) String, name of application to perform this command on
38
+ # app_uid::
39
+ # sut:: (optional) SUT, creator of the command. Can be used to access parameters when creating messages.
40
+ # arguments:: (optional) Arguments given to the application on start up. Comma separated list if more the one.
41
+ # == returns
42
+ # Application:: New CommandData object
43
+ # == raises
44
+ # ArgumentError:: When the supplied command_type is invalid.
45
+ def initialize( command_type = nil, app_name = nil, app_uid = nil, sut = nil, arguments = nil, environment = nil, events_to_listen = nil, signals_to_listen = nil, flags = nil, start_command = nil)
46
+ # Set status value to nil (not executed)
47
+
48
+ self.command( command_type )
49
+ self.name( app_name )
50
+ self.uid( app_uid )
51
+ self.sut( sut )
52
+ self.arguments( arguments )
53
+ self.events_to_listen( events_to_listen )
54
+ self.signals_to_listen( signals_to_listen )
55
+ self.environment( environment )
56
+ self.flags( flags )
57
+ self.start_command( start_command )
58
+ self.refresh_args
59
+
60
+ @_attribute_csv_string = nil
61
+
62
+ self
63
+
64
+ end
65
+
66
+ # Store the args for possible future use
67
+ def refresh_args(refresh_args={})
68
+ @_refresh_args = refresh_args
69
+ end
70
+
71
+ def get_refresh_args
72
+ @_refresh_args
73
+ end
74
+
75
+
76
+ # Defines the type of command this Application CommandData object represents
77
+ # == params
78
+ # command_type:: Symbol, defines the command to perform on the application
79
+ # == returns
80
+ # Application:: This CommandData object
81
+ # == raises
82
+ # ArgumentError:: When the supplied command_type is invalid.
83
+ def command( command_type )
84
+
85
+ @_command = command_type
86
+ self
87
+
88
+ end
89
+
90
+ # Defines the used SUT to be able to access parameters when creating messages
91
+ # == params
92
+ # sut:: SUT, creator of the command.
93
+ # == returns
94
+ # Application:: This CommandData object
95
+ # == raises
96
+ # ArgumentError:: When sut is not nil or a SUT
97
+ def sut( sut )
98
+
99
+ raise ArgumentError.new( "The given sut must be nil or a SUT." ) unless sut == nil || sut.kind_of?( MobyBase::SUT )
100
+ @_sut = sut
101
+ self
102
+
103
+ end
104
+
105
+ # Defines the name of the application this Application CommandData object is associated with
106
+ # == params
107
+ # app_name:: String, name of application to perform this command on
108
+ # == returns
109
+ # Application:: This CommandData object
110
+ # == raises
111
+ # ArgumentError:: When app_name is not nil or a String
112
+ def name( app_name )
113
+
114
+ raise ArgumentError.new( "The given application name must be nil or a String." ) unless app_name == nil || app_name.kind_of?( String )
115
+ @_application_name = app_name
116
+ self
117
+
118
+ end
119
+
120
+ def arguments( arguments )
121
+
122
+ raise ArgumentError.new( "The given application arguments must be nil or a String." ) unless arguments == nil || arguments.kind_of?( String )
123
+ @_arguments = arguments
124
+
125
+ end
126
+
127
+ def flags( flags )
128
+
129
+ raise ArgumentError.new( "The given application flags must be nil or a Hash." ) unless flags == nil || flags.kind_of?( Hash )
130
+ @_flags = flags
131
+
132
+ end
133
+
134
+ def environment( environment )
135
+
136
+ raise ArgumentError.new( "The given application environment must be nil or a String." ) unless environment == nil || environment.kind_of?( String )
137
+ @_environment = environment
138
+
139
+ end
140
+
141
+ def events_to_listen( events )
142
+
143
+ raise ArgumentError.new( "The events to listen must be nil or a String." ) unless events == nil || events.kind_of?( String )
144
+ @_events_to_listen = events
145
+
146
+ end
147
+
148
+ def signals_to_listen( signals )
149
+
150
+ raise ArgumentError.new( "The signals to listen must be nil or a String." ) unless signals == nil || signals.kind_of?( String )
151
+ @_signals_to_listen = signals
152
+
153
+ end
154
+
155
+ def start_command( start_command )
156
+
157
+ raise ArgumentError.new( "The start_command must be nil or a String." ) unless start_command == nil || start_command.kind_of?( String )
158
+ @_start_command = start_command
159
+
160
+ end
161
+
162
+ # Defines the uid of the application this Application CommandData object is associated with
163
+ # == params
164
+ # app_uid:: FixNum, uid of application to perform this command on
165
+ # == returns
166
+ # Application:: This CommandData object
167
+ # == raises
168
+ # ArgumentError:: When app_name is not nil or a String
169
+ def uid( app_uid )
170
+
171
+ raise ArgumentError.new( "The given application uid must be nil, a String or an Integer." ) unless app_uid == nil || app_uid.kind_of?( String ) || app_uid.kind_of?( Fixnum )
172
+ @_application_uid = app_uid
173
+ @_application_uid = @_application_uid.to_i unless @_application_uid == nil
174
+ self
175
+
176
+ end
177
+
178
+ def get_command
179
+
180
+ @_command
181
+
182
+ end
183
+
184
+ def get_application
185
+
186
+ @_application_name
187
+
188
+ end
189
+
190
+ def get_uid
191
+
192
+ @_application_uid
193
+
194
+ end
195
+
196
+ def get_flags
197
+
198
+ @_flags
199
+
200
+ end
201
+
202
+ def attribute_filter(attribute_string)
203
+
204
+ @_attribute_csv_string = attribute_string
205
+
206
+ end
207
+
208
+ def get_attribute_filter
209
+
210
+ @_attribute_csv_string
211
+
212
+ end
213
+
214
+ # enable hooking for performance measurement & debug logging
215
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
216
+
217
+ end # Application
218
+
219
+ end # MobyCommand