testability-driver-qt-sut-plugin 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/installer/extconf.rb +1 -1
  2. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +5 -5
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +174 -236
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +3 -3
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +5 -5
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +7 -7
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +7 -7
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +1 -1
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +3 -3
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +5 -5
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +73 -60
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +3 -3
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +6 -6
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +8 -8
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +1 -1
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +348 -329
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +5 -5
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +3 -3
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +7 -7
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +9 -9
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +79 -27
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +3 -3
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +5 -5
  24. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +3 -3
  25. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +5 -5
  26. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +13 -11
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +70 -67
  28. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +1 -1
  29. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +1 -1
  30. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +1 -1
  31. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +2 -3
  32. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +1 -1
  33. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +1 -1
  34. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +3 -3
  35. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +1 -1
  36. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +1 -1
  37. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +30 -14
  38. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +8 -3
  39. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +160 -29
  40. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +6 -8
  41. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +13 -2
  42. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +50 -35
  43. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +129 -95
  44. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +4 -4
  45. data/xml/behaviour/qt.xml +8 -12
  46. metadata +53 -72
@@ -568,10 +568,10 @@ module MobyBehaviour
568
568
  end
569
569
 
570
570
  rescue Exception => e
571
- MobyUtil::Logger.instance.log "behaviour","FAIL;Failed infologger \"#{params.to_s}\".;#{service};"
571
+ $logger.log "behaviour","FAIL;Failed infologger \"#{params.to_s}\".;#{service};"
572
572
  Kernel::raise e
573
573
  end
574
- MobyUtil::Logger.instance.log "behaviour","PASS;Operation infologger succeeded with params \"#{params.to_s}\".;#{service};"
574
+ $logger.log "behaviour","PASS;Operation infologger succeeded with params \"#{params.to_s}\".;#{service};"
575
575
  ret
576
576
  end
577
577
 
@@ -587,7 +587,7 @@ module MobyBehaviour
587
587
  end
588
588
 
589
589
  # enable hooking for performance measurement & debug logging
590
- MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
590
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
591
591
 
592
592
 
593
593
  end
@@ -89,12 +89,12 @@ module MobyBehaviour
89
89
 
90
90
  "Symbol #{ key.inspect } cannot be used due to no keymap defined for #{ @sut.id } in TDriver configuration file."
91
91
 
92
- ) if key.kind_of?( Symbol ) && !MobyUtil::Parameter[ @sut.id ].has_key?( :keymap )
92
+ ) if key.kind_of?( Symbol ) && !$parameters[ @sut.id ].has_key?( :keymap )
93
93
 
94
94
  @key_sequence = nil
95
95
  if key.kind_of?( Symbol )
96
96
 
97
- scancode = MobyUtil::Parameter[ @sut.id ][ :keymap ][ key, nil ]
97
+ scancode = $parameters[ @sut.id ][ :keymap ][ key, nil ]
98
98
  scancode = scancode.hex if scancode.kind_of?( String )
99
99
  # raise exception if value is other than fixnum
100
100
  Kernel::raise ArgumentError.new( "Scan code for :%s not defined in keymap" % key ) unless scancode.kind_of?( Fixnum )
@@ -107,7 +107,7 @@ module MobyBehaviour
107
107
  @key_sequence = []
108
108
  key.get_sequence.each do | key_event |
109
109
 
110
- tempcode = MobyUtil::Parameter[ @sut.id ][ :keymap ][ key_event[ :value ], nil ]
110
+ tempcode = $parameters[ @sut.id ][ :keymap ][ key_event[ :value ], nil ]
111
111
  tempcode = tempcode.hex if tempcode.kind_of?( String )
112
112
 
113
113
  press_type = { :KeyDown => 'KeyPress', :KeyUp => 'KeyRelease' }.fetch( key_event[ :type ] ){ "KeyClick" }
@@ -132,19 +132,19 @@ module MobyBehaviour
132
132
 
133
133
  rescue Exception => exception
134
134
 
135
- MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed press_key with key \"#{ key }\".;#{ identity };press_key;"
135
+ $logger.log "behaviour" , "FAIL;Failed press_key with key \"#{ key }\".;#{ identity };press_key;"
136
136
  Kernel::raise exception
137
137
 
138
138
  end
139
139
 
140
- MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation press_key executed successfully with key \"#{ key }\".;#{ identity };press_key;"
140
+ $logger.log "behaviour" , "PASS;Operation press_key executed successfully with key \"#{ key }\".;#{ identity };press_key;"
141
141
 
