testability-driver-qt-sut-plugin 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +11 -8
  2. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +3 -3
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +76 -74
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +2 -0
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +10 -4
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +49 -42
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +0 -9
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +5 -0
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +11 -1
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +441 -324
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +32 -11
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +54 -34
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +26 -26
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +61 -21
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +528 -344
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +16 -138
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +3 -67
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +4 -18
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +1 -1
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +166 -149
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +80 -75
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +93 -0
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +161 -0
  24. data/xml/behaviour/qt.xml +26 -26
  25. data/xml/template/qt.xml +9 -7
  26. metadata +7 -6
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +0 -45
@@ -60,7 +60,6 @@ module MobyBehaviour
60
60
  # The file path given must exist on the target.
61
61
  # Optional append parameter can also be given and if true the log file will not be cleared if one exists (by default a new file will always be started).
62
62
  # example: {:interval => 1, :filePath => 'C:\Data', :append => true}
63
- # default: No default values, must be set
64
63
  #
65
64
  # == returns
66
65
  # nil
@@ -145,7 +144,6 @@ module MobyBehaviour
145
144
  # Hash
146
145
  # description: Optional parameters.
147
146
  # example: {:clearLog => true}
148
- # default: No default values, must be set
149
147
  #
150
148
  # == returns
151
149
  # Xml
@@ -189,7 +187,6 @@ module MobyBehaviour
189
187
  # The file path given must exist on the target.
190
188
  # Optional append parameter can also be given and if true the log file will not be cleared if one exists (by default a new file will always be started).
191
189
  # example: {:interval => 1, :filePath => 'C:\Data', :append => true}
192
- # default: No default values, must be set
193
190
  #
194
191
  # == returns
195
192
  # nil
@@ -269,7 +266,6 @@ module MobyBehaviour
269
266
  # Hash
270
267
  # description: Optional parameters.
271
268
  # example: {:clearLog => true}
272
- # default: No default values, must be set
273
269
  #
274
270
  # == returns
275
271
  # Xml
@@ -313,7 +309,6 @@ module MobyBehaviour
313
309
  # The file path given must exist on the target.
314
310
  # Optional append parameter can also be given and if true the log file will not be cleared if one exists (by default a new file will always be started).
315
311
  # example: {:interval => 1, :filePath => 'C:\Data', :append => true}
316
- # default: No default values, must be set
317
312
  #
318
313
  # == returns
319
314
  # nil
@@ -426,7 +421,6 @@ module MobyBehaviour
426
421
  # Hash
427
422
  # description: Optional parameters.
428
423
  # example: {:clearLog => true}
429
- # default: No default values, must be set
430
424
  #
431
425
  # == returns
432
426
  # Xml
@@ -475,7 +469,6 @@ module MobyBehaviour
475
469
  # Hash
476
470
  # description: Optional params hash. If :clearLog => true given will clear the log when loading by default log will not be cleared.
477
471
  # example: {:clearLog = true}
478
- # default: nil
479
472
  #
480
473
  #
481
474
  # == returns
@@ -504,7 +497,6 @@ module MobyBehaviour
504
497
  # Hash
505
498
  # description: Optional params hash. If :clearLog => true given will clear the log when loading by default log will not be cleared.
506
499
  # example: {:clearLog = true}
507
- # default: nil
508
500
  #
509
501
  #
510
502
  # == returns
@@ -533,7 +525,6 @@ module MobyBehaviour
533
525
  # Hash
534
526
  # description: Optional params hash. If :clearLog => true given will clear the log when loading by default log will not be cleared.
535
527
  # example: {:clearLog = true}
536
- # default: nil
537
528
  #
538
529
  #
539
530
  # == returns
@@ -52,6 +52,11 @@ module MobyBehaviour
52
52
  # == description
53
53
  # Creates a new localisation able for translation using the tdriver_parameters to locate the Localization DB.
54
54
  # It uses the temporary folder to store temporary translation files.
55
+ # The table structure will have the different languages as columns and the comun names will be set as the
56
+ # postfix language code from the source filenames for .qm and .ts files. For .loc files, the two-digit postfix
57
+ # will be mapped to the same language codes as in .qm or .ts when possible forlowing the mapping table on
58
+ # symbian reference documentation. To see the full mapping used please check the localization.rb implementation
59
+ # file on testability-driver gem.
55
60
  #
56
61
  # == arguments
57
62
  # path
@@ -46,6 +46,11 @@ module MobyBehaviour
46
46
 
47
47
  include MobyBehaviour::QT::Behaviour
48
48
 
49
+ # == nodoc
50
+ # == returns
51
+ # NilClass
52
+ # description: -
53
+ # example: -
49
54
  def start_recording
50
55
 
51
56
  begin
@@ -67,6 +72,11 @@ module MobyBehaviour
67
72
  nil
68
73
  end
69
74
 
75
+ # == nodoc
76
+ # == returns
77
+ # NilClass
78
+ # description: -
79
+ # example: -
70
80
  def stop_recording
71
81
 
72
82
  begin
@@ -89,6 +99,7 @@ module MobyBehaviour
89
99
 
90
100
  end
91
101
 
102
+ # == nodoc
92
103
  def print_recordings
93
104
 
94
105
  ret = nil
@@ -116,7 +127,6 @@ module MobyBehaviour
116
127
  # enable hooking for performance measurement & debug logging
117
128
  MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
118
129
 
119
-
120
130
  end # Record
121
131
 
122
132
  end
@@ -44,20 +44,24 @@ module MobyBehaviour
44
44
  # == objects
45
45
  # sut
46
46
  #
47
- module SUT
47
+ module SUT
48
48
 
49
- include MobyBehaviour::Behaviour
49
+ include MobyBehaviour::Behaviour
50
50
 
51
- @@_event_type_map = { :Mouse => '0', :Touch => '1', :Both => '2' }
51
+ @@_event_type_map = { :Mouse => '0', :Touch => '1', :Both => '2' }
52
52
 
53
- # QT specific feature.
54
- # Kills all of the application processed started through the server.
55
- def kill_started_processes
56
-
57
- # execute the application control service request
58
- execute_command( MobyCommand::Application.new( :KillAll ) )
59
-
60
- end
53
+ # == description
54
+ # Kills all of the applications started through the server.
55
+ # == returns
56
+ # NilClass
57
+ # description: -
58
+ # example: -
59
+ def kill_started_processes
60
+
61
+ # execute the application control service request
62
+ execute_command( MobyCommand::Application.new( :KillAll ) )
63
+ nil
64
+ end
61
65
 
62
66
  # == description
63
67
  # Returns XML list of applications running on SUT known to qttasserver
@@ -72,227 +76,308 @@ module MobyBehaviour
72
76
  # == exceptions
73
77
  # RuntimeError
74
78
  # description: if getting applications list throws any exception it's converted to RuntimeError with descriptive message
75
- def list_apps
76
-
77
- apps = nil
78
-
79
- begin
80
- # execute the application control service request
81
- apps = execute_command( MobyCommand::Application.new( :ListApps ) )
82
- MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully listed applications.;#{ id };sut;{};list_apps;"
83
-
84
- rescue Exception => e
85
-
86
- MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to list applications.;#{ id };sut;{};list_apps;"
87
- Kernel::raise RuntimeError.new( "Unable to list applications: Exception: #{ e.message } (#{ e.class })" )
88
-
89
- end
90
-
91
- apps
92
-
93
- end
94
-
95
- # Returns list of crashed applications running on SUT known to qttasserver
96
- # ==usage
97
- # apps = sut.list_crashed_apps()
98
- # ==return
99
- # String:: Xml string containing crashed applications, their names, process ids and crash times
100
- def list_crashed_apps
101
-
102
- apps = nil
103
-
104
- begin
105
- # execute the application control service request
106
- apps = execute_command( MobyCommand::Application.new( :ListCrashedApps ) )
107
- MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully listed crashed applications.;#{ id };sut;{};list_crashed_apps;"
108
- rescue Exception => e
109
- MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to list crashed applications.;#{ id };sut;{};list_crashed_apps;"
110
- Kernel::raise RuntimeError.new( "Unable to list crashed applications: Exception: #{ e.message } (#{ e.class })" )
111
- end
112
-
113
- apps
114
- end
115
-
116
- # Executes the given command as a new process
117
- #
118
- # === params
119
- # command:: String containing the command to execute and any arguments
120
- # param:: Hash with the flags for the command
121
- # === returns
122
- # String:: Output of the command, if any
123
- # === raises
124
- # ArgumentError:: The command argument was not a non empty String
125
- def execute_shell_command(command, param = { :detached => "false"} )
126
- Kernel::raise ArgumentError.new("The command argument must be a non empty String.") unless ( command.kind_of?( String ) and !command.empty? )
127
- Kernel::raise ArgumentError.new("The parameters argumet must be a Hash.") unless ( param.kind_of?(Hash) )
128
-
129
- if param[:detached].nil?
130
- param[:detached] = "false"
131
- end
79
+ def list_apps
80
+
81
+ apps = nil
82
+
83
+ begin
84
+ # execute the application control service request
85
+ apps = execute_command( MobyCommand::Application.new( :ListApps ) )
86
+ MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully listed applications.;#{ id };sut;{};list_apps;"
87
+
88
+ rescue Exception => e
89
+
90
+ MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to list applications.;#{ id };sut;{};list_apps;"
91
+ Kernel::raise RuntimeError.new( "Unable to list applications: Exception: #{ e.message } (#{ e.class })" )
92
+
93
+ end
94
+
95
+ apps
96
+
97
+ end
98
+
99
+ # == description
100
+ # Returns list of crashed applications running on SUT known to qttasserver
101
+ # == returns
102
+ # String
103
+ # description: XML string containing crashed applications, their names, process ids and crash times
104
+ # example: "<tasMessage dateTime="2010.11.02 14:48:11.056" version="0.9.1" ><tasInfo id="1" name="Qt4.6.2" type="qt" ><object id="" name="QApplications" type="applications" ></object></tasInfo></tasMessage>"
105
+ def list_crashed_apps
106
+
107
+ apps = nil
108
+
109
+ begin
110
+ # execute the application control service request
111
+ apps = execute_command( MobyCommand::Application.new( :ListCrashedApps ) )
112
+ MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully listed crashed applications.;#{ id };sut;{};list_crashed_apps;"
113
+ rescue Exception => e
114
+ MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to list crashed applications.;#{ id };sut;{};list_crashed_apps;"
115
+ Kernel::raise RuntimeError.new( "Unable to list crashed applications: Exception: #{ e.message } (#{ e.class })" )
116
+ end
117
+
118
+ apps
119
+ end
120
+
121
+ # == description
122
+ # Executes the command in a shell in the target sut. Note that the executable need to be in path or otherwise you need to use full absolute path. No relative paths can be used with this command. If the process started will take more than 4 seconds to exit then you should launch the process in detached mode by adding the parameter hash ":detached => 'true'" to the arguments. By default processes are launched in "synchronus" mode.
123
+ #
124
+ # == arguments
125
+ # command
126
+ # String
127
+ # description: String containing the command executable to execute and any arguments it might need. Executable can be used without path if it is in PATH. Otherwise full absolute path is needed. A shell is required for piped commands (UNIX).
128
+ # example: "ruby script.rb" or 'sh -c "ruby script.rb|grep output'"
129
+ #
130
+ # param
131
+ # Hash
132
+ # description: Hash with the flags for the command
133
+ # example: {:wait => 'true', :timeout => 13}
134
+ #
135
+ # == tables
136
+ # execute_shell_command_hash
137
+ # title: Parameter hash keys
138
+ # |Key|Description|Default|
139
+ # |:detached|Hash containing the ':detached' key with 'true' or 'false' strings as value.|false|
140
+ # |:threaded|If :thread is set true, the command will be run in a background thrad and the command will return the PID of the process. See [link="#QtSUT:shell_command"]shell_command[/link] for information about controlling the command.|false|
141
+ # |:wait|Execute a threaded command and wait for the command to complete. Return value will contain the output of the command. Use :wait if the shell command execution taks longer than 4 seconds.|false|
142
+ # |:timeout|Timeout for :wait, in seconds. If timeout is reached, the command will be killed. RunTimeError occurs if timeout is reached.|300|
143
+ #
144
+ # == returns
145
+ # String
146
+ # description: Output of the command if any
147
+ # example: "OK"
148
+ #
149
+ # == Exceptions
150
+ # ArgumentError
151
+ # description: The command argument was not a non empty String.
152
+ #
153
+ # ArgumentError
154
+ # description: The parameters argumet must be a Hash.
155
+ #
156
+ # RuntimeError
157
+ # description: Timeout of %s seconds reached. %s
158
+ def execute_shell_command(command, param = { :detached => "false"} )
159
+ Kernel::raise ArgumentError.new("The command argument must be a non empty String.") unless ( command.kind_of?( String ) and !command.empty? )
160
+ Kernel::raise ArgumentError.new("The parameters argumet must be a Hash.") unless ( param.kind_of?(Hash) )
161
+
162
+ if param[:detached].nil?
163
+ param[:detached] = "false"
164
+ end
132
165
 
133
- param[:timeout].nil? ? timeout = 300 : timeout = param[:timeout].to_i
134
-
135
- # Launch the program execution into the background, wait for it to finish.
136
- if param[:wait].to_s == "true"
137
- param[:threaded] = "true"
138
- pid = execute_command( MobyCommand::Application.new( :Shell, command, nil, nil, nil, nil, nil, nil, param ) ).to_i
139
- data = ""
140
- if pid != 0
141
- time = Time.new + timeout
142
- while true
143
- obj = shell_command(pid)
144
- sleep 1
145
- data += obj['output']
146
- if Time.new > time
147
- command_params = {:kill => 'true'}
148
- command_output = shell_command(pid, command_params)['output']
149
- Kernel::raise RuntimeError.new( "Timeout of #{timeout.to_s} seconds reached. #{command_output}")
150
- elsif obj['status'] == "RUNNING"
151
- next
152
- else
153
- break
154
- end
155
- end
156
- end
157
- return data
158
- end
159
-
160
- return execute_command( MobyCommand::Application.new( :Shell, command, nil, nil, nil, nil, nil, nil, param ) ).to_s
161
- end
162
-
163
- # Returns the command status of given shell command
164
- #
165
- # === params
166
- # pid:: Integer of the process id given.
167
- # param:: Hash with the flags for the command
168
- # === returns
169
- # Hash:: Information about the shell command.
170
- # === raises
171
- # ArgumentError:: The command argument was not a non empty String
172
- def shell_command(pid, param = {} )
173
- Kernel::raise ArgumentError.new("pid argument should be positive integer.") unless pid.to_i > 0
174
- param[ :status ] = 'true'
175
- xml_source = execute_command( MobyCommand::Application.new( :Shell, pid.to_s, nil, nil, nil, nil, nil, nil, param ) ).to_s
176
- if param[:kill].nil?
177
- xml = Nokogiri::XML(xml_source)
178
- data = {}
179
- xml.xpath("//object[@type = 'Response']/attributes/attribute").each { |attr|
180
- data[attr[:name]] = attr.children[0].content
181
- }
182
- return data
183
- else
184
- # Killed processes have no relevant data.
185
- data = {
186
- :status => "KILLED",
187
- :output => xml_source
188
- }
189
- end
190
- end
191
-
192
- # == description
193
- # Returns details about the tested target. The data is platform/device specific which will make your scripts platform dependant. For devices with mobility apis the data available from them is returned and could be somewhat similar across platforms. Memory details are returned in a fixed format so they can be used and still maintain compatibility cross platforms. However it should be noted that platforms which do not support memory details will return -1 (scripts will not break but data will not be usable).
194
- # == arguments
195
- # == returns
196
- # MobyBase::StateObject
197
- # description: Similar object to test objects.
198
- # example: -
199
- # == exceptions
200
- def system_information
201
- xml_source = execute_command( MobyCommand::Application.new( :SystemInfo, nil) )
202
- MobyBase::StateObject.new( xml_source )
203
- end
204
-
205
- # == description
206
- # Returns the memory used by the qttassever in bytes. Note that this will query for the details from the device. If you intend to use all of the memory details see system_information on how to get the details in one query.
207
- # == arguments
208
- # == returns
209
- # Integer
210
- # description: Memory usage in bytes, or -1 if there was an error
211
- # example: 7376896
212
- # == exceptions
213
- def agent_mem_usage
214
- info = self.system_information
215
- begin
216
- info.MemoryStatus.attribute('qttasMemUsage').to_i
217
- rescue Exception => e
218
- -1
219
- end
220
- end
221
-
222
- # == description
223
- # Returns the total amount of memory in bytes. Note that this will query for the details from the device. If you intend to all of the memory details see system_information on how to get the details in one query.
224
- # == arguments
225
- # == returns
226
- # Integer
227
- # description: Amount of total memory, or -1 if there was an error
228
- # example: 2147483647
229
- # == exceptions
230
- def system_total_mem
231
- info = self.system_information
232
- begin
233
- info.MemoryStatus.attribute('total').to_i
234
- rescue Exception => e
235
- -1
236
- end
237
- end
238
-
239
- # == description
240
- # Returns the amount of available memory in bytes. Note that this will query for the details from the device. If you intend to use all of the memory details see system_information on how to get the details in one query.
241
- # == arguments
242
- # == returns
243
- # Integer
244
- # description: Amount of available memory, or -1 if there was an error
245
- # example: 1214980096
246
- # == exceptions
247
- def system_available_mem
248
- info = self.system_information
249
- begin
250
- info.MemoryStatus.attribute('available').to_i
251
- rescue Exception => e
252
- -1
253
- end
254
- end
255
-
256
- # tap screen on given coordinates
257
- # x:: X Coordinate to tap
258
- # y:: Y Coordinate to tap
259
- # time_to_hold:: How long is the ta pressed down, in seconds. default 0.1s
260
- # == params
261
- def tap_screen(x,y,time_to_hold = 0.1) # todo count
262
-
263
- command = MobyCommand::Tap.new(x,y,time_to_hold)
264
-
265
- begin
266
- execute_command( command )
267
- nil
268
- rescue Exception => e
269
-
270
- MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed tap_screen on coords \"#{x}:#{y}\";"
271
- Kernel::raise e
272
-
273
- end
274
-
275
- end
276
-
277
- def close_qttas
278
- begin
279
- # execute the application control service request
280
- apps = execute_command( MobyCommand::Application.new( :CloseQttas ) )
281
- MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully closed qttas.;#{ id };sut;{};close_qttas;"
282
- rescue Exception => e
283
- MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to close qttas.;#{ id };sut;{};close_qttas;"
284
- Kernel::raise RuntimeError.new( "Unable to close qttas: Exception: #{ e.message } (#{ e.class })" )
285
- end
286
-
287
- end
166
+ param[:timeout].nil? ? timeout = 300 : timeout = param[:timeout].to_i
167
+
168
+ # Launch the program execution into the background, wait for it to finish.
169
+ if param[:wait].to_s == "true"
170
+ param[:threaded] = "true"
171
+ pid = execute_command( MobyCommand::Application.new( :Shell, command, nil, nil, nil, nil, nil, nil, param ) ).to_i
172
+ data = ""
173
+ if pid != 0
174
+ time = Time.new + timeout
175
+ while true
176
+ obj = shell_command(pid)
177
+ sleep 1
178
+ data += obj['output']
179
+ if Time.new > time
180
+ command_params = {:kill => 'true'}
181
+ command_output = shell_command(pid, command_params)['output']
182
+ Kernel::raise RuntimeError.new( "Timeout of #{timeout.to_s} seconds reached. #{command_output}")
183
+ elsif obj['status'] == "RUNNING"
184
+ next
185
+ else
186
+ break
187
+ end
188
+ end
189
+ end
190
+ return data
191
+ end
192
+
193
+ return execute_command( MobyCommand::Application.new( :Shell, command, nil, nil, nil, nil, nil, nil, param ) ).to_s
194
+ end
195
+
196
+ # == description
197
+ # Control and retrieve data from a command started by [link="#QtSUT:execute_shell_command"]execute_shell_command[/link]. On a running process, the status and produced output is returned. The command will remove all output from the server that has already been retrieved by the testability driver script. If the command status is FINISHED, all information is removed from the server.
198
+ #
199
+ # == arguments
200
+ # pid
201
+ # Integer
202
+ # description: Process id of the command returned by the threaded execute_shell_command.
203
+ # example: 23442
204
+ #
205
+ # param
206
+ # Hash
207
+ # description: Additional parameters for the command. Currently supported is ":kill", which will kill the process.
208
+ # example: {:kill => 'true'}
209
+ #
210
+ # == tables
211
+ # shell_command_return_values
212
+ # title: Shell command return values
213
+ # |Key|Description|
214
+ # |status|RUNNING, ERROR, FINISHED|
215
+ # |output|Command output|
216
+ # |exitCode|Return code of the command if finished|
217
+ #
218
+ # == returns
219
+ # Hash
220
+ # description: The return hash will be empty if no pid is found.
221
+ # example: {:status => 'FINISHED', :output => 'example_output', :exitCode => 0}
222
+ #
223
+ # == exceptions
224
+ # ArgumentError
225
+ # description: The command argument was not a non empty String
226
+ #
227
+ def shell_command(pid, param = {} )
228
+ Kernel::raise ArgumentError.new("pid argument should be positive integer.") unless pid.to_i > 0
229
+ param[ :status ] = 'true'
230
+ xml_source = execute_command( MobyCommand::Application.new( :Shell, pid.to_s, nil, nil, nil, nil, nil, nil, param ) ).to_s
231
+ if param[:kill].nil?
232
+ xml = Nokogiri::XML(xml_source)
233
+ data = {}
234
+ xml.xpath("//object[@type = 'Response']/attributes/attribute").each { |attr|
235
+ data[attr[:name]] = attr.children[0].content
236
+ }
237
+ return data
238
+ else
239
+ # Killed processes have no relevant data.
240
+ data = {
241
+ :status => "KILLED",
242
+ :output => xml_source
243
+ }
244
+ end
245
+ end
246
+
247
+ # == description
248
+ # Returns details about the tested target. The data is platform/device specific which will make your scripts platform dependant. For devices with mobility apis the data available from them is returned and could be somewhat similar across platforms. Memory details are returned in a fixed format so they can be used and still maintain compatibility cross platforms. However it should be noted that platforms which do not support memory details will return -1 (scripts will not break but data will not be usable).
249
+ # == arguments
250
+ # == returns
251
+ # MobyBase::StateObject
252
+ # description: Similar object to test objects.
253
+ # example: -
254
+ # == exceptions
255
+ def system_information
256
+ xml_source = execute_command( MobyCommand::Application.new( :SystemInfo, nil) )
257
+ MobyBase::StateObject.new( xml_source )
258
+ end
259
+
260
+ # == description
261
+ # Returns the memory used by the qttassever in bytes. Note that this will query for the details from the device. If you intend to use all of the memory details see system_information on how to get the details in one query.
262
+ # == arguments
263
+ # == returns
264
+ # Integer
265
+ # description: Memory usage in bytes, or -1 if there was an error
266
+ # example: 7376896
267
+ # == exceptions
268
+ def agent_mem_usage
269
+ info = self.system_information
270
+ begin
271
+ info.MemoryStatus.attribute('qttasMemUsage').to_i
272
+ rescue Exception => e
273
+ -1
274
+ end
275
+ end
276
+
277
+ # == description
278
+ # Returns the total amount of memory in bytes. Note that this will query for the details from the device. If you intend to all of the memory details see system_information on how to get the details in one query.
279
+ # == arguments
280
+ # == returns
281
+ # Integer
282
+ # description: Amount of total memory, or -1 if there was an error
283
+ # example: 2147483647
284
+ # == exceptions
285
+ def system_total_mem
286
+ info = self.system_information
287
+ begin
288
+ info.MemoryStatus.attribute('total').to_i
289
+ rescue Exception => e
290
+ -1
291
+ end
292
+ end
293
+
294
+ # == description
295
+ # Returns the amount of available memory in bytes. Note that this will query for the details from the device. If you intend to use all of the memory details see system_information on how to get the details in one query.
296
+ # == arguments
297
+ # == returns
298
+ # Integer
299
+ # description: Amount of available memory, or -1 if there was an error
300
+ # example: 1214980096
301
+ # == exceptions
302
+ def system_available_mem
303
+ info = self.system_information
304
+ begin
305
+ info.MemoryStatus.attribute('available').to_i
306
+ rescue Exception => e
307
+ -1
308
+ end
309
+ end
310
+
311
+ # == description
312
+ # Taps the SUT screen at the specified coordinates.\n
313
+ # \n
314
+ # [b]NOTE:[/b] Method is only implemented in *nix enviroments.
315
+ #
316
+ # == arguments
317
+ # x
318
+ # Fixnum
319
+ # description: Target point vertical axis coordinate.
320
+ # example: 50
321
+ # y
322
+ # Fixnum
323
+ # description: Target point horizontal axis coordinate.
324
+ # example: 100
325
+ #
326
+ # time_to_hold
327
+ # Float
328
+ # description: Duration of the tap, in seconds.
329
+ # example: 0.1
330
+ #
331
+ # == returns
332
+ # NilClass
333
+ # description: Always returns nil
334
+ # example: -
335
+ #
336
+ def tap_screen( x, y, time_to_hold = 0.1 ) # todo count
337
+
338
+ command = MobyCommand::Tap.new(x,y,time_to_hold)
339
+
340
+ begin
341
+ execute_command( command )
342
+ nil
343
+ rescue Exception => e
344
+
345
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed tap_screen on coords \"#{x}:#{y}\";"
346
+ Kernel::raise e
347
+
348
+ end
349
+
350
+ end
351
+
352
+ # == nodoc
353
+ # == description
354
+ # Request the qttasserver to shutdown. This command will cause the qttasserver to close. The sut will no longer be usable after this command. To resume testing qttasserver must be restarted.
355
+ # == returns
356
+ # NilClass
357
+ # description: -
358
+ # example: -
359
+ # == exceptions
360
+ # RuntimeError
361
+ # description: Unable to close qttas: Exception: %s (%s)
362
+ def close_qttas
363
+ begin
364
+ # execute the application control service request
365
+ execute_command( MobyCommand::Application.new( :CloseQttas ) )
366
+ MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully closed qttas.;#{ id };sut;{};close_qttas;"
367
+ rescue Exception => e
368
+ MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to close qttas.;#{ id };sut;{};close_qttas;"
369
+ Kernel::raise RuntimeError.new( "Unable to close qttas: Exception: #{ e.message } (#{ e.class })" )
370
+ end
371
+ nil
372
+ end
288
373
 
289
374
  # == description
290
375
  # Starts process memory logging. Information about the given application's
291
376
  # heap memory usage will be stored in a file. In addition to application,
292
377
  # used log file can be specified as well as the type of timestamp and
293
- # interval length (in seconds).
294
- #
295
- # Note! Currently only supported on Symbian platform.
378
+ # interval length (in seconds).\ŋ
379
+ # \n
380
+ # [b]NOTE:[/b] Currently only supported on Symbian platform.
296
381
  #
297
382
  # == arguments
298
383
  # thread_name
@@ -322,29 +407,28 @@ module MobyBehaviour
322
407
  # description: Response message
323
408
  # example: 'OK'
324
409
  #
325
- def log_process_mem_start(thread_name, file_name = nil, timestamp_type = nil, interval_s = nil)
326
- status = nil
327
- begin
328
- status = execute_command(
329
- MobyCommand::Application.new(
330
- :ProcessMemLoggingStart,
331
- thread_name,
332
- nil, nil, nil, nil, nil, nil,
333
- {:file_name => file_name, :timestamp => timestamp_type, :interval_s => interval_s} ) )
334
- MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully started process memory logging.;#{ id };sut;{};log_process_mem_start;"
335
- rescue Exception => e
336
- MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to start process memory logging.;#{ id };sut;{};log_process_mem_start;"
337
- Kernel::raise RuntimeError.new( "Unable to start process memory logging: Exception: #{ e.message } (#{ e.class })" )
338
- end
339
- status
340
- end
410
+ def log_process_mem_start(thread_name, file_name = nil, timestamp_type = nil, interval_s = nil)
411
+ status = nil
412
+ begin
413
+ status = execute_command(
414
+ MobyCommand::Application.new(
415
+ :ProcessMemLoggingStart,
416
+ thread_name,
417
+ nil, nil, nil, nil, nil, nil,
418
+ {:file_name => file_name, :timestamp => timestamp_type, :interval_s => interval_s} ) )
419
+ MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully started process memory logging.;#{ id };sut;{};log_process_mem_start;"
420
+ rescue Exception => e
421
+ MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to start process memory logging.;#{ id };sut;{};log_process_mem_start;"
422
+ Kernel::raise RuntimeError.new( "Unable to start process memory logging: Exception: #{ e.message } (#{ e.class })" )
423
+ end
424
+ status
425
+ end
341
426
 
342
427
  # == description
343
- # Stops process memory logging. Logging of the given application's heap
344
- # memory usage is stopped. Either the full log file name or the log file
345
- # contents will be returned.
346
- #
347
- # Note! Currently only supported on Symbian platform.
428
+ # Stops process memory logging. Logging of the given application's heap memory usage is stopped. Either the full log file name or the log file
429
+ # contents will be returned.\n
430
+ # \n
431
+ # [b]NOTE:[/b] Currently only supported on Symbian platform.
348
432
  #
349
433
  # == arguments
350
434
  # thread_name
@@ -364,27 +448,27 @@ module MobyBehaviour
364
448
  # example: 'OK'
365
449
  #
366
450
  def log_process_mem_stop(thread_name, return_data = nil)
367
- log = nil
368
- begin
369
- log = execute_command(
370
- MobyCommand::Application.new(
371
- :ProcessMemLoggingStop,
372
- thread_name,
373
- nil, nil, nil, nil, nil, nil,
374
- {:return_data => return_data} ) )
375
- MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully stopped process memory logging.;#{ id };sut;{};log_process_mem_stop;"
376
- rescue Exception => e
377
- MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to stop process memory logging.;#{ id };sut;{};log_process_mem_stop;"
378
- Kernel::raise RuntimeError.new( "Unable to stop process memory logging: Exception: #{ e.message } (#{ e.class })" )
379
- end
380
- log
381
- end
451
+ log = nil
452
+ begin
453
+ log = execute_command(
454
+ MobyCommand::Application.new(
455
+ :ProcessMemLoggingStop,
456
+ thread_name,
457
+ nil, nil, nil, nil, nil, nil,
458
+ {:return_data => return_data} ) )
459
+ MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully stopped process memory logging.;#{ id };sut;{};log_process_mem_stop;"
460
+ rescue Exception => e
461
+ MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to stop process memory logging.;#{ id };sut;{};log_process_mem_stop;"
462
+ Kernel::raise RuntimeError.new( "Unable to stop process memory logging: Exception: #{ e.message } (#{ e.class })" )
463
+ end
464
+ log
465
+ end
382
466
 
383
467
  # == description
384
468
  # Starts generating CPU load. Tries to generate CPU load as accurately as
385
- # it can but depending on other activities on the system it might vary.
386
- #
387
- # Note! Currently only supported on Symbian platform.
469
+ # it can but depending on other activities on the system it might vary. \n
470
+ # \n
471
+ # [b]NOTE:[/b] Currently only supported on Symbian platform.
388
472
  #
389
473
  # == arguments
390
474
  # load
@@ -393,17 +477,17 @@ module MobyBehaviour
393
477
  # example: 50
394
478
  #
395
479
  # == returns
396
- # NilClass
397
- # description: -
398
- # example: -
480
+ # NilClass
481
+ # description: -
482
+ # example: -
399
483
  #
400
484
  def cpu_load_start(load)
401
485
  begin
402
486
  status = execute_command(
403
487
  MobyCommand::Application.new(
404
- :CpuLoadStart,
405
- nil, nil, nil, nil, nil, nil, nil,
406
- {:cpu_load => load} ) )
488
+ :CpuLoadStart,
489
+ nil, nil, nil, nil, nil, nil, nil,
490
+ {:cpu_load => load} ) )
407
491
  MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully started generating CPU load.;#{ id };sut;{};cpu_load_start;"
408
492
  rescue Exception => e
409
493
  MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to start generating CPU load.;#{ id };sut;{};cpu_load_start;"
@@ -412,14 +496,14 @@ module MobyBehaviour
412
496
  end
413
497
 
414
498
  # == description
415
- # Stops generating CPU load.
416
- #
417
- # Note! Currently only supported on Symbian platform.
499
+ # Stops generating CPU load.\n
500
+ # \n
501
+ # [b]NOTE:[/b] Currently only supported on Symbian platform.
418
502
  #
419
503
  # == returns
420
- # NilClass
421
- # description: -
422
- # example: -
504
+ # NilClass
505
+ # description: -
506
+ # example: -
423
507
  #
424
508
  def cpu_load_stop
425
509
  begin
@@ -431,61 +515,94 @@ module MobyBehaviour
431
515
  end
432
516
  end
433
517
 
434
- def group_behaviours( interval, app, &block )
435
- begin
436
- raise ArgumentError.new("Application must be defined!") unless app
437
- raise ArgumentError.new("Interval must be a number.") unless interval.kind_of?(Numeric)
438
-
439
- interval_millis = interval*1000 # to millis
440
-
441
- # make one refresh before execution then freeze
442
- app.force_refresh({:id => get_application_id})
443
- self.freeze
444
-
445
- #disable sleep to avoid unnecessary sleeping
446
- MobyUtil::Parameter[ id ][ :sleep_disabled] = 'true'
447
-
448
- ret = execute_command( MobyCommand::Group.new(interval_millis.to_i, app, block ) )
449
-
450
- MobyUtil::Parameter[ id ][ :sleep_disabled] = 'false'
451
-
452
- self.unfreeze
453
-
454
- # the behaviour returns the amout of behaviours
455
- # sleep to avoid sending messages to the app untill the
456
- # commands have been executed
457
- sleep (ret*interval)
458
-
459
- MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully executed grouped behaviours.;#{ id };sut;{};group_behaviours;"
460
- rescue Exception => e
461
- MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to execute grouped behaviours.;#{ id };sut;{};group_behaviours;"
462
- Kernel::raise RuntimeError.new( "Unable to execute grouped behaviours: Exception: #{ e.message } (#{ e.class })" )
463
- end
464
- end
465
-
466
- # Set the event type used to interact with the target. Possible methods are :Mouse, :Touch and :Both.
467
- # Event generation depends on this setting. If set to :Mouse or :Touch then only those events are generated.
468
- # If set to :Both then both mouse and touch events are sent. In this situation touch events are set as primary.
469
- # This setting has no affect when using multitouch. Note that if you generate multitouch type events e.g. a.tap_down,
470
- # b.tap_down then a.tap_up, b.tap_up you must set the type to :Touch to avoid mouse events to be generated.
471
- # === params
472
- # new_type:: Symbol defining which method to use: :Mouse, :Touch and :Both.
473
- # === raises
474
- # ArgumentError:: If invalid type is given.
475
- def set_event_type(new_type)
476
- raise ArgumentError.new("Invalid event type. Accepted values :" << @@_event_type_map.keys.join(", :") ) unless @@_event_type_map.include?(new_type)
477
- MobyUtil::Parameter[ self.id ][ :event_type] = @@_event_type_map[new_type]
518
+ # == description
519
+ # Groups behaviours into a single message. Commands are executed in the target in sequence using the given interval as timeout between the commands. The interval is not quaranteed to be exactly the specified amount and will vary depending on the load in the target device. Therefore it is not recommended to use the interval as basis for the test results. The commands are all executed in the target device in a single roundtrip from TDriver to the target device so no verification will or can be done between the commands so do not group behaviours which change the ui in a way that the next command may fail. Best use cases for the grouping is static behaviours such as virtual keyboard button taps. Behaviours can only be qrouped for one application at a time and you need to provide the application object as parameter. Sut behaviours cannot be grouped.
520
+ # == arguments
521
+ # interval
522
+ # Fixnum
523
+ # description: Inteval time in seconds (0.1 is an acceptable value)
524
+ # example: 1
525
+ # app
526
+ # MobyBase::TestObject
527
+ # description: The target application for the grouped behaviours
528
+ # example: -
529
+ # &block
530
+ # Proc
531
+ # description: Code block containing the behaviours to group as one.
532
+ # example: {app.Object.tap;app.Object_two.tap}
533
+ # == returns
534
+ # NilClass
535
+ # description: -
536
+ # example: -
537
+ def group_behaviours( interval, app, &block )
538
+ begin
539
+ raise ArgumentError.new("Application must be defined!") unless app
540
+ raise ArgumentError.new("Interval must be a number.") unless interval.kind_of?(Numeric)
541
+
542
+ interval_millis = interval*1000 # to millis
543
+
544
+ # make one refresh before execution then freeze
545
+ app.force_refresh({:id => get_application_id})
546
+ self.freeze
547
+
548
+ #disable sleep to avoid unnecessary sleeping
549
+ MobyUtil::Parameter[ id ][ :sleep_disabled] = 'true'
550
+
551
+ ret = execute_command( MobyCommand::Group.new(interval_millis.to_i, app, block ) )
552
+
553
+ MobyUtil::Parameter[ id ][ :sleep_disabled] = 'false'
554
+
555
+ self.unfreeze
556
+
557
+ # the behaviour returns the amout of behaviours
558
+ # sleep to avoid sending messages to the app untill the
559
+ # commands have been executed
560
+ sleep (ret*interval)
561
+
562
+ MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully executed grouped behaviours.;#{ id };sut;{};group_behaviours;"
563
+ rescue Exception => e
564
+ MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to execute grouped behaviours.;#{ id };sut;{};group_behaviours;"
565
+ Kernel::raise RuntimeError.new( "Unable to execute grouped behaviours: Exception: #{ e.message } (#{ e.class })" )
566
+ end
567
+ nil
568
+ end
569
+
570
+ # == description
571
+ # Set the event type used to interact with the target. Possible methods are :Mouse, :Touch and :Both.
572
+ # Event generation depends on this setting. If set to :Mouse or :Touch then only those events are generated.
573
+ # If set to :Both then both mouse and touch events are sent. In this situation touch events are set as primary.
574
+ # This setting has no affect when using multitouch.\n\n
575
+ # [b]NOTE:[/b] If you generate multitouch type events e.g. a.tap_down,
576
+ # b.tap_down then a.tap_up, b.tap_up you must set the type to :Touch to avoid mouse events to be generated.
577
+ # == arguments
578
+ # new_type
579
+ # Symbol
580
+ # description: Symbol defining which method to use: :Mouse, :Touch and :Both.
581
+ # example: :Touch
582
+ # == returns
583
+ # NilClass
584
+ # description: -
585
+ # example: -
586
+ # == raises
587
+ # ArgumentError
588
+ # description: If invalid type is given.
589
+ #
590
+ def set_event_type(new_type)
591
+ raise ArgumentError.new("Invalid event type. Accepted values :" << @@_event_type_map.keys.join(", :") ) unless @@_event_type_map.include?(new_type)
592
+ MobyUtil::Parameter[ self.id ][ :event_type] = @@_event_type_map[new_type]
593
+ nil
478
594
  end
479
595
 
596
+ # == nodoc
480
597
  # {:name => '', id => '', applicationUid => ''},[ {:objectName => '' , :className => , :text =>} ,..]
481
- def find_object(app_details = nil, objects = nil)
482
- ret = execute_command( MobyCommand::FindObjectCommand.new(self, app_details, objects) )
598
+ def find_object( app_details = nil, objects = nil )
599
+ execute_command( MobyCommand::FindObjectCommand.new( self, app_details, objects ) )
483
600
  end
484
601
 
485
602
  # enable hooking for performance measurement & debug logging
486
603
  MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
487
604
 
488
- end
605
+ end
489
606
 
490
607
  end
491
608