testability-driver-qt-sut-plugin 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/env.rb +26 -0
- data/installer/extconf.rb +62 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin.rb +23 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +156 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +318 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +227 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +140 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +317 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +165 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +333 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +80 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +178 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +906 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +604 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +152 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +151 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +85 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +455 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +100 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +148 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +124 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +283 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +492 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +113 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +93 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +97 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +97 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +230 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +663 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/action.rb +30 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/configure_command.rb +38 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/drag.rb +44 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +50 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +45 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +48 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/infologger_command.rb +38 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +170 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/tap.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +226 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +264 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +60 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +114 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +67 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +52 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +62 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +99 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +51 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +72 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +119 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +225 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +154 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +58 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +77 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +82 -0
- data/lib/testability-driver-qt-sut-plugin.rb +24 -0
- data/xml/behaviour/qt.xml +717 -0
- data/xml/defaults/sut_qt.xml +9 -0
- data/xml/keymap/qt.xml +321 -0
- data/xml/template/qt.xml +124 -0
- metadata +141 -0
@@ -0,0 +1,492 @@
|
|
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
|
+
require 'nokogiri'
|
21
|
+
|
22
|
+
module MobyBehaviour
|
23
|
+
|
24
|
+
module QT
|
25
|
+
|
26
|
+
# == description
|
27
|
+
# Qt SUT specific behaviours
|
28
|
+
#
|
29
|
+
# == behaviour
|
30
|
+
# QtSUT
|
31
|
+
#
|
32
|
+
# == requires
|
33
|
+
# testability-driver-qt-sut-plugin
|
34
|
+
#
|
35
|
+
# == input_type
|
36
|
+
# *
|
37
|
+
#
|
38
|
+
# == sut_type
|
39
|
+
# QT
|
40
|
+
#
|
41
|
+
# == sut_version
|
42
|
+
# *
|
43
|
+
#
|
44
|
+
# == objects
|
45
|
+
# sut
|
46
|
+
#
|
47
|
+
module SUT
|
48
|
+
|
49
|
+
include MobyBehaviour::Behaviour
|
50
|
+
|
51
|
+
@@_event_type_map = { :Mouse => '0', :Touch => '1', :Both => '2' }
|
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
|
61
|
+
|
62
|
+
# == description
|
63
|
+
# Returns XML list of applications running on SUT known to qttasserver
|
64
|
+
# \n
|
65
|
+
# == arguments
|
66
|
+
#
|
67
|
+
# == returns
|
68
|
+
# String
|
69
|
+
# description: tasMessage XML
|
70
|
+
# example: <tasMessage dateTime="2010.10.26 17:01:53.930" version="0.9.1" ><tasInfo id="1" name="Qt4.7.0" type="qt" ><object id="" name="QApplications" type="applications" ></object></tasInfo></tasMessage>
|
71
|
+
#
|
72
|
+
# == exceptions
|
73
|
+
# RuntimeError
|
74
|
+
# 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
|
132
|
+
|
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
|
288
|
+
|
289
|
+
# == description
|
290
|
+
# Starts process memory logging. Information about the given application's
|
291
|
+
# heap memory usage will be stored in a file. In addition to application,
|
292
|
+
# 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.
|
296
|
+
#
|
297
|
+
# == arguments
|
298
|
+
# thread_name
|
299
|
+
# String
|
300
|
+
# description: Name of the application process/thread.
|
301
|
+
# example: 'testapp'
|
302
|
+
#
|
303
|
+
# file_name
|
304
|
+
# String
|
305
|
+
# description: Full name (containing path) of the used log file.
|
306
|
+
# example: 'c:\Data\proc_mem.log'
|
307
|
+
#
|
308
|
+
# timestamp_type
|
309
|
+
# String
|
310
|
+
# description: Type of the used timestamp, either "absolute" for
|
311
|
+
# current system time or "relative" or not specified for
|
312
|
+
# relative timestamp from 0 in milliseconds.
|
313
|
+
# example: 'absolute'
|
314
|
+
#
|
315
|
+
# interval_s
|
316
|
+
# Integer
|
317
|
+
# description: Logging interval in seconds.
|
318
|
+
# example: 2
|
319
|
+
#
|
320
|
+
# == returns
|
321
|
+
# String
|
322
|
+
# description: Response message
|
323
|
+
# example: 'OK'
|
324
|
+
#
|
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
|
341
|
+
|
342
|
+
# == 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.
|
348
|
+
#
|
349
|
+
# == arguments
|
350
|
+
# thread_name
|
351
|
+
# String
|
352
|
+
# description: Name of the application process/thread.
|
353
|
+
# example: 'testapp'
|
354
|
+
#
|
355
|
+
# return_data
|
356
|
+
# String
|
357
|
+
# description: Should the log file data be returned in response message.
|
358
|
+
# If false, only the log file name will be returned.
|
359
|
+
# example: 'true'
|
360
|
+
#
|
361
|
+
# == returns
|
362
|
+
# String
|
363
|
+
# description: Either the full log file name or the log file contents.
|
364
|
+
# example: 'OK'
|
365
|
+
#
|
366
|
+
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
|
382
|
+
|
383
|
+
# == description
|
384
|
+
# 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.
|
388
|
+
#
|
389
|
+
# == arguments
|
390
|
+
# load
|
391
|
+
# Integer
|
392
|
+
# description: Requested CPU load in percentage.
|
393
|
+
# example: 50
|
394
|
+
#
|
395
|
+
# == returns
|
396
|
+
# NilClass
|
397
|
+
# description: -
|
398
|
+
# example: -
|
399
|
+
#
|
400
|
+
def cpu_load_start(load)
|
401
|
+
begin
|
402
|
+
status = execute_command(
|
403
|
+
MobyCommand::Application.new(
|
404
|
+
:CpuLoadStart,
|
405
|
+
nil, nil, nil, nil, nil, nil, nil,
|
406
|
+
{:cpu_load => load} ) )
|
407
|
+
MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully started generating CPU load.;#{ id };sut;{};cpu_load_start;"
|
408
|
+
rescue Exception => e
|
409
|
+
MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to start generating CPU load.;#{ id };sut;{};cpu_load_start;"
|
410
|
+
Kernel::raise RuntimeError.new( "Unable to start generating CPU load: Exception: #{ e.message } (#{ e.class })" )
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
# == description
|
415
|
+
# Stops generating CPU load.
|
416
|
+
#
|
417
|
+
# Note! Currently only supported on Symbian platform.
|
418
|
+
#
|
419
|
+
# == returns
|
420
|
+
# NilClass
|
421
|
+
# description: -
|
422
|
+
# example: -
|
423
|
+
#
|
424
|
+
def cpu_load_stop
|
425
|
+
begin
|
426
|
+
status = execute_command(MobyCommand::Application.new(:CpuLoadStop) )
|
427
|
+
MobyUtil::Logger.instance.log "behaviour", "PASS;Successfully started generating CPU load.;#{ id };sut;{};cpu_load_start;"
|
428
|
+
rescue Exception => e
|
429
|
+
MobyUtil::Logger.instance.log "behaviour", "FAIL;Failed to start generating CPU load.;#{ id };sut;{};cpu_load_start;"
|
430
|
+
Kernel::raise RuntimeError.new( "Unable to start generating CPU load: Exception: #{ e.message } (#{ e.class })" )
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
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]
|
478
|
+
end
|
479
|
+
|
480
|
+
# {: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) )
|
483
|
+
end
|
484
|
+
|
485
|
+
# enable hooking for performance measurement & debug logging
|
486
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
487
|
+
|
488
|
+
end
|
489
|
+
|
490
|
+
end
|
491
|
+
|
492
|
+
end
|