142
142
  nil
143
143
 
144
144
  end
145
145
 
146
146
  # enable hooking for performance measurement & debug logging
147
- MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
147
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
148
148
 
149
149
  end
150
150
 
@@ -86,17 +86,17 @@ module MobyBehaviour
86
86
  #
87
87
  def create_locale_db(path = "/", file = "*.qm", database_file = nil, column_names_map = {} )
88
88
 
89
- db_type = MobyUtil::Parameter[ :localisation_db_type ]
90
- host = MobyUtil::Parameter[ :localisation_server_ip ]
91
- database_file = MobyUtil::Parameter[ :localisation_server_database_name ] if database_file.nil?
92
- username = MobyUtil::Parameter[ :localisation_server_username ]
93
- password = MobyUtil::Parameter[ :localisation_server_password ]
89
+ db_type = $parameters[ :localisation_db_type ]
90
+ host = $parameters[ :localisation_server_ip ]
91
+ database_file = $parameters[ :localisation_server_database_name ] if database_file.nil?
92
+ username = $parameters[ :localisation_server_username ]
93
+ password = $parameters[ :localisation_server_password ]
94
94
 
95
95
  db_connection = MobyUtil::DBConnection.new( db_type, host, database_file, username, password )
96
- table_name = MobyUtil::Parameter[ :sut_qt ][ :localisation_server_database_tablename, "" ]
96
+ table_name = $parameters[ :sut_qt ][ :localisation_server_database_tablename, "" ]
97
97
 
98
98
  begin
99
- tmp_path = MobyUtil::Parameter[:tmp_folder] + "/locale_db_tmp"
99
+ tmp_path = $parameters[:tmp_folder] + "/locale_db_tmp"
100
100
  rescue MobyUtil::ParameterNotFoundError
101
101
  tmp_path = Dir.tmpdir + "/locale_db_tmp"
102
102
  end
@@ -147,7 +147,7 @@ module MobyBehaviour
147
147
  end
148
148
 
149
149
  # enable hooking for performance measurement & debug logging
150
- MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
150
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
151
151
 
152
152
  end # LocalisationDB
153
153
 
@@ -78,7 +78,7 @@ module MobyBehaviour
78
78
  end
79
79
 
80
80
  # enable hooking for performance measurement & debug logging
81
- MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
81
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
82
82
 
83
83
  end
84
84
  end
@@ -46,347 +46,363 @@ module MobyBehaviour
46
46
 
47
47
  include MobyBehaviour::QT::Behaviour
48
48
 
49
- # == description
50
- # Performs a pinch zoom in operation. The distance of the operation is
51
- # is for both fingers. So a distance of 100 will be performed by both
52
- # end points (fingers).
53
- #
54
- # == arguments
55
- # speed
56
- # Integer
57
- # description: Speed of the operation in seconds
58
- # example: 3
59
- #
60
- # distance
61
- # Integer
62
- # description: Distance of the pinch zoom
63
- # example: 100
64
- #
65
- # direction
66
- # Integer
67
- # description: Direction of the pinch zoom in degrees 0-180
68
- # example: 90
69
- # Symbol
70
- # description: Direction of the pinch zoom either :Horizontal or :Vertical
71
- # example: :Horizontal
72
- #
73
- # differential
74
- # Integer
75
- # description: The difference from where the zoom starts or ends (how far apart are the fingers when starting the zoom)
76
- # example: 10
77
- #
78
- # == returns
79
- # NilClass
80
- # description: -
81
- # example: -
82
- #
83
- # == exceptions
84
- # ArgumentError
85
- # description: In case the given parameters are not valid.
86
- #
87
- # == info
88
- # See method pinch_zoom
89
- #
90
- def pinch_zoom_in(speed, distance, direction, differential = 10)
91
- pinch_zoom({:type => :in, :speed => speed, :distance_1 => distance, :distance_2 => distance, :direction => direction, :differential => differential})
92
- end
49
+ # == description
50
+ # Performs a pinch zoom in operation. The distance of the operation is
51
+ # is for both fingers. So a distance of 100 will be performed by both
52
+ # end points (fingers).
53
+ #
54
+ # == arguments
55
+ # speed
56
+ # Integer
57
+ # description: Speed of the operation in seconds
58
+ # example: 3
59
+ #
60
+ # distance
61
+ # Integer
62
+ # description: Distance of the pinch zoom
63
+ # example: 100
64
+ #
65
+ # direction
66
+ # Integer
67
+ # description: Direction of the pinch zoom in degrees 0-180
68
+ # example: 90
69
+ # Symbol
70
+ # description: Direction of the pinch zoom either :Horizontal or :Vertical
71
+ # example: :Horizontal
72
+ #
73
+ # differential
74
+ # Integer
75
+ # description: The difference from where the zoom starts or ends (how far apart are the fingers when starting the zoom)
76
+ # example: 10
77
+ #
78
+ # == returns
79
+ # NilClass
80
+ # description: -
81
+ # example: -
82
+ #
83
+ # == exceptions
84
+ # ArgumentError
85
+ # description: In case the given parameters are not valid.
86
+ #
87
+ # == info
88
+ # See method pinch_zoom
89
+ #
90
+ def pinch_zoom_in(speed, distance, direction, differential = 10)
93
91
 
94
- # == description
95
- # Performs a pinch zoom out operation. The distance of the operation is
96
- # is for both fingers. So a distance of 100 will be performed by both
97
- # fingers.
98
- #
99
- # == arguments
100
- # speed
101
- # Integer
102
- # description: Speed of the operation in seconds
103
- # example: 3
104
- #
105
- # distance
106
- # Integer
107
- # description: Distance of the pinch zoom
108
- # example: 100
109
- #
110
- # direction
111
- # Integer
112
- # description: Direction of the pinch zoom in degrees 0-180
113
- # example: 90
114
- # Symbol
115
- # description: Direction of the pinch zoom either :Horizontal or :Vertical
116
- # example: :Horizontal
117
- #
118
- # differential
119
- # Integer
120
- # description: The difference from where the zoom starts or ends (how far apart are the fingers when starting the zoom)
121
- # example: 10
122
- #
123
- # == returns
124
- # NilClass
125
- # description: -
126
- # example: -
127
- #
128
- # == exceptions
129
- # ArgumentError
130
- # description: In case the given parameters are not valid.
131
- #
132
- # == info
133
- # See method pinch_zoom
134
- #
135
- def pinch_zoom_out(speed, distance, direction, differential = 10)
136
- pinch_zoom({:type => :out, :speed => speed, :distance_1 => distance, :distance_2 => distance, :direction => direction, :differential => differential})
137
- end
92
+ pinch_zoom({:type => :in, :speed => speed, :distance_1 => distance, :distance_2 => distance, :direction => direction, :differential => differential})
138
93
 
139
- # == description
140
- # Causes a pinch zoom gesture on the object. The type of the pinch is based on the given parameters.
141
- # The parameters make it possible to define various kinds of pinch zoom operations.
142
- #
143
- # The image shows how the different parameters will be used to make the pinch gesture.
144
- # The image show a zoom in type gesture (:type => :in). Direction is the angle of the
145
- # first part of the pinch gesture against the y axel (0 degrees is up). Distance variables
146
- # do not have to be the same. This means that you can set the gesture so that one finger
147
- # moves a longer distance than the other (or even set one distance to 0).
148
- # The :differential parameter determines the how close the nearest points
149
- # in the pinch gesture are (:in start points and :out end points).
150
- # The center points can be set using the :x and :y setting.
151
- # The values are relative to the object and if not set then the center point of the object is used.
152
- # \n
153
- # [img="images/pinch.png"]Pinch zoom parameters[/img]
154
- #
155
- # == arguments
156
- # params
157
- # Hash
158
- # description:
159
- # A Hash table contains all of the parameters required to make the pinch zoom.
160
- # See [link="#pinch_options_table"]Pinch options table[/link] for valid keys.
161
- # example: pinch_zoom({:type => :in, :speed => 2, :distance_1 => 100, :distance_2 => 100, :direction => :Vertical, :differential => 10})
162
- #
163
- # == tables
164
- # pinch_options_table
165
- # title: Pinch options table
166
- # |Key|Type|Description|Accepted values|Example|Required|
167
- # |:type|Symbol|Zoom in or out|:in,:out|:type => :in|Yes|
168
- # |:speed|Integer|Speed of the gesture in seconds|Positive Integer|:speed => 2|Yes|
169
- # |:distance_1|Integer|Distance of the first finger zoom gesture|Positive integer|:distance_1 => 100|Yes|
170
- # |:distance_2|Integer|Distance of the second finger zoom gesture|Positive integer|:distance_2 => 100|Yes|
171
- # |:differential|Integer|The difference from where the zoom starts or ends|Positive integer|:differential => 10|Yes|
172
- # |:x|Integer|X coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set y must also be set.|Positive Integer| :x => 120|No|
173
- # |:y|Integer|Y coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set x must also be set.|Positive Integer|:y => 200|No|
174
- #
175
- # == returns
176
- # NilClass
177
- # description: -
178
- # example: -
179
- #
180
- # == exceptions
181
- # ArgumentError
182
- # description: In case the given parameters are not valid.
183
- #
184
- def pinch_zoom(params)
94
+ self
185
95
 
186
- begin
187
- verify_pinch_params!(params)
96
+ end
188
97
 
189
- #convert speed to millis
190
- time = params[:speed].to_f
191
- speed = time*1000
192
- params[:speed] = speed.to_i
193
- if params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
194
- params[:useCoordinates] = 'true'
195
- params[:x] = attribute('x_absolute').to_i + params[:x]
196
- params[:y] = attribute('y_absolute').to_i + params[:y]
197
- end
198
- command = command_params #in qt_behaviour
199
- command.command_name('PinchZoom')
200
- command.command_params(params)
98
+ # == description
99
+ # Performs a pinch zoom out operation. The distance of the operation is
100
+ # is for both fingers. So a distance of 100 will be performed by both
101
+ # fingers.
102
+ #
103
+ # == arguments
104
+ # speed
105
+ # Integer
106
+ # description: Speed of the operation in seconds
107
+ # example: 3
108
+ #
109
+ # distance
110
+ # Integer
111
+ # description: Distance of the pinch zoom
112
+ # example: 100
113
+ #
114
+ # direction
115
+ # Integer
116
+ # description: Direction of the pinch zoom in degrees 0-180
117
+ # example: 90
118
+ # Symbol
119
+ # description: Direction of the pinch zoom either :Horizontal or :Vertical
120
+ # example: :Horizontal
121
+ #
122
+ # differential
123
+ # Integer
124
+ # description: The difference from where the zoom starts or ends (how far apart are the fingers when starting the zoom)
125
+ # example: 10
126
+ #
127
+ # == returns
128
+ # NilClass
129
+ # description: -
130
+ # example: -
131
+ #
132
+ # == exceptions
133
+ # ArgumentError
134
+ # description: In case the given parameters are not valid.
135
+ #
136
+ # == info
137
+ # See method pinch_zoom
138
+ #
139
+ def pinch_zoom_out(speed, distance, direction, differential = 10)
201
140
 
202
- @sut.execute_command( command )
141
+ pinch_zoom({:type => :out, :speed => speed, :distance_1 => distance, :distance_2 => distance, :direction => direction, :differential => differential})
203
142
 
204
- #wait untill the pinch is finished
205
- do_sleep(time)
143
+ self
206
144
 
207
- rescue Exception => e
208
- MobyUtil::Logger.instance.log "behaviour","FAIL;Failed pinch_zoom with params \"#{params.to_s}\".;#{identity};pinch_zoom;"
209
- Kernel::raise e
210
- end
211
- MobyUtil::Logger.instance.log "behaviour","PASS;Operation pinch_zoom succeeded with params \"#{params.to_s}\".;#{identity};pinch_zoom;"
212
- nil
213
- end
145
+ end
214
146
 
215
- # == description
216
- # Causes rotation motion on the object. The rotation will be so that one point is stationary
217
- # while other moves to create a rotation motion (like a hinge).
218
- #
219
- # == arguments
220
- # radius
221
- # Integer
222
- # description: Radius of the of the rotation in degrees (distance between the points)
223
- # example: 100
224
- #
225
- # start_angle
226
- # Integer
227
- # description: Starting angle of the rotation. Integer from 0-360
228
- # example: 90
229
- # Symbol
230
- # description: Starting angle of the rotation. Symbol :Horizontal or :Vertical
231
- # example: :Horizontal
232
- #
233
- # rotate_direction
234
- # Symbol
235
- # description: Rotation direction :Clockwise or :CounterClockwise.
236
- # example: :CounterClockwise
237
- #
238
- # distance
239
- # Integer
240
- # description: Distance of the rotation in degrees
241
- # example: 360
242
- #
243
- # speed
244
- # Integer
245
- # description: Speed in seconds
246
- # example: 3
247
- #
248
- # center_point
249
- # Hash
250
- # description: Optional X and Y coordinates (relative to the object e.g. top left of the object is 0.0).
251
- # In one point rotation the other end point will remain stationary (the rotation is done around that point)
252
- # and that will be the given point. If not given the point will be the center of the object.
253
- # example: {:x => 50, :y => 100}
254
- #
255
- # == returns
256
- # NilClass
257
- # description: -
258
- # example: -
259
- #
260
- #
261
- # == exceptions
262
- # ArgumentError
263
- # description: In case the given parameters are not valid.
264
- #
265
- # == info
266
- # See method rotate
267
- #
268
- def one_point_rotate(radius, start_angle, rotate_direction, distance, speed, center_point = nil)
269
- params = {:type => :one_point, :radius => radius, :rotate_direction => rotate_direction, :distance => distance, :speed => speed, :direction => start_angle}
270
- params.merge!(center_point) if center_point
271
- rotate(params)
272
- end
147
+ # == description
148
+ # Causes a pinch zoom gesture on the object. The type of the pinch is based on the given parameters.
149
+ # The parameters make it possible to define various kinds of pinch zoom operations.
150
+ #
151
+ # The image shows how the different parameters will be used to make the pinch gesture.
152
+ # The image show a zoom in type gesture (:type => :in). Direction is the angle of the
153
+ # first part of the pinch gesture against the y axel (0 degrees is up). Distance variables
154
+ # do not have to be the same. This means that you can set the gesture so that one finger
155
+ # moves a longer distance than the other (or even set one distance to 0).
156
+ # The :differential parameter determines the how close the nearest points
157
+ # in the pinch gesture are (:in start points and :out end points).
158
+ # The center points can be set using the :x and :y setting.
159
+ # The values are relative to the object and if not set then the center point of the object is used.
160
+ # \n
161
+ # [img="images/pinch.png"]Pinch zoom parameters[/img]
162
+ #
163
+ # == arguments
164
+ # params
165
+ # Hash
166
+ # description:
167
+ # A Hash table contains all of the parameters required to make the pinch zoom.
168
+ # See [link="#pinch_options_table"]Pinch options table[/link] for valid keys.
169
+ # example: pinch_zoom({:type => :in, :speed => 2, :distance_1 => 100, :distance_2 => 100, :direction => :Vertical, :differential => 10})
170
+ #
171
+ # == tables
172
+ # pinch_options_table
173
+ # title: Pinch options table
174
+ # |Key|Type|Description|Accepted values|Example|Required|
175
+ # |:type|Symbol|Zoom in or out|:in,:out|:type => :in|Yes|
176
+ # |:speed|Integer|Speed of the gesture in seconds|Positive Integer|:speed => 2|Yes|
177
+ # |:distance_1|Integer|Distance of the first finger zoom gesture|Positive integer|:distance_1 => 100|Yes|
178
+ # |:distance_2|Integer|Distance of the second finger zoom gesture|Positive integer|:distance_2 => 100|Yes|
179
+ # |:differential|Integer|The difference from where the zoom starts or ends|Positive integer|:differential => 10|Yes|
180
+ # |:x|Integer|X coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set y must also be set.|Positive Integer| :x => 120|No|
181
+ # |:y|Integer|Y coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set x must also be set.|Positive Integer|:y => 200|No|
182
+ #
183
+ # == returns
184
+ # NilClass
185
+ # description: -
186
+ # example: -
187
+ #
188
+ # == exceptions
189
+ # ArgumentError
190
+ # description: In case the given parameters are not valid.
191
+ #
192
+ def pinch_zoom( params )
193
+
194
+ begin
195
+ verify_pinch_params!(params)
196
+
197
+ #convert speed to millis
198
+ time = params[:speed].to_f
199
+ speed = time*1000
200
+ params[:speed] = speed.to_i
201
+ if params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
202
+ params[:useCoordinates] = 'true'
203
+ params[:x] = attribute('x_absolute').to_i + params[:x]
204
+ params[:y] = attribute('y_absolute').to_i + params[:y]
205
+ end
206
+ command = command_params #in qt_behaviour
207
+ command.command_name('PinchZoom')
208
+ command.command_params(params)
209
+
210
+ @sut.execute_command( command )
211
+
212
+ #wait untill the pinch is finished
213
+ do_sleep(time)
214
+
215
+ rescue Exception => e
216
+ $logger.log "behaviour","FAIL;Failed pinch_zoom with params \"#{params.to_s}\".;#{identity};pinch_zoom;"
217
+ Kernel::raise e
218
+ end
219
+
220
+ $logger.log "behaviour","PASS;Operation pinch_zoom succeeded with params \"#{params.to_s}\".;#{identity};pinch_zoom;"
221
+
222
+ self
223
+
224
+ end
225
+
226
+ # == description
227
+ # Causes rotation motion on the object. The rotation will be so that one point is stationary
228
+ # while other moves to create a rotation motion (like a hinge).
229
+ #
230
+ # == arguments
231
+ # radius
232
+ # Integer
233
+ # description: Radius of the of the rotation in degrees (distance between the points)
234
+ # example: 100
235
+ #
236
+ # start_angle
237
+ # Integer
238
+ # description: Starting angle of the rotation. Integer from 0-360
239
+ # example: 90
240
+ # Symbol
241
+ # description: Starting angle of the rotation. Symbol :Horizontal or :Vertical
242
+ # example: :Horizontal
243
+ #
244
+ # rotate_direction
245
+ # Symbol
246
+ # description: Rotation direction :Clockwise or :CounterClockwise.
247
+ # example: :CounterClockwise
248
+ #
249
+ # distance
250
+ # Integer
251
+ # description: Distance of the rotation in degrees
252
+ # example: 360
253
+ #
254
+ # speed
255
+ # Integer
256
+ # description: Speed in seconds
257
+ # example: 3
258
+ #
259
+ # center_point
260
+ # Hash
261
+ # description: Optional X and Y coordinates (relative to the object e.g. top left of the object is 0.0).
262
+ # In one point rotation the other end point will remain stationary (the rotation is done around that point)
263
+ # and that will be the given point. If not given the point will be the center of the object.
264
+ # example: {:x => 50, :y => 100}
265
+ #
266
+ # == returns
267
+ # NilClass
268
+ # description: -
269
+ # example: -
270
+ #
271
+ #
272
+ # == exceptions
273
+ # ArgumentError
274
+ # description: In case the given parameters are not valid.
275
+ #
276
+ # == info
277
+ # See method rotate
278
+ #
279
+ def one_point_rotate(radius, start_angle, rotate_direction, distance, speed, center_point = nil)
280
+ params = {:type => :one_point, :radius => radius, :rotate_direction => rotate_direction, :distance => distance, :speed => speed, :direction => start_angle}
281
+ params.merge!(center_point) if center_point
282
+ rotate(params)
283
+ self
284
+ end
273
285
 
274
- # == description
275
- # Causes ratation motion on the object. The rotation will be so that both ends move to create a rotation motion around a point.
276
- #
277
- # == arguments
278
- # radius
279
- # Integer
280
- # description: Radius of the of the rotation in degrees (distance between the points)
281
- # example: 100
282
- #
283
- # start_angle
284
- # Integer
285
- # description: Starting angle of the rotation. Integer from 0-360
286
- # example: 90
287
- # Symbol
288
- # description: Starting angle of the rotation. Symbol :Horizontal or :Vertical
289
- # example: :Horizontal
290
- #
291
- # rotate_direction
292
- # Symbol
293
- # description: Rotation direction :Clockwise or :CounterClockwise.
294
- # example: :CounterClockwise
295
- #
296
- # distance
297
- # Integer
298
- # description: Distance of the rotation in degrees
299
- # example: 360
300
- #
301
- # speed
302
- # Integer
303
- # description: Speed in seconds
304
- # example: 3
305
- #
306
- # center_point
307
- # Hash
308
- # description: Optional X and Y coordinates (relative to the object e.g. top left of the object is 0.0).
309
- # In two point rotation both end points will rotate around a center point which will be
310
- # the given point. If not given the point will be the center of the object.
311
- # example: {:x => 50, :y => 100}
312
- #
313
- # == returns
314
- # NilClass
315
- # description: -
316
- # example: -
317
- #
318
- # == exceptions
319
- #
320
- # ArgumentError
321
- # description: In case the given parameters are not valid.
322
- #
323
- # == info
324
- # See method rotate
325
- #
326
- def two_point_rotate(radius, start_angle, rotate_direction, distance, speed, center_point = nil)
327
- params = {:type => :two_point, :radius => radius, :rotate_direction => rotate_direction, :distance => distance, :speed => speed, :direction => start_angle}
328
- params.merge!(center_point) if center_point
329
- rotate(params)
330
- end
286
+ # == description
287
+ # Causes ratation motion on the object. The rotation will be so that both ends move to create a rotation motion around a point.
288
+ #
289
+ # == arguments
290
+ # radius
291
+ # Integer
292
+ # description: Radius of the of the rotation in degrees (distance between the points)
293
+ # example: 100
294
+ #
295
+ # start_angle
296
+ # Integer
297
+ # description: Starting angle of the rotation. Integer from 0-360
298
+ # example: 90
299
+ # Symbol
300
+ # description: Starting angle of the rotation. Symbol :Horizontal or :Vertical
301
+ # example: :Horizontal
302
+ #
303
+ # rotate_direction
304
+ # Symbol
305
+ # description: Rotation direction :Clockwise or :CounterClockwise.
306
+ # example: :CounterClockwise
307
+ #
308
+ # distance
309
+ # Integer
310
+ # description: Distance of the rotation in degrees
311
+ # example: 360
312
+ #
313
+ # speed
314
+ # Integer
315
+ # description: Speed in seconds
316
+ # example: 3
317
+ #
318
+ # center_point
319
+ # Hash
320
+ # description: Optional X and Y coordinates (relative to the object e.g. top left of the object is 0.0).
321
+ # In two point rotation both end points will rotate around a center point which will be
322
+ # the given point. If not given the point will be the center of the object.
323
+ # example: {:x => 50, :y => 100}
324
+ #
325
+ # == returns
326
+ # NilClass
327
+ # description: -
328
+ # example: -
329
+ #
330
+ # == exceptions
331
+ #
332
+ # ArgumentError
333
+ # description: In case the given parameters are not valid.
334
+ #
335
+ # == info
336
+ # See method rotate
337
+ #
338
+ def two_point_rotate(radius, start_angle, rotate_direction, distance, speed, center_point = nil)
339
+ params = {:type => :two_point, :radius => radius, :rotate_direction => rotate_direction, :distance => distance, :speed => speed, :direction => start_angle}
340
+ params.merge!(center_point) if center_point
341
+ rotate(params)
342
+ self
343
+ end
331
344
 
332
- # == description
333
- # Causes a rotate motion on the screen using two fingers (e.g. like turning a knob). Similar gesture to pinch zooming except the angle changes.
334
- # \n
335
- # \n
336
- # [img="images/rotate.png"]Rotation parameters[/img]
337
- # \n
338
- # The image shows how the different parameters will be used to make the rotation gestures in both
339
- # one point and two point rotations. In one point rotation the other end remains stationary while
340
- # the other moves around it based on the given radius. In two point rotation the movement is done
341
- # by both ends. Note the direction paramters as the :direction parameter defines the starting angle
342
- # for the gesture and :rotation_direction defines the actual rotation direction (clockwise or counter clockwise).
343
- # When performing two point rotation note that the radius is in fact a radius not the diameter.
344
- # Distance is given in degrees from 0-360. Center point can be set using :x and :y and if
345
- # not set the center point of the object will be used.
346
- #
347
- # == arguments
348
- # params
349
- # Hash
350
- # description: A hash of the parameters that define the rotation. See [link="#rotate_options_table"]Rotate options table[/link] for valid keys
351
- #
352
- # example: {:type => :one_point, :radius => 100, :rotate_direction => :Clockwise, :distance => 45, :speed => 2, :direction => 35, :x => 2, y => 35}
353
- #
354
- # == tables
355
- # rotate_options_table
356
- # title: Rotate options table
357
- # |Key|Type|Description|Accepted values|Example|Required|
358
- # |:type|Symbol|Rotation type|:one_point,:two_point|:type => :one_point|Yes|
359
- # |:radius|Integer|Radius of the rotatation in pixels|Any positive Integer|:radius => 100|Yes|
360
- # |:rotation_direction|Symbol|Rotation direction|:Clockwise, :CounterClockwise|:rotate_direction => :Clockwise|Yes|
361
- # |:distance|Integer|Rotation distance in degrees|0-360|:distance => 90|Yes|
362
- # |:speed|Integer|Speed of the gesture in seconds|Positive Integer|:speed => 2|Yes|
363
- # |:direction|Integer/Symbol|The start angle of the rotation.|0-360 or :Horizontal, :Vertical|:direction => 35|Yes|
364
- # |:x|Integer|X coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set y must also be set.|Positive Integer|:x => 50|No|
365
- # |:y|Integer|Y coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set x must also be set.|Positive Integer|:y => 120|No|
366
- #
367
- #
368
- # == returns
369
- # NilClass
370
- # description: -
371
- # example: -
372
- #
373
- # == exceptions
374
- #
375
- # ArgumentError
376
- # description: In case the given parameters are not valid.
377
- #
345
+ # == description
346
+ # Causes a rotate motion on the screen using two fingers (e.g. like turning a knob). Similar gesture to pinch zooming except the angle changes.
347
+ # \n
348
+ # \n
349
+ # [img="images/rotate.png"]Rotation parameters[/img]
350
+ # \n
351
+ # The image shows how the different parameters will be used to make the rotation gestures in both
352
+ # one point and two point rotations. In one point rotation the other end remains stationary while
353
+ # the other moves around it based on the given radius. In two point rotation the movement is done
354
+ # by both ends. Note the direction paramters as the :direction parameter defines the starting angle
355
+ # for the gesture and :rotation_direction defines the actual rotation direction (clockwise or counter clockwise).
356
+ # When performing two point rotation note that the radius is in fact a radius not the diameter.
357
+ # Distance is given in degrees from 0-360. Center point can be set using :x and :y and if
358
+ # not set the center point of the object will be used.
359
+ #
360
+ # == arguments
361
+ # params
362
+ # Hash
363
+ # description: A hash of the parameters that define the rotation. See [link="#rotate_options_table"]Rotate options table[/link] for valid keys
364
+ #
365
+ # example: {:type => :one_point, :radius => 100, :rotate_direction => :Clockwise, :distance => 45, :speed => 2, :direction => 35, :x => 2, y => 35}
366
+ #
367
+ # == tables
368
+ # rotate_options_table
369
+ # title: Rotate options table
370
+ # |Key|Type|Description|Accepted values|Example|Required|
371
+ # |:type|Symbol|Rotation type|:one_point,:two_point|:type => :one_point|Yes|
372
+ # |:radius|Integer|Radius of the rotatation in pixels|Any positive Integer|:radius => 100|Yes|
373
+ # |:rotation_direction|Symbol|Rotation direction|:Clockwise, :CounterClockwise|:rotate_direction => :Clockwise|Yes|
374
+ # |:distance|Integer|Rotation distance in degrees|0-360|:distance => 90|Yes|
375
+ # |:speed|Integer|Speed of the gesture in seconds|Positive Integer|:speed => 2|Yes|
376
+ # |:direction|Integer/Symbol|The start angle of the rotation.|0-360 or :Horizontal, :Vertical|:direction => 35|Yes|
377
+ # |:x|Integer|X coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set y must also be set.|Positive Integer|:x => 50|No|
378
+ # |:y|Integer|Y coordinate of the center point for the pinch (relative to the object). Optional defaults to center point but if set x must also be set.|Positive Integer|:y => 120|No|
379
+ #
380
+ #
381
+ # == returns
382
+ # NilClass
383
+ # description: -
384
+ # example: -
385
+ #
386
+ # == exceptions
387
+ #
388
+ # ArgumentError
389
+ # description: In case the given parameters are not valid.
390
+ #
378
391
  def rotate(params)
392
+
379
393
  begin
394
+
380
395
  verify_rotate_params!(params)
381
396
 
382
397
  time = params[:speed].to_f
383
- speed = time*1000
384
- params[:speed] = speed.to_i
398
+
399
+ params[:speed] = (time * 1000).to_i
400
+
385
401
 
386
402
  if params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
387
- params[:useCoordinates] = 'true'
388
- params[:x] = attribute('x_absolute').to_i + params[:x]
389
- params[:y] = attribute('y_absolute').to_i + params[:y]
403
+ params[:useCoordinates] = 'true'
404
+ params[:x] = attribute('x_absolute').to_i + params[:x]
405
+ params[:y] = attribute('y_absolute').to_i + params[:y]
390
406
  end
391
407
 
392
408
  command = command_params #in qt_behaviour
@@ -396,13 +412,16 @@ module MobyBehaviour
396
412
  @sut.execute_command( command )
397
413
 
398
414
  #wait untill the operation to finish
399
- do_sleep(time)
415
+ do_sleep( time )
400
416
  rescue Exception => e
401
- MobyUtil::Logger.instance.log "behaviour","FAIL;Failed rotate with params \"#{params.to_s}\".;#{identity};rotate;"
417
+ $logger.log "behaviour","FAIL;Failed rotate with params \"#{params.to_s}\".;#{identity};rotate;"
402
418
  Kernel::raise e
403
419
  end
404
- MobyUtil::Logger.instance.log "behaviour","PASS;Operation rotate succeeded with params \"#{params.to_s}\".;#{identity};rotate;"
405
- nil
420
+
421
+ $logger.log "behaviour","PASS;Operation rotate succeeded with params \"#{params.to_s}\".;#{identity};rotate;"
422
+
423
+ self
424
+
406
425
  end
407
426
 
408
427
  private
@@ -446,7 +465,7 @@ module MobyBehaviour
446
465
  end
447
466
 
448
467
  # enable hooking for performance measurement & debug logging
449
- MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
468
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
450
469
 
451
470
  end # Multitouch
452
471