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.
Files changed (61) hide show
  1. data/env.rb +26 -0
  2. data/installer/extconf.rb +62 -0
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin.rb +23 -0
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +156 -0
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +318 -0
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +227 -0
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +140 -0
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +317 -0
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +165 -0
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +333 -0
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +80 -0
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +178 -0
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +906 -0
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +604 -0
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +152 -0
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +151 -0
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +85 -0
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +455 -0
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +100 -0
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +148 -0
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +124 -0
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +283 -0
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +492 -0
  24. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +113 -0
  25. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +93 -0
  26. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +97 -0
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +97 -0
  28. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +230 -0
  29. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +663 -0
  30. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/action.rb +30 -0
  31. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/configure_command.rb +38 -0
  32. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/drag.rb +44 -0
  33. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +50 -0
  34. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +45 -0
  35. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +48 -0
  36. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/infologger_command.rb +38 -0
  37. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +170 -0
  38. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/tap.rb +54 -0
  39. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +226 -0
  40. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +264 -0
  41. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +60 -0
  42. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +114 -0
  43. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +67 -0
  44. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +52 -0
  45. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +62 -0
  46. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +99 -0
  47. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +54 -0
  48. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +51 -0
  49. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +72 -0
  50. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +119 -0
  51. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +225 -0
  52. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +154 -0
  53. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +58 -0
  54. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +77 -0
  55. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +82 -0
  56. data/lib/testability-driver-qt-sut-plugin.rb +24 -0
  57. data/xml/behaviour/qt.xml +717 -0
  58. data/xml/defaults/sut_qt.xml +9 -0
  59. data/xml/keymap/qt.xml +321 -0
  60. data/xml/template/qt.xml +124 -0
  61. metadata +141 -0
@@ -0,0 +1,663 @@
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
+
21
+
22
+ # TODO: document
23
+ module MobyBehaviour
24
+
25
+ module QT
26
+
27
+ # == description
28
+ # Widget specific behaviours
29
+ #
30
+ # == behaviour
31
+ # QtWidget
32
+ #
33
+ # == requires
34
+ # testability-driver-qt-sut-plugin
35
+ #
36
+ # == input_type
37
+ # touch
38
+ #
39
+ # == sut_type
40
+ # qt
41
+ #
42
+ # == sut_version
43
+ # *
44
+ #
45
+ # == objects
46
+ # *
47
+ #
48
+ module Widget
49
+
50
+ include MobyBehaviour::QT::Behaviour
51
+
52
+ # Moves the mouse to the object it was called on.
53
+ # == params
54
+ # refresh::(optional) if true will cause the framework to refresh the ui state. Default is false.
55
+ # === examples
56
+ # @object.move_mouse
57
+ def move_mouse( move_params = false )
58
+
59
+ $stderr.puts "#{ caller(0).last.to_s } warning: move_mouse(boolean) is deprecated; use move_mouse(Hash)" if move_params == true
60
+
61
+ begin
62
+ # Hide all future params in a hash
63
+ use_tap_screen = false
64
+ if move_params.kind_of? Hash
65
+ use_tap_screen = move_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
66
+ move_params[:use_tap_screen].to_s
67
+ else
68
+ use_tap_screen = MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false']
69
+ end
70
+ command = command_params #in qt_behaviour
71
+ command.command_name('MouseMove')
72
+
73
+ if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
74
+ params = {'x' => center_x, 'y' => center_y, 'useCoordinates' => 'true',
75
+ 'useTapScreen' => use_tap_screen}
76
+ else
77
+ params = {'useTapScreen' => use_tap_screen.to_s}
78
+ end
79
+ command.command_params(params)
80
+
81
+ @sut.execute_command(command)
82
+
83
+ rescue Exception => e
84
+
85
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed to mouse_move"
86
+ Kernel::raise e
87
+ end
88
+
89
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation mouse_move executed successfully"
90
+
91
+ nil
92
+
93
+ end
94
+
95
+ # Taps the screen on the coordinates of the object.
96
+ # == params
97
+ # tap_count::(optional defaults to 1)number of times to tap the screen
98
+ # button::(optional defaults to :Left) button symbol supported values are: :NoButton, :Left, :Right, :Middle
99
+ # x::(optional defaults to nil) x coordinate inside object to click, if nil then center is used
100
+ # y::(optional defaults to nil) y coordinate inside object to click, if nil then center is used
101
+ # == returns
102
+ # == raises
103
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
104
+ # ArgumentError:: If an invalid button type is given
105
+ # ArgumentError:: If coordinates are outside of the object
106
+ # === examples
107
+ # @object.tap
108
+ # def tap( tap_count = 1, interval = nil, button = :Left)
109
+ # def tap( tap_count = 1, interval = nil, button = :Left, tap_screen = false, duration = 0.1 )
110
+ def tap( tap_params = 1, interval = nil, button = :Left )
111
+ # tapMeasure = Time.now
112
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - tap start"
113
+
114
+ # delegate duration taps to grouped behaviors
115
+ if tap_params.kind_of?(Hash) && !tap_params[:duration].nil?
116
+ @sut.group_behaviours(tap_params[:duration], get_application) {
117
+ tap_down
118
+ tap_up
119
+ }
120
+ return
121
+ end
122
+
123
+ begin
124
+ #for api compatibility
125
+ if interval and interval.kind_of?(Symbol)
126
+ button = interval
127
+ interval = nil
128
+ end
129
+
130
+ # Another one, first param a has for the rest
131
+ if tap_params.kind_of?(Hash)
132
+ interval = tap_params[:interval]
133
+ if tap_params[:button].nil?
134
+ button = :Left
135
+ else
136
+ button = tap_params[:button]
137
+ end
138
+
139
+ tap_count = tap_params[:tap_count].nil? ? 1 : tap_params[:tap_count]
140
+ use_tap_screen = tap_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
141
+ tap_params[:use_tap_screen].to_s
142
+ else
143
+ tap_count = tap_params
144
+
145
+ use_tap_screen = MobyUtil::Parameter[@sut.id][ :use_tap_screen, 'false']
146
+ end
147
+
148
+ raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
149
+ if interval
150
+ raise ArgumentError.new( "Invalid interval must be an integer." ) unless interval.kind_of?(Integer)
151
+ end
152
+
153
+ command = command_params #in qt_behaviour
154
+ command.command_name('Tap')
155
+
156
+ params = {
157
+ 'count' => tap_count.to_s,
158
+ 'button' => @@_buttons_map[button],
159
+ 'mouseMove' => MobyUtil::Parameter[ @sut.id ][ :in_tap_move_pointer, 'false' ],
160
+ 'useTapScreen' => use_tap_screen
161
+ }
162
+
163
+
164
+ if interval
165
+ params[:interval] = (interval.to_f * 1000).to_i
166
+ end
167
+
168
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - before webs"
169
+
170
+ if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
171
+ params['x'] = center_x
172
+ params['y'] = center_y
173
+ params['useCoordinates'] = 'true'
174
+ end
175
+
176
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - before 2 webs"
177
+
178
+ if(attribute('objectType') == 'Web')
179
+ if type != "QWebFrame"
180
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - Not q webframe"
181
+
182
+ x_absolute = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='x_absolute']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
183
+ y_absolute = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='y_absolute']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
184
+ width = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='width']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
185
+ height = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='height']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
186
+
187
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - x_a(#{x_absolute}), y_a(#{y_absolute}), w(#{width}), h(#{height})"
188
+
189
+
190
+ if((center_x.to_i < x_absolute) or
191
+ (center_x.to_i > x_absolute + width) or
192
+ (center_y.to_i < y_absolute) or
193
+ (center_y.to_i > y_absolute + height)
194
+ )
195
+ #puts "web element scroll"
196
+ self.scroll(0,0,1) # enable tap centralization
197
+ #puts "web element force refresh in tap"
198
+ self.force_refresh({:id => get_application_id})
199
+ self.tap(tap_params, interval, button)
200
+ return
201
+ end
202
+ end
203
+ end
204
+ command.command_params(params)
205
+
206
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - tap about to execute "
207
+ @sut.execute_command( command )
208
+
209
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - executed"
210
+ #do not allow operations to continue untill taps done
211
+ if interval
212
+ sleep interval * tap_count
213
+ end
214
+
215
+ rescue Exception => e
216
+
217
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed tap with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};tap;"
218
+ Kernel::raise e
219
+
220
+ end
221
+
222
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation tap executed successfully with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};tap;"
223
+
224
+ # puts "tap: " + (Time.now - tapMeasure).to_s + " s - tapping ending"
225
+
226
+
227
+ nil
228
+
229
+ end
230
+
231
+ # == description
232
+ # Taps the screen on the specified coordinates of the object. Given coordinates are relative to the object.
233
+ #
234
+ # == arguments
235
+ # x
236
+ # Integer
237
+ # description: x coordinate inside object to click
238
+ # example: 5
239
+ #
240
+ # y
241
+ # Integer
242
+ # description: y coordinate inside object to click
243
+ # example: 5
244
+ #
245
+ # tap_count
246
+ # Integer
247
+ # description: number of times to tap the screen
248
+ # example: 1
249
+ #
250
+ # button
251
+ # Symbol
252
+ # description: button symbol supported values are: :NoButton, :Left, :Right, :Middle
253
+ # example: :Left
254
+ #
255
+ # tap_params
256
+ # Hash
257
+ # description: parameter that also incorporate all previous tap_object_* commands :command, :behavior_name and :use_tap_screen
258
+ # example: { }
259
+ #
260
+ # == returns
261
+ # NilClass
262
+ # description: -
263
+ # example: -
264
+ #
265
+ # == exceptions
266
+ # TestObjectNotFoundError
267
+ # description: If a graphics item is not visible on screen
268
+ #
269
+ # ArgumentError
270
+ # description: If coordinates are outside of the object
271
+ #
272
+ def tap_object( x, y, tap_count = 1, button = :Left, tap_params = nil )
273
+
274
+ begin
275
+ # New hash format for the parameter. Also incorporates all
276
+ # previous tap_object_* commands that were redundant.
277
+ if tap_params.kind_of? Hash
278
+ command_name = tap_params[:command].nil? ? 'Tap' : tap_params[:command]
279
+ behavior_name = tap_params[:behavior_name].nil? ? 'tap_object' : tap_params[:behavior_name]
280
+
281
+ use_tap_screen = tap_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
282
+ tap_params[:use_tap_screen].to_s
283
+ else
284
+ use_tap_screen = MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false']
285
+ command_name = 'Tap'
286
+ behavior_name = 'tap_object'
287
+ end
288
+
289
+ raise ArgumentError.new( "Coordinate x:#{x} x_abs:#{x} outside object." ) unless ( x <= attribute( 'width' ).to_i and x >= 0 )
290
+ raise ArgumentError.new( "Coordinate y:#{y} y_abs:#{y} outside object." ) unless ( y <= attribute( 'height' ).to_i and y >= 0 )
291
+
292
+ command = command_params #in qt_behaviour
293
+ command.command_name(command_name)
294
+
295
+
296
+
297
+ command.command_params(
298
+ 'x' => ( attribute('x_absolute').to_i + x.to_i ).to_s,
299
+ 'y' => ( attribute('y_absolute').to_i + y.to_i ).to_s,
300
+ 'count' => tap_count.to_s,
301
+ 'button' => @@_buttons_map[ button ],
302
+ 'mouseMove' => MobyUtil::Parameter[ @sut.id ][ :in_tap_move_pointer, 'false' ],
303
+ 'useCoordinates' => 'true',
304
+ 'useTapScreen' => use_tap_screen
305
+ )
306
+
307
+ @sut.execute_command(command)
308
+
309
+ rescue Exception => e
310
+
311
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed #{behavior_name} with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};#{behavior_name};"
312
+ Kernel::raise e
313
+
314
+ end
315
+
316
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation #{behavior_name} executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};#{behavior_name};"
317
+
318
+ nil
319
+
320
+ end
321
+
322
+ # Tap down on the screen on the specified coordinates of the object. Given coordinates are relative to the object.
323
+ # == params
324
+ # x::x coordinate inside object
325
+ # y::y coordinate inside object
326
+ # button::(optional defaults to :Left) button symbol supported values are: :NoButton, :Left, :Right, :Middle
327
+ # == returns
328
+ # == raises
329
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
330
+ # ArgumentError:: If coordinates are outside of the object
331
+ # === examples
332
+ # @object.tap_down_object(5, 5)
333
+ def tap_down_object( x, y, button = :Left, tap_params = {} )
334
+ tap_params[:behavior_name] = 'tap_down_object'
335
+ tap_params[:command] = 'MousePress'
336
+ tap_object(x,y,1,button,tap_params)
337
+ end
338
+
339
+ # Tap up on the screen on the specified coordinates of the object. Given coordinates are relative to the object.
340
+ # == params
341
+ # x::x coordinate inside object
342
+ # y::y coordinate inside object
343
+ # button::(optional defaults to :Left) button symbol supported values are: :NoButton, :Left, :Right, :Middle
344
+ # tap_params::(optional, defautlts to Hash} Hash consisting of any additional parameter.
345
+ # == returns
346
+ # == raises
347
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
348
+ # ArgumentError:: If coordinates are outside of the object
349
+ # === examples
350
+ # @object.tap_up_object(5, 5)
351
+ def tap_up_object( x, y = -1, button = :Left, tap_params = {} )
352
+ tap_params[:behavior_name] = 'tap_up_object'
353
+ tap_params[:command] = 'MouseRelease'
354
+ tap_object(x,y,1,button,tap_params)
355
+ end
356
+
357
+ # Taps the screen on the coordinates of the object for the period of time given is seconds.
358
+ # == params
359
+ # time::(optional defaults to 1) number of seconds to hold the pointer down.
360
+ # button::(optional defaults to :Left) button symbol supported values are: :NoButton, :Left, :Right, :Middle
361
+ # == returns
362
+ # == raises
363
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
364
+ # ArgumentError:: If an invalid button type is given
365
+ # === examples
366
+ # @object.long_tap(2, :Left)
367
+ def long_tap( time = 1, button = :Left, tap_params = {} )
368
+
369
+ logging_enabled = MobyUtil::Logger.instance.enabled
370
+ MobyUtil::Logger.instance.enabled = false
371
+
372
+
373
+ raise ArgumentError.new("First parameter should be time between taps or Hash") unless tap_params.kind_of? Hash or tap_params.kind_of? Fixnum
374
+
375
+
376
+ begin
377
+ tap_down(button, false, tap_params)
378
+ sleep time
379
+ tap_up(button, false, tap_params)
380
+ rescue Exception => e
381
+ MobyUtil::Logger.instance.enabled = logging_enabled
382
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed long_tap with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap;"
383
+ Kernel::raise e
384
+
385
+ end
386
+ MobyUtil::Logger.instance.enabled = logging_enabled
387
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation long_tap executed successfully with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap;"
388
+
389
+ nil
390
+
391
+ end
392
+
393
+ # Long tap on the screen on the given relative coordinates of the object for the period of time given is seconds.
394
+ # == params
395
+ # x::x coordinate inside object
396
+ # y::y coordinate inside object
397
+ # time::(optional defaults to 1) number of seconds to hold the pointer down.
398
+ # button::(optional defaults to :Left) button symbol supported values are: :NoButton, :Left, :Right, :Middle
399
+ # == returns
400
+ # == raises
401
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
402
+ # ArgumentError:: If an invalid button type is given
403
+ # === examples
404
+ # @object.long_tap_object(1, 2, 1, :Left)
405
+ def long_tap_object( x, y, time = 1, button = :Left, tap_params = {} )
406
+
407
+ begin
408
+ tap_down_object(x, y, button, tap_params)
409
+ sleep time
410
+ tap_up_object(x, y, button, tap_params)
411
+ rescue Exception => e
412
+
413
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed long_tap_object with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap_object;"
414
+ Kernel::raise e
415
+
416
+ end
417
+
418
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation long_tap_object executed successfully with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap_object;"
419
+
420
+ nil
421
+
422
+ end
423
+
424
+ # Tap down the screen on the coordinates of the object
425
+ # == params
426
+ # button::(optional defaults to :Left) button symbol supported values are: :NoButton, :Left, :Right, :Middle
427
+ # refresh::(optional) If false ui state will not be updated
428
+ # == returns
429
+ # == raises
430
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
431
+ # ArgumentError:: If an invalid button type is given
432
+ # === examples
433
+ # @object.long_tap_down
434
+ def tap_down( button = :Left, refresh = false, tap_params = {} )
435
+
436
+ begin
437
+ use_tap_screen = tap_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
438
+ tap_params[:use_tap_screen].to_s
439
+ tap_params[:useTapScreen] = use_tap_screen
440
+
441
+ raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
442
+ command = command_params #in qt_behaviour
443
+ command.command_name('MousePress')
444
+
445
+ params = {'button' => @@_buttons_map[button],
446
+ 'mouseMove' => MobyUtil::Parameter[ @sut.id ][ :in_tap_move_pointer, 'false' ],
447
+ 'useTapScreen' => use_tap_screen}
448
+
449
+ if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
450
+ params['x'] = center_x
451
+ params['y'] = center_y
452
+ params['useCoordinates'] = 'true'
453
+ end
454
+ params.merge!(tap_params)
455
+
456
+ command.command_params(params)
457
+ @sut.execute_command(command)
458
+
459
+ self.force_refresh( :id => get_application_id ) if refresh
460
+
461
+ rescue Exception => e
462
+
463
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed tap_down with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_down;"
464
+ Kernel::raise e
465
+
466
+ end
467
+
468
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation tap_down executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_down;"
469
+
470
+ nil
471
+
472
+ end
473
+
474
+ # Release the pointer on the screen on the coordinates of the object
475
+ # == params
476
+ # button::(optional defaults to :Left) button symbol supported values are: :NoButton, :Left, :Right, :Middle
477
+ # refresh::(optional) If false ui state will not be updated
478
+ # == returns
479
+ # == raises
480
+ # TestObjectNotFoundError:: If a graphics item is not visible on screen
481
+ # ArgumentError:: If an invalid button type is given
482
+ # === examples
483
+ # @object.tap_up
484
+ def tap_up( button = :Left, refresh = true, tap_params = {} )
485
+
486
+ begin
487
+ use_tap_screen = tap_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
488
+ tap_params[:use_tap_screen].to_s
489
+ tap_params[:useTapScreen] = use_tap_screen
490
+
491
+ raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
492
+ command = command_params #in qt_behaviour
493
+ command.command_name('MouseRelease')
494
+ params = {'button' => @@_buttons_map[button], 'useTapScreen' => use_tap_screen}
495
+
496
+ if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
497
+ params['x'] = center_x
498
+ params['y'] = center_y
499
+ params['useCoordinates'] = 'true'
500
+ end
501
+ params.merge!(tap_params)
502
+
503
+ command.command_params(params)
504
+
505
+
506
+ @sut.execute_command(command)
507
+ self.force_refresh({:id => get_application_id}) if refresh
508
+
509
+ rescue Exception => e
510
+
511
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed tap_up with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_up;"
512
+ Kernel::raise e
513
+
514
+ end
515
+
516
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation tap_up executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_up;"
517
+
518
+ nil
519
+
520
+ end
521
+
522
+ # TODO: [2009-04-02] Remove deprevated methods?
523
+
524
+ # warning: TestObject#press is deprecated; use TestObject#tap
525
+ # == deprecated
526
+ # 0.8.x
527
+ # == description
528
+ # TestObject#press is deprecated, use TestObject#tap instead.
529
+ def press( tap_count = 1, button = :Left )
530
+
531
+ $stderr.puts "#{ caller(0).last.to_s } warning: TestObject#press is deprecated; use TestObject#tap"
532
+
533
+ begin
534
+ raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
535
+
536
+ command = command_params #in qt_behaviour
537
+
538
+ command.command_name('Tap')
539
+
540
+ command.command_params(
541
+ 'x' => center_x,
542
+ 'y' => center_y,
543
+ 'count' => tap_count.to_s,
544
+ 'button' => @@_buttons_map[button],
545
+ 'mouseMove'=>'true'
546
+ )
547
+
548
+ @sut.execute_command(command)
549
+
550
+ rescue Exception => e
551
+
552
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed press with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};press;"
553
+ Kernel::raise e
554
+
555
+ end
556
+
557
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation press executed successfully with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};press;"
558
+
559
+ nil
560
+
561
+ end
562
+
563
+ # TestObject#long_press is deprecated; use TestObject#long_tap
564
+ # == deprecated
565
+ # 0.8.x
566
+ # == description
567
+ # TestObject#long_press is deprecated, use TestObject#long_tap instead.
568
+ def long_press( time = 1, button = :Left )
569
+
570
+ $stderr.puts "#{ caller(0).last.to_s } warning: TestObject#long_press is deprecated; use TestObject#long_tap"
571
+
572
+ begin
573
+ long_tap(time, button)
574
+ rescue Exception => e
575
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed long_press with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_press;"
576
+ Kernel::raise e
577
+ end
578
+
579
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation long_press executed successfully with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_press;"
580
+
581
+ nil
582
+
583
+ end
584
+
585
+ # TestObject#hold is deprecated; use TestObject#tap_down
586
+ # == deprecated
587
+ # 0.8.x
588
+ # == description
589
+ # TestObject#hold is deprecated, use TestObject#tap_down instead.
590
+ def hold(button = :Left, refresh = true)
591
+
592
+ $stderr.puts "#{ caller(0).last.to_s } warning: TestObject#hold is deprecated; use TestObject#tap_down"
593
+
594
+ begin
595
+
596
+ tap_down(button, refresh)
597
+
598
+ rescue Exception => e
599
+
600
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed hold with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};hold;"
601
+ Kernel::raise e
602
+
603
+ end
604
+
605
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation hold executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};hold;"
606
+
607
+ nil
608
+
609
+ end
610
+
611
+ # TestObject#release is deprecated; use TestObject#tap_up
612
+ # == deprecated
613
+ # 0.8.x
614
+ # == description
615
+ # TestObject#release is deprecated, use TestObject#tap_up instead.
616
+ def release( button = :Left, refresh = true )
617
+
618
+ $stderr.puts "#{ caller(0).last.to_s } warning: TestObject#release is deprecated; use TestObject#tap_up"
619
+
620
+ begin
621
+
622
+ tap_up(button, refresh)
623
+
624
+ rescue Exception => e
625
+
626
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed release with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};release;"
627
+ Kernel::raise e
628
+
629
+ end
630
+
631
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation release executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};release;"
632
+
633
+ nil
634
+
635
+ end
636
+
637
+ =begin
638
+ private
639
+
640
+ def center_x
641
+ x = self.attribute('x_absolute').to_i
642
+ width = self.attribute('width').to_i
643
+ x = x + (width/2)
644
+ x.to_s
645
+ end
646
+
647
+ def center_y
648
+ y = self.attribute('y_absolute').to_i
649
+ height = self.attribute('height').to_i
650
+ y = y + (height/2)
651
+ y.to_s
652
+ end
653
+ =end
654
+
655
+ # enable hooking for performance measurement & debug logging
656
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
657
+
658
+ end # Widget
659
+
660
+
661
+ end # QT
662
+
663
+ end # MobyBehaviour