testability-driver-qt-sut-plugin 1.1.1 → 1.2.0

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 (40) hide show
  1. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +7 -6
  2. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +190 -182
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +2 -2
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +17 -17
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +6 -6
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +6 -6
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +2 -2
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +10 -14
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fps.rb +7 -7
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +387 -338
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +177 -5
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +5 -5
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +2 -1
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +34 -7
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +4 -4
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +4 -4
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +6 -6
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +8 -12
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/settings.rb +8 -8
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +171 -115
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +2 -2
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +11 -7
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +2 -2
  24. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +5 -5
  25. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +13 -13
  26. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +54 -63
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +45 -28
  28. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/version.rb +34 -0
  29. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +2 -2
  30. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +174 -121
  31. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +35 -26
  32. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/version.rb +56 -0
  33. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +64 -16
  34. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +138 -40
  35. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +91 -83
  36. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +222 -44
  37. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +176 -10
  38. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +2 -2
  39. data/xml/behaviour/qt.xml +12 -0
  40. metadata +7 -5
@@ -240,11 +240,11 @@ module MobyBehaviour
240
240
  begin
241
241
  returnValue = @sut.execute_command( command )
242
242
  rescue
243
- $logger.log "behaviour" , "FAIL;Failed when calling method set_attribute with values attribute:#{attribute.to_s} value:#{value.to_s}.;#{identity};set_attribute;"
243
+ $logger.behaviour "FAIL;Failed when calling method set_attribute with values attribute:#{attribute.to_s} value:#{value.to_s}.;#{identity};set_attribute;"
244
244
  Kernel::raise RuntimeError.new("Setting attribute '%s' to value '%s' failed with error: %s" % [attribute, value, returnValue])
245
245
  end
246
246
 
247
- $logger.log "behaviour" , "PASS;The method set_attribute was executed successfully with with values attribute:#{attribute.to_s} value:#{value.to_s}.;#{identity};set_attribute;"
247
+ $logger.behaviour "PASS;The method set_attribute was executed successfully with with values attribute:#{attribute.to_s} value:#{value.to_s}.;#{identity};set_attribute;"
248
248
 
249
249
  nil
250
250
 
@@ -57,7 +57,7 @@ module MobyBehaviour
57
57
  # should this method be private?
58
58
  def command_params( command = MobyCommand::WidgetCommand.new )
59
59
 
60
- if self.attribute( 'objectType' ) == 'Graphics' and self.attribute( 'visibleOnScreen' ) == 'false' and self.creation_attributes[:visibleOnScreen] != 'false'
60
+ if attribute( 'objectType' ) == 'Graphics' and attribute( 'visibleOnScreen' ) == 'false' and self.creation_attributes[:visibleOnScreen] != 'false'
61
61
  begin
62
62
  self.creation_attributes.merge!({'visibleOnScreen' => 'true'})
63
63
  self.parent.child(self.creation_attributes)
@@ -66,36 +66,36 @@ module MobyBehaviour
66
66
  end
67
67
  end
68
68
 
69
- command.set_event_type($parameters[ @sut.id ][ :event_type, "0" ])
69
+ command.set_event_type(sut_parameters[ :event_type, "0" ])
70
70
 
71
71
  #for components with object visible on screen but not actual widgets or graphicsitems
72
- if self.attribute( 'objectType' ) == 'Embedded'
72
+ if attribute( 'objectType' ) == 'Embedded'
73
73
  command.application_id( get_application_id )
74
- command.object_id( parent.id )
74
+ command.set_object_id( parent.id )
75
75
  command.object_type( parent.attribute( 'objectType' ).intern )
76
76
  else
77
77
  command.application_id( get_application_id )
78
- command.object_id( self.id )
79
- command.object_type( self.attribute( 'objectType' ).intern )
78
+ command.set_object_id( @id )
79
+ command.object_type( attribute( 'objectType' ).intern )
80
80
  end
81
81
 
82
82
  command
83
83
 
84
84
  end
85
85
 
86
+ private
87
+
86
88
  # == nodoc
87
89
  # should this method be private?
88
90
  def plugin_command( require_response = false, command = MobyCommand::WidgetCommand.new )
89
- command.set_event_type($parameters[ @sut.id ][ :event_type, "0" ])
91
+ command.set_event_type(sut_parameters[ :event_type, "0" ])
90
92
  command.application_id( get_application_id )
91
- command.object_id( self.id )
92
- command.object_type( self.attribute('objectType' ).intern)
93
+ command.set_object_id( @id )
94
+ command.object_type( attribute('objectType' ).intern)
93
95
  command.transitions_off
94
96
  command
95
97
  end
96
98
 
97
- private
98
-
99
99
  def do_sleep(time)
100
100
 
101
101
  time = time.to_f * 1.3
@@ -109,23 +109,23 @@ module MobyBehaviour
109
109
 
110
110
  def center_x
111
111
 
112
- #x = self.attribute( 'x_absolute' ).to_i
113
- #width = self.attribute( 'width' ).to_i
112
+ #x = attribute( 'x_absolute' ).to_i
113
+ #width = attribute( 'width' ).to_i
114
114
  #x = x + ( width/2 )
115
115
  #x.to_s
116
116
 
117
- ( ( self.attribute( 'x_absolute' ).to_i ) + ( self.attribute( 'width' ).to_i / 2 ) ).to_s
117
+ ( ( attribute( 'x_absolute' ).to_i ) + ( attribute( 'width' ).to_i / 2 ) ).to_s
118
118
 
119
119
  end
120
120
 
121
121
  def center_y
122
122
 
123
- #y = self.attribute( 'y_absolute' ).to_i
124
- #height = self.attribute( 'height' ).to_i
123
+ #y = attribute( 'y_absolute' ).to_i
124
+ #height = attribute( 'height' ).to_i
125
125
  #y = y + ( height/2 )
126
126
  #y.to_s
127
127
 
128
- ( ( self.attribute( 'y_absolute' ).to_i ) + ( self.attribute( 'height' ).to_i / 2 ) ).to_s
128
+ ( ( attribute( 'y_absolute' ).to_i ) + ( attribute( 'height' ).to_i / 2 ) ).to_s
129
129
 
130
130
  end
131
131
 
@@ -227,12 +227,12 @@ module MobyBehaviour
227
227
 
228
228
  rescue Exception => e
229
229
 
230
- $logger.log "behaviour" , "FAIL;Failed to enable event logging. With event_list \"#{event_list};log_events"
230
+ $logger.behaviour "FAIL;Failed to enable event logging. With event_list \"#{event_list};log_events"
231
231
  Kernel::raise e
232
232
 
233
233
  end
234
234
 
235
- $logger.log "behaviour" , "PASS;Event logging enabled. With event_list \"#{event_list};log_events"
235
+ $logger.behaviour "PASS;Event logging enabled. With event_list \"#{event_list};log_events"
236
236
 
237
237
  end
238
238
 
@@ -252,12 +252,12 @@ module MobyBehaviour
252
252
 
253
253
  rescue Exception => e
254
254
 
255
- $logger.log "behaviour" , "FAIL;Failed to stop event logging.;stop_event_logging"
255
+ $logger.behaviour "FAIL;Failed to stop event logging.;stop_event_logging"
256
256
  Kernel::raise e
257
257
 
258
258
  end
259
259
 
260
- $logger.log "behaviour" , "PASS;Event logging stopped.;stop_event_logging"
260
+ $logger.behaviour "PASS;Event logging stopped.;stop_event_logging"
261
261
 
262
262
  end
263
263
 
@@ -287,12 +287,12 @@ module MobyBehaviour
287
287
 
288
288
  rescue Exception => e
289
289
 
290
- $logger.log "behaviour" , "FAIL;Failed to configure logger. With params \"#{params_hash.to_s};configure_logger"
290
+ $logger.behaviour "FAIL;Failed to configure logger. With params \"#{params_hash.to_s};configure_logger"
291
291
  Kernel::raise e
292
292
 
293
293
  end
294
294
 
295
- $logger.log "behaviour" , "PASS;Succesfully configured logger. With params \"#{params_hash.to_s};configure_logger"
295
+ $logger.behaviour "PASS;Succesfully configured logger. With params \"#{params_hash.to_s};configure_logger"
296
296
 
297
297
  end
298
298
 
@@ -82,12 +82,12 @@ module MobyBehaviour
82
82
 
83
83
  rescue Exception => e
84
84
 
85
- $logger.log "behaviour" , "FAIL;Failed enable_events with refresh \"#{filter_array.to_s}\".;#{ identity };enable_events;"
85
+ $logger.behaviour "FAIL;Failed enable_events with refresh \"#{filter_array.to_s}\".;#{ identity };enable_events;"
86
86
  Kernel::raise e
87
87
 
88
88
  end
89
89
 
90
- $logger.log "behaviour" , "PASS;Operation enable_events executed successfully with refresh \"#{ filter_array.to_s }\".;#{ identity };enable_events;"
90
+ $logger.behaviour "PASS;Operation enable_events executed successfully with refresh \"#{ filter_array.to_s }\".;#{ identity };enable_events;"
91
91
  nil
92
92
  end
93
93
 
@@ -111,11 +111,11 @@ module MobyBehaviour
111
111
  command.service( 'collectEvents' )
112
112
  @sut.execute_command( command)
113
113
  rescue Exception => e
114
- $logger.log "behaviour" , "FAIL;Failed disable_events.;#{ identity };disable_events;"
114
+ $logger.behaviour "FAIL;Failed disable_events.;#{ identity };disable_events;"
115
115
  Kernel::raise e
116
116
  end
117
117
 
118
- $logger.log "behaviour" , "PASS;Operation disable_events executed successfully.;#{ identity };disable_events;"
118
+ $logger.behaviour "PASS;Operation disable_events executed successfully.;#{ identity };disable_events;"
119
119
  nil
120
120
 
121
121
  end
@@ -146,12 +146,12 @@ module MobyBehaviour
146
146
 
147
147
  rescue Exception => e
148
148
 
149
- $logger.log "behaviour" , "FAIL;Failed get_events.;#{ identity };get_events;"
149
+ $logger.behaviour "FAIL;Failed get_events.;#{ identity };get_events;"
150
150
  Kernel::raise e
151
151
 
152
152
  end
153
153
 
154
- $logger.log "behaviour" , "PASS;Operation get_events executed successfully.;#{ identity };get_events;"
154
+ $logger.behaviour "PASS;Operation get_events executed successfully.;#{ identity };get_events;"
155
155
 
156
156
  ret
157
157
 
@@ -64,11 +64,11 @@ module MobyBehaviour
64
64
  ## flick_to (center)
65
65
  search_result.flick_to(window_x.to_i, window_y.to_i)
66
66
  rescue Exception => e
67
- ##$logger.log "behaviour" , "FAIL;Failed to find test object.;#{id.to_s};sut;{};find;" << (find_hash.kind_of?(Hash) ? find_hash.inspect : find_hash.class.to_s)
67
+ ##$logger.behaviour "FAIL;Failed to find test object.;#{id.to_s};sut;{};find;" << (find_hash.kind_of?(Hash) ? find_hash.inspect : find_hash.class.to_s)
68
68
  ## Rescue from center and flick
69
69
  Kernel::raise e
70
70
  end
71
- $logger.log "behaviour" , "PASS;Test object found and centered.;#{id.to_s};sut;{};application;" << find_hash.inspect
71
+ $logger.behaviour "PASS;Test object found and centered.;#{id.to_s};sut;{};application;" << find_hash.inspect
72
72
  search_result
73
73
  end
74
74
 
@@ -89,22 +89,20 @@ module MobyBehaviour
89
89
  params = {:name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => false}
90
90
  #for sut send the fixture command to qttasserver (appid nil)
91
91
  if self.class == MobyBase::SUT
92
- params.merge!( {:application_id => nil, :object_id => self.id, :object_type => :Application} )
93
- ret = self.execute_command( MobyCommand::Fixture.new( params ) )
92
+ params.merge!( {:application_id => nil, :object_id => @id, :object_type => :Application} )
93
+ ret = execute_command( MobyCommand::Fixture.new( params ) )
94
94
  else
95
- params.merge!( {:application_id => get_application_id, :object_id => self.id, :object_type => self.attribute( 'objectType' ).intern} )
95
+ params.merge!( {:application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).intern} )
96
96
  ret = @sut.execute_command( MobyCommand::Fixture.new( params ) )
97
97
  end
98
98
  rescue Exception => e
99
99
 
100
- $logger.log "behaviour",
101
- "FAIL;Failed when calling fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
100
+ $logger.behaviour "FAIL;Failed when calling fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
102
101
 
103
102
  Kernel::raise MobyBase::BehaviourError.new("Fixture", "Failed to execute fixture name #{fixture_name} method #{fixture_method}")
104
103
  end
105
104
 
106
- $logger.log "behaviour",
107
- "PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
105
+ $logger.behaviour "PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
108
106
 
109
107
  ret
110
108
 
@@ -154,22 +152,20 @@ module MobyBehaviour
154
152
  params = {:name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => true}
155
153
  #for sut send the fixture command to qttasserver (appid nil)
156
154
  if self.class == MobyBase::SUT
157
- params.merge!( {:application_id => nil, :object_id => self.id, :object_type => :Application} )
158
- ret = self.execute_command( MobyCommand::Fixture.new( params ) )
155
+ params.merge!( {:application_id => nil, :object_id => @id, :object_type => :Application} )
156
+ ret = execute_command( MobyCommand::Fixture.new( params ) )
159
157
  else
160
- params.merge!( {:application_id => get_application_id, :object_id => self.id, :object_type => self.attribute( 'objectType' ).intern} )
158
+ params.merge!( {:application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).intern} )
161
159
  ret = @sut.execute_command( MobyCommand::Fixture.new( params ) )
162
160
  end
163
161
  rescue Exception => e
164
162
 
165
- $logger.log "behaviour" ,
166
- "FAIL;Failed when calling async_fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
163
+ $logger.behaviour "FAIL;Failed when calling async_fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
167
164
 
168
165
  Kernel::raise MobyBase::BehaviourError.new("Fixture", "Failed to execute async_fixture name #{fixture_name} method #{fixture_method}")
169
166
  end
170
167
 
171
- $logger.log "behaviour",
172
- "PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
168
+ $logger.behaviour "PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
173
169
 
174
170
  ret
175
171
 
@@ -73,12 +73,12 @@ module MobyBehaviour
73
73
  self.fixture('fps', 'startFps')
74
74
  rescue Exception => e
75
75
 
76
- $logger.log "behaviour" , "FAIL;Failed start_fps_measurement.;#{ identity };start_fps_measurement;"
76
+ $logger.behaviour "FAIL;Failed start_fps_measurement.;#{ identity };start_fps_measurement;"
77
77
  Kernel::raise e
78
78
 
79
79
  end
80
80
 
81
- $logger.log "behaviour" , "PASS;Operation start_fps_measurement executed successfully.;#{ identity };start_fps_measurement;"
81
+ $logger.behaviour "PASS;Operation start_fps_measurement executed successfully.;#{ identity };start_fps_measurement;"
82
82
 
83
83
  nil
84
84
  end
@@ -102,12 +102,12 @@ module MobyBehaviour
102
102
  results = parse_results( self.fixture('fps', 'stopFps') )
103
103
  rescue Exception => e
104
104
 
105
- $logger.log "behaviour" , "FAIL;Failed stop_fps_measurement.;#{ identity };stop_fps_measurement;"
105
+ $logger.behaviour "FAIL;Failed stop_fps_measurement.;#{ identity };stop_fps_measurement;"
106
106
  Kernel::raise e
107
107
 
108
108
  end
109
109
 
110
- $logger.log "behaviour" , "PASS;Operation stop_fps_measurement executed successfully.;#{ identity };stop_fps_measurement;"
110
+ $logger.behaviour "PASS;Operation stop_fps_measurement executed successfully.;#{ identity };stop_fps_measurement;"
111
111
 
112
112
  results
113
113
  end
@@ -135,12 +135,12 @@ module MobyBehaviour
135
135
  results = parse_results( self.fixture('fps', 'collectData') )
136
136
  rescue Exception => e
137
137
 
138
- $logger.log "behaviour" , "FAIL;Failed collect_fps_data.;#{ identity };collect_fps_data;"
138
+ $logger.behaviour "FAIL;Failed collect_fps_data.;#{ identity };collect_fps_data;"
139
139
  Kernel::raise e
140
140
 
141
141
  end
142
142
 
143
- $logger.log "behaviour" , "PASS;Operation collect_fps_data executed successfully.;#{ identity };collect_fps_data;"
143
+ $logger.behaviour "PASS;Operation collect_fps_data executed successfully.;#{ identity };collect_fps_data;"
144
144
 
145
145
  results
146
146
  end
@@ -148,7 +148,7 @@ module MobyBehaviour
148
148
  private
149
149
 
150
150
  def parse_results(results_xml)
151
- xml_as_object = MobyBase::StateObject.new( results_xml )
151
+ xml_as_object = @sut.state_object( results_xml )
152
152
  results = []
153
153
  count = xml_as_object.results.attribute('count').to_i
154
154
  for i in 0...count
@@ -42,11 +42,11 @@ module MobyBehaviour
42
42
  # == objects
43
43
  # *
44
44
  #
45
- module Gesture
45
+ module Gesture
46
46
 
47
- include MobyBehaviour::QT::Behaviour
47
+ include MobyBehaviour::QT::Behaviour
48
48
 
49
- # == description
49
+ # == description
50
50
  # Flick the screen at the location of the object (touch the object and do a flick gesture).
51
51
  # Speed and distance of the flick are defined in the tdriver_parameters under the sut used.
52
52
  # By default a flick is a fast gesture.
@@ -81,33 +81,40 @@ module MobyBehaviour
81
81
  # == exceptions
82
82
  # ArgumentError
83
83
  # description: One of the arguments is not valid
84
- def flick( direction, button = :Left, optional_params = {} )
84
+ def flick( direction, button = :Left, optional_params = {} )
85
+
86
+ begin
87
+
88
+ if optional_params[:use_tap_screen].nil?
89
+ use_tap_screen = sut_parameters[ :use_tap_screen, 'false']
90
+ else
91
+ use_tap_screen = optional_params[:use_tap_screen].to_s
92
+ end
85
93
 
86
- begin
87
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
88
- optional_params[:use_tap_screen].to_s
89
- optional_params[:useTapScreen] = use_tap_screen
94
+ optional_params[:useTapScreen] = use_tap_screen
90
95
 
91
- speed = calculate_speed(@sut.parameter[:gesture_flick_distance], @sut.parameter[:gesture_flick_speed])
92
- distance = @sut.parameter[:gesture_flick_distance].to_i
93
- params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => button, :useTapScreen => use_tap_screen}
94
- params.merge!(optional_params)
96
+ speed = calculate_speed(sut_parameters[:gesture_flick_distance], sut_parameters[:gesture_flick_speed])
97
+ distance = sut_parameters[:gesture_flick_distance].to_i
98
+
99
+ params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => button, :useTapScreen => use_tap_screen}
95
100
 
96
- do_gesture(params)
97
- do_sleep(speed)
98
-
99
- rescue Exception => e
101
+ params.merge!(optional_params)
100
102
 
101
- $logger.log "behaviour" , "FAIL;Failed flick with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
102
- Kernel::raise e
103
- end
103
+ do_gesture(params)
104
+ do_sleep(speed)
105
+
106
+ rescue Exception => e
104
107
 
105
- $logger.log "behaviour" , "PASS;Operation flick executed successfully with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
108
+ $logger.behaviour "FAIL;Failed flick with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
109
+ Kernel::raise e
110
+ end
106
111
 
107
- self
108
- end
112
+ $logger.behaviour "PASS;Operation flick executed successfully with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
109
113
 
110
- # == description
114
+ self
115
+ end
116
+
117
+ # == description
111
118
  # Flick the screen at the location of the object (touch the object and do a flick gesture), ending the flick at the specified coordinates.
112
119
  # Speed and distance of the flick are defined in the tdriver_parameters under the sut used.
113
120
  # By default a flick is a fast gesture.
@@ -143,34 +150,50 @@ module MobyBehaviour
143
150
  #
144
151
  # == exceptions
145
152
  # ArgumentError
146
- # description: One of the arguments is not valid
147
- def flick_to( x, y, button = :Left, optional_params = {})
153
+ # description: One of the arguments is not valid
154
+ def flick_to( x, y, button = :Left, optional_params = {})
155
+
156
+ begin
157
+
158
+ if optional_params[:use_tap_screen].nil?
159
+ use_tap_screen = sut_parameters[:use_tap_screen, 'false']
160
+ else
161
+ use_tap_screen = optional_params[:use_tap_screen].to_s
162
+ end
163
+
164
+ optional_params[:useTapScreen] = use_tap_screen
148
165
 
149
- begin
150
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
151
- optional_params[:use_tap_screen].to_s
152
- optional_params[:useTapScreen] = use_tap_screen
166
+ speed = calculate_speed( sut_parameters[ :gesture_flick_distance ], sut_parameters[ :gesture_flick_speed ] )
153
167
 
154
-
168
+ do_gesture(
169
+ {
170
+ :gesture_type => :MouseGestureToCoordinates,
171
+ :x => x,
172
+ :y => y,
173
+ :speed => speed,
174
+ :isDrag => false,
175
+ :button => button,
176
+ :useTapScreen => use_tap_screen
177
+ }
178
+ )
179
+
180
+ do_sleep(speed)
155
181
 
156
- speed = calculate_speed( @sut.parameter[ :gesture_flick_distance ], @sut.parameter[ :gesture_flick_speed ] )
157
- do_gesture({:gesture_type => :MouseGestureToCoordinates, :x => x, :y => y, :speed => speed, :isDrag => false, :button => button, :useTapScreen => use_tap_screen})
158
- do_sleep(speed)
182
+ rescue Exception => e
159
183
 
160
- rescue Exception => e
184
+ $logger.behaviour "FAIL;Failed flick_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
185
+ Kernel::raise e
161
186
 
162
- $logger.log "behaviour" , "FAIL;Failed flick_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
163
- Kernel::raise e
164
- end
187
+ end
165
188
 
166
- $logger.log "behaviour" , "PASS;Operation flick_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
189
+ $logger.behaviour "PASS;Operation flick_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
167
190
 
168
- self
191
+ self
169
192
 
170
- end
193
+ end
171
194
 
172
195
 
173
- # == description
196
+ # == description
174
197
  # Perform a gesture with the object
175
198
  #
176
199
  # == arguments
@@ -200,8 +223,8 @@ module MobyBehaviour
200
223
  # default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
201
224
  #
202
225
  # == tables
203
- # directions_table
204
- # title: Direction symbols table
226
+ # directions_table
227
+ # title: Direction symbols table
205
228
  # |Symbol|
206
229
  # |:Left|
207
230
  # |:Right|
@@ -209,7 +232,7 @@ module MobyBehaviour
209
232
  # |:Down|
210
233
  #
211
234
  # buttons_table
212
- # title: Mouse button symbols table
235
+ # title: Mouse button symbols table
213
236
  # |Symbol|Description|
214
237
  # |:Left|Simulate left mouse button|
215
238
  # |:Middle|Simulate middle mouse button|
@@ -224,43 +247,43 @@ module MobyBehaviour
224
247
  # == exceptions
225
248
  # ArgumentError
226
249
  # description: One of the arguments is not valid
227
- def gesture( direction, speed, distance, optional_params = {:button => :Left, :isDrag => false})
250
+ def gesture( direction, speed, distance, optional_params = {:button => :Left, :isDrag => false})
228
251
 
229
- begin
230
- # change the format for api consitency
231
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
232
- optional_params[:use_tap_screen].to_s
233
- optional_params[:useTapScreen] = use_tap_screen
234
- optional_params['x_off'] = $parameters[ @sut.id ][:tap_x_offset , '0' ],
235
- optional_params['y_off'] = $parameters[ @sut.id ][:tap_y_offset , '0' ]
252
+ begin
236
253
 
254
+ if optional_params[:use_tap_screen].nil?
255
+ use_tap_screen = sut_parameters[ :use_tap_screen, 'false']
256
+ else
257
+ use_tap_screen = optional_params[:use_tap_screen].to_s
258
+ end
237
259
 
260
+ optional_params[:useTapScreen] = use_tap_screen
261
+ optional_params['x_off'] = sut_parameters[:tap_x_offset , '0' ],
262
+ optional_params['y_off'] = sut_parameters[:tap_y_offset , '0' ]
238
263
 
239
- #do_gesture(direction, speed, distance, isDrag, button)
240
- params = {
241
- :gesture_type => :MouseGesture,
242
- :direction => direction,
243
- :speed => speed,
244
- :distance => distance
245
- }
246
- params.merge!(optional_params)
247
- do_gesture(params)
248
- do_sleep(speed)
264
+ #do_gesture(direction, speed, distance, isDrag, button)
265
+ params = {
266
+ :gesture_type => :MouseGesture,
267
+ :direction => direction,
268
+ :speed => speed,
269
+ :distance => distance
270
+ }
271
+ params.merge!(optional_params)
272
+ do_gesture(params)
273
+ do_sleep(speed)
249
274
 
250
- rescue Exception => e
275
+ rescue Exception => e
251
276
 
252
- $logger.log "behaviour",
253
- "FAIL;Failed gesture with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
254
- Kernel::raise e
255
- end
277
+ $logger.behaviour "FAIL;Failed gesture with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
278
+ Kernel::raise e
279
+ end
256
280
 
257
- $logger.log "behaviour",
258
- "PASS;Operation gesture executed successfully with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
281
+ $logger.behaviour "PASS;Operation gesture executed successfully with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
259
282
 
260
- self
261
- end
283
+ self
284
+ end
262
285
 
263
- # == description
286
+ # == description
264
287
  # Perform a gesture with the object, ending the gesture at the specified point.
265
288
  #
266
289
  # == arguments
@@ -293,45 +316,49 @@ module MobyBehaviour
293
316
  # == exceptions
294
317
  # ArgumentError
295
318
  # description: One of the arguments is not valid
296
- def gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false})
297
-
298
- begin
299
- # change the format for api consitency
300
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
301
- optional_params[:use_tap_screen].to_s
302
- optional_params[:useTapScreen] = use_tap_screen
303
-
304
- params = {:gesture_type => :MouseGestureToCoordinates, :speed => speed}
305
- if attribute('objectType') == 'Web'
306
- elemens_xml_data, unused_rule = TDriver::TestObjectAdapter.get_objects( @sut.xml_data, { :id => self.attribute('webFrame')}, true )
307
- object_xml_data = elemens_xml_data[0]
308
- object_attributes = TDriver::TestObjectAdapter.test_object_attributes(object_xml_data, ['x_absolute', 'y_absolute'])
309
- frame_x_absolute = object_attributes['x_absolute'].to_i
310
- frame_y_absolute = object_attributes['y_absolute'].to_i
311
- new_params = {:x=>(frame_x_absolute + x.to_i + (attribute('width' ).to_i/2)),
312
- :y=>(frame_y_absolute + y.to_i + (attribute('height').to_i/2))}
313
- params.merge!(new_params)
314
- else
315
- new_params = {:x=>x, :y=>y}
316
- params.merge!(new_params)
317
- end
318
-
319
-
320
- params.merge!(optional_params)
321
- do_gesture(params)
322
- do_sleep(speed)
319
+ def gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false})
323
320
 
324
- rescue Exception => e
321
+ begin
325
322
 
326
- $logger.log "behaviour" , "FAIL;Failed gesture_to with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", button \".;#{identity};gesture;"
327
- Kernel::raise e
323
+ if optional_params[:use_tap_screen].nil?
324
+ use_tap_screen = sut_parameters[ :use_tap_screen, 'false']
325
+ else
326
+ use_tap_screen = optional_params[:use_tap_screen].to_s
328
327
  end
329
328
 
330
- $logger.log "behaviour" , "PASS;Operation gesture_to executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\".;#{identity};gesture;"
331
- self
329
+ optional_params[:useTapScreen] = use_tap_screen
330
+
331
+ params = {:gesture_type => :MouseGestureToCoordinates, :speed => speed}
332
+ if attribute('objectType') == 'Web'
333
+ elemens_xml_data, unused_rule = @test_object_adapter.get_objects( @sut.xml_data, { :id => attribute('webFrame')}, true )
334
+ object_xml_data = elemens_xml_data[0]
335
+ object_attributes = @test_object_adapter.test_object_attributes(object_xml_data, ['x_absolute', 'y_absolute'])
336
+ frame_x_absolute = object_attributes['x_absolute'].to_i
337
+ frame_y_absolute = object_attributes['y_absolute'].to_i
338
+ new_params = {:x=>(frame_x_absolute + x.to_i + (attribute('width' ).to_i/2)),
339
+ :y=>(frame_y_absolute + y.to_i + (attribute('height').to_i/2))}
340
+ params.merge!(new_params)
341
+ else
342
+ new_params = {:x=>x, :y=>y}
343
+ params.merge!(new_params)
344
+ end
345
+
346
+
347
+ params.merge!(optional_params)
348
+ do_gesture(params)
349
+ do_sleep(speed)
350
+
351
+ rescue Exception => e
352
+
353
+ $logger.behaviour "FAIL;Failed gesture_to with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", button \".;#{identity};gesture;"
354
+ Kernel::raise e
332
355
  end
333
356
 
334
- # == description
357
+ $logger.behaviour "PASS;Operation gesture_to executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\".;#{identity};gesture;"
358
+ self
359
+ end
360
+
361
+ # == description
335
362
  # Perform a gesture with the object, starting the gesture at the specified point inside it.
336
363
  #
337
364
  # == arguments
@@ -379,30 +406,31 @@ module MobyBehaviour
379
406
  # ArgumentError
380
407
  # description: One of the arguments is not valid, or the initial point is outside the target object.
381
408
  #
382
- def gesture_from(x, y, speed, distance, direction, optional_params = {:button => :Left, :isDrag => false})
383
- begin
384
- raise ArgumentError.new( "Coordinate x:#{x} x_abs:#{x} outside object." ) unless ( x <= attribute( 'width' ).to_i and x >= 0 )
385
- raise ArgumentError.new( "Coordinate y:#{y} y_abs:#{y} outside object." ) unless ( y <= attribute( 'height' ).to_i and y >= 0 )
386
-
387
- x_absolute = attribute('x_absolute').to_i + x.to_i
388
- y_absolute = attribute('y_absolute').to_i + y.to_i
409
+ def gesture_from(x, y, speed, distance, direction, optional_params = {:button => :Left, :isDrag => false})
389
410
 
390
- params = {:gesture_type => :MouseGestureFromCoordinates, :x => x_absolute, :y => y_absolute, :speed => speed, :distance => distance, :direction => direction}
411
+ begin
391
412
 
392
- params.merge!(optional_params)
393
- do_gesture(params)
394
- do_sleep(speed)
413
+ raise ArgumentError.new( "Coordinate x:#{x} x_abs:#{x} outside object." ) unless ( x <= attribute( 'width' ).to_i and x >= 0 )
414
+ raise ArgumentError.new( "Coordinate y:#{y} y_abs:#{y} outside object." ) unless ( y <= attribute( 'height' ).to_i and y >= 0 )
415
+
416
+ x_absolute = attribute('x_absolute').to_i + x.to_i
417
+ y_absolute = attribute('y_absolute').to_i + y.to_i
395
418
 
419
+ params = {:gesture_type => :MouseGestureFromCoordinates, :x => x_absolute, :y => y_absolute, :speed => speed, :distance => distance, :direction => direction}
396
420
 
397
- rescue Exception => e
398
- $logger.log "behaviour" , "FAIL;Failed gesture_from with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\", button \".;#{identity};gesture;"
399
- Kernel::raise e
400
- end
401
- $logger.log "behaviour" , "PASS;Operation gesture_from executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
402
- self
403
- end
421
+ params.merge!(optional_params)
422
+ do_gesture(params)
423
+ do_sleep(speed)
424
+
425
+ rescue Exception => e
426
+ $logger.behaviour "FAIL;Failed gesture_from with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\", button \".;#{identity};gesture;"
427
+ Kernel::raise e
428
+ end
429
+ $logger.behaviour "PASS;Operation gesture_from executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
430
+ self
431
+ end
404
432
 
405
- # == description
433
+ # == description
406
434
  # Perform a gesture with the object, ending the gesture at the center of another object.
407
435
  #
408
436
  # == arguments
@@ -430,50 +458,53 @@ module MobyBehaviour
430
458
  # == exceptions
431
459
  # ArgumentError
432
460
  # description: One of the arguments is not valid
433
- def gesture_to_object(target_object, duration, optional_params = {:button => :Left, :isDrag => false})
434
- if attribute('objectType') == 'Web'
435
- elemens_xml_data, unused_rule = TDriver::TestObjectAdapter.get_objects( @sut.xml_data, { :id => self.attribute('webFrame')}, true )
436
- object_xml_data = elemens_xml_data[0]
437
- object_attributes = TDriver::TestObjectAdapter.test_object_attributes(object_xml_data, ['x', 'y'])
438
- frame_x = object_attributes['x'].to_i
439
- frame_y = object_attributes['y'].to_i
440
- puts "x " + frame_x.to_s + " y " + frame_y.to_s
441
-
442
-
443
- gesture_to(target_object.attribute('x').to_i + (target_object.attribute('width' ).to_i/2) - (attribute('width' ).to_i/2 ) - frame_x,
444
- target_object.attribute('y').to_i + (target_object.attribute('height').to_i/2) - (attribute('height').to_i/2 ) - frame_y,
445
- duration, optional_params)
446
- nil
447
- return
448
- end
461
+ def gesture_to_object(target_object, duration, optional_params = {:button => :Left, :isDrag => false})
462
+
463
+ if attribute('objectType') == 'Web'
464
+ elemens_xml_data, unused_rule = @test_object_adapter.get_objects( @sut.xml_data, { :id => attribute('webFrame')}, true )
465
+ object_xml_data = elemens_xml_data[0]
466
+ object_attributes = @test_object_adapter.test_object_attributes(object_xml_data, ['x', 'y'])
467
+ frame_x = object_attributes['x'].to_i
468
+ frame_y = object_attributes['y'].to_i
469
+ puts "x " + frame_x.to_s + " y " + frame_y.to_s
470
+
471
+
472
+ gesture_to(target_object.attribute('x').to_i + (target_object.attribute('width' ).to_i/2) - (attribute('width' ).to_i/2 ) - frame_x,
473
+ target_object.attribute('y').to_i + (target_object.attribute('height').to_i/2) - (attribute('height').to_i/2 ) - frame_y,
474
+ duration, optional_params)
475
+ nil
476
+ return
477
+ end
449
478
 
450
- begin
451
- # change the format for api consitency
452
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
453
- optional_params[:use_tap_screen].to_s
454
- optional_params[:useTapScreen] = use_tap_screen
479
+ begin
455
480
 
481
+ if optional_params[:use_tap_screen].nil?
482
+ use_tap_screen = sut_parameters[ :use_tap_screen, 'false']
483
+ else
484
+ use_tap_screen = optional_params[:use_tap_screen].to_s
485
+ end
456
486
 
487
+ optional_params[:useTapScreen] = use_tap_screen
457
488
 
458
- params = {:gesture_type => :MouseGestureTo, :speed => duration}
459
- params[:targetId] = target_object.id
460
- params[:targetType] = target_object.attribute('objectType')
461
- params.merge!(optional_params)
462
- do_gesture(params)
463
- do_sleep(duration)
489
+ params = {:gesture_type => :MouseGestureTo, :speed => duration}
490
+ params[:targetId] = target_object.id
491
+ params[:targetType] = target_object.attribute('objectType')
492
+ params.merge!(optional_params)
493
+ do_gesture(params)
494
+ do_sleep(duration)
464
495
 
465
- rescue Exception => e
496
+ rescue Exception => e
466
497
 
467
- $logger.log "behaviour" , "FAIL;Failed gesture_to_object with button.;#{identity};drag;"
468
- Kernel::raise e
498
+ $logger.behaviour "FAIL;Failed gesture_to_object with button.;#{identity};drag;"
499
+ Kernel::raise e
469
500
 
470
- end
501
+ end
471
502
 
472
- $logger.log "behaviour" , "PASS;Operation gesture_to_object executed successfully with button.;#{identity};drag;"
503
+ $logger.behaviour "PASS;Operation gesture_to_object executed successfully with button.;#{identity};drag;"
473
504
 
474
- self
505
+ self
475
506
 
476
- end
507
+ end
477
508
 
478
509
  # == description
479
510
  # Perform a gesture following a track of points.
@@ -509,60 +540,62 @@ module MobyBehaviour
509
540
  # == exceptions
510
541
  # ArgumentError
511
542
  # description: One of the arguments is not valid
512
- def gesture_points( points, duration, mouse_details = { :press => true, :release => true, :button => :Left, :isDrag => true}, optional_params = {} )
543
+ def gesture_points( points, duration, mouse_details = { :press => true, :release => true, :button => :Left, :isDrag => true}, optional_params = {} )
513
544
 
514
- begin
545
+ begin
546
+
547
+ if optional_params[:use_tap_screen].nil?
548
+ use_tap_screen = sut_parameters[:use_tap_screen, 'false']
549
+ else
550
+ use_tap_screen = optional_params[:use_tap_screen].to_s
551
+ end
515
552
 
516
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
517
- optional_params[:use_tap_screen].to_s
518
553
  optional_params[:useTapScreen] = use_tap_screen
519
554
 
520
- mouse_details[:press] = true unless mouse_details.has_value?(:press)
521
- mouse_details[:release] = true unless mouse_details.has_value?(:release)
522
- mouse_details[:button] = :Left unless mouse_details.has_value?(:button)
523
- mouse_details[:isDrag] = true unless mouse_details.has_value?(:isDrag)
555
+ mouse_details[:press] = true unless mouse_details.has_value?(:press)
556
+ mouse_details[:release] = true unless mouse_details.has_value?(:release)
557
+ mouse_details[:button] = :Left unless mouse_details.has_value?(:button)
558
+ mouse_details[:isDrag] = true unless mouse_details.has_value?(:isDrag)
524
559
 
525
- raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(mouse_details[:button])
560
+ raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(mouse_details[:button])
526
561
 
527
- command = command_params #in qt_behaviour
528
- command.command_name('MouseGesturePoints')
529
- params = {'mouseMove'=>'true'}
562
+ command = command_params #in qt_behaviour
563
+ command.command_name('MouseGesturePoints')
564
+ params = {'mouseMove'=>'true'}
530
565
 
531
- params['button'] = @@_buttons_map[mouse_details[:button]]
532
- params['press'] = 'false' unless mouse_details[:press]
533
- params['release'] = 'false' unless mouse_details[:release]
534
- params['isDrag'] = 'true' if mouse_details[:isDrag]
535
- params.merge!(optional_params)
566
+ params['button'] = @@_buttons_map[mouse_details[:button]]
567
+ params['press'] = 'false' unless mouse_details[:press]
568
+ params['release'] = 'false' unless mouse_details[:release]
569
+ params['isDrag'] = 'true' if mouse_details[:isDrag]
570
+ params.merge!(optional_params)
536
571
 
537
572
 
538
- millis = duration.to_f
539
- millis = millis*1000
540
- speed = millis.to_i
541
- params['speed'] = speed.to_s
542
- command.command_params(params)
543
- point_string = ""
544
- points.each { |point| point_string << point["x"].to_s << "," << point["y"].to_s << "," << (point["interval"]*1000).to_i.to_s << ";"}
545
- command.command_value(point_string)
573
+ millis = duration.to_f
574
+ millis = millis*1000
575
+ speed = millis.to_i
576
+ params['speed'] = speed.to_s
577
+ command.command_params(params)
578
+ point_string = ""
579
+ points.each { |point| point_string << point["x"].to_s << "," << point["y"].to_s << "," << (point["interval"]*1000).to_i.to_s << ";"}
580
+ command.command_value(point_string)
546
581
 
547
- @sut.execute_command(command)
582
+ @sut.execute_command(command)
548
583
 
549
- do_sleep(duration)
584
+ do_sleep(duration)
550
585
 
551
- rescue Exception => e
586
+ rescue Exception => e
552
587
 
553
- $logger.log "behaviour",
554
- "FAIL;Failed drag_to_object with points \"#{points.to_s}\", duration \"#{duration.to_s}\", mouse_details \"#{mouse_details.to_s}\".;#{identity};gesture_points;"
555
- Kernel::raise e
588
+ $logger.behaviour "FAIL;Failed drag_to_object with points \"#{points.to_s}\", duration \"#{duration.to_s}\", mouse_details \"#{mouse_details.to_s}\".;#{identity};gesture_points;"
589
+ Kernel::raise e
556
590
 
557
- end
591
+ end
558
592
 
559
- $logger.log "behaviour",
560
- "PASS;Operation drag_to_object executed successfully with points \"#{points.to_s}\", duration \"#{duration.to_s}\", mouse_details \"#{mouse_details.to_s}\".;#{identity};gesture_points;"
593
+ $logger.behaviour "PASS;Operation drag_to_object executed successfully with points \"#{points.to_s}\", duration \"#{duration.to_s}\", mouse_details \"#{mouse_details.to_s}\".;#{identity};gesture_points;"
561
594
 
562
- self
563
- end
595
+ self
596
+ end
564
597
 
565
- # == description
598
+ # == description
566
599
  # Drag the object for the given distance.
567
600
  # By default a drag is a slow gesture.
568
601
  #
@@ -601,30 +634,36 @@ module MobyBehaviour
601
634
  # == exceptions
602
635
  # ArgumentError
603
636
  # description: One of the arguments is not valid
604
- def drag(direction, distance, button = :Left, optional_params = {})
637
+ def drag(direction, distance, button = :Left, optional_params = {})
638
+
639
+ begin
640
+
641
+ if optional_params[:use_tap_screen].nil?
642
+ use_tap_screen = sut_parameters[:use_tap_screen, 'false']
643
+ else
644
+ use_tap_screen = optional_params[:use_tap_screen].to_s
645
+ end
605
646
 
606
- begin
607
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
608
- optional_params[:use_tap_screen].to_s
609
- optional_params[:useTapScreen] = use_tap_screen
647
+ optional_params[:useTapScreen] = use_tap_screen
610
648
 
611
- speed = calculate_speed( distance, @sut.parameter[ :gesture_drag_speed ] )
612
- params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => true, :button => button}
613
- params.merge!(optional_params)
614
- do_gesture(params)
615
- do_sleep( speed )
649
+ speed = calculate_speed( distance, sut_parameters[ :gesture_drag_speed ] )
650
+
651
+ params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => true, :button => button}
652
+ params.merge!(optional_params)
653
+ do_gesture(params)
654
+ do_sleep( speed )
616
655
 
617
- rescue Exception => e
618
-
619
- $logger.log "behaviour" , "FAIL;Failed drag with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
620
- Kernel::raise e
656
+ rescue Exception => e
657
+
658
+ $logger.behaviour "FAIL;Failed drag with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
659
+ Kernel::raise e
621
660
 
622
- end
661
+ end
623
662
 
624
- $logger.log "behaviour" , "PASS;Operation drag executed successfully with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
663
+ $logger.behaviour "PASS;Operation drag executed successfully with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
625
664
 
626
- self
627
- end
665
+ self
666
+ end
628
667
 
629
668
  # == description
630
669
  # Drag the object to the given coordinates.
@@ -661,20 +700,20 @@ module MobyBehaviour
661
700
  # == exceptions
662
701
  # ArgumentError
663
702
  # description: One of the arguments is not valid
664
- def drag_to( x, y, button = :Left, optional_params= {} )
703
+ def drag_to( x, y, button = :Left, optional_params= {} )
665
704
 
666
705
  begin
667
- optional_params.merge!({ :isDrag => true , :button=>button})
706
+ optional_params.merge!({ :isDrag => true, :button=>button})
668
707
  distance = distance_to_point(x,y)
669
- speed = calculate_speed(distance, @sut.parameter[:gesture_drag_speed])
708
+ speed = calculate_speed(distance, sut_parameters[:gesture_drag_speed])
670
709
  gesture_to(x, y, speed, optional_params )
671
710
 
672
711
  rescue Exception => e
673
- $logger.log "behaviour" , "FAIL;Failed drag_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
712
+ $logger.behaviour "FAIL;Failed drag_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
674
713
  Kernel::raise e
675
714
  end
676
715
 
677
- $logger.log "behaviour" , "PASS;Operation drag_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
716
+ $logger.behaviour "PASS;Operation drag_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
678
717
 
679
718
  self
680
719
 
@@ -710,40 +749,44 @@ module MobyBehaviour
710
749
  # == exceptions
711
750
  # ArgumentError
712
751
  # description: One of the arguments is not valid
713
- def drag_to_object(target_object, button = :Left, optional_params = {})
752
+ def drag_to_object(target_object, button = :Left, optional_params = {})
753
+
754
+ begin
714
755
 
715
- begin
756
+ if optional_params[:use_tap_screen].nil?
757
+ use_tap_screen = sut_parameters[:use_tap_screen, 'false']
758
+ else
759
+ use_tap_screen = optional_params[:use_tap_screen].to_s
760
+ end
716
761
 
717
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
718
- optional_params[:use_tap_screen].to_s
719
762
  optional_params[:useTapScreen] = use_tap_screen
720
763
 
721
- distance = distance_to_point(target_object.object_center_x, target_object.object_center_y)
722
- #no drag needed, maybe even attempting to drag to it self
723
- return if distance == 0
764
+ distance = distance_to_point(target_object.object_center_x, target_object.object_center_y)
765
+ #no drag needed, maybe even attempting to drag to it self
766
+ return if distance == 0
724
767
 
725
- speed = calculate_speed(distance, @sut.parameter[:gesture_drag_speed])
768
+ speed = calculate_speed(distance, sut_parameters[:gesture_drag_speed])
726
769
  params = {:gesture_type => :MouseGestureTo, :speed => speed, :isDrag => true, :button => button}
727
770
  params[:targetId] = target_object.id
728
771
  params[:targetType] = target_object.attribute('objectType')
729
772
  params.merge!(optional_params)
730
773
  do_gesture(params)
731
- do_sleep(speed)
774
+ do_sleep(speed)
732
775
 
733
- rescue Exception => e
776
+ rescue Exception => e
734
777
 
735
- $logger.log "behaviour" , "FAIL;Failed drag_to_object with button \"#{button.to_s}\".;#{identity};drag;"
736
- Kernel::raise e
778
+ $logger.behaviour "FAIL;Failed drag_to_object with button \"#{button.to_s}\".;#{identity};drag;"
779
+ Kernel::raise e
737
780
 
738
- end
781
+ end
739
782
 
740
- $logger.log "behaviour" , "PASS;Operation drag_to_object executed successfully with button \"#{button.to_s}\".;#{identity};drag;"
783
+ $logger.behaviour "PASS;Operation drag_to_object executed successfully with button \"#{button.to_s}\".;#{identity};drag;"
741
784
 
742
- self
785
+ self
743
786
 
744
- end
787
+ end
745
788
 
746
- # == description
789
+ # == description
747
790
  # Perform a pointer move starting at the object
748
791
  #
749
792
  # == arguments
@@ -781,154 +824,160 @@ module MobyBehaviour
781
824
  # == exceptions
782
825
  # ArgumentError
783
826
  # description: One of the arguments is not valid
784
- def move(direction, distance, button = :Left, optional_params = {})
827
+ def move(direction, distance, button = :Left, optional_params = {})
828
+
829
+ begin
785
830
 
786
- begin
831
+ if optional_params[:use_tap_screen].nil?
832
+ use_tap_screen = sut_parameters[:use_tap_screen, 'false']
833
+ else
834
+ use_tap_screen = optional_params[:use_tap_screen].to_s
835
+ end
787
836
 
788
- use_tap_screen = optional_params[:use_tap_screen].nil? ? $parameters[ @sut.id][ :use_tap_screen, 'false'] :
789
837
  optional_params[:use_tap_screen].to_s
790
838
  optional_params[:useTapScreen] = use_tap_screen
791
839
 
792
- speed = calculate_speed( distance, @sut.parameter[ :gesture_drag_speed ] )
840
+ speed = calculate_speed( distance, sut_parameters[ :gesture_drag_speed ] )
793
841
  params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => button, :isMove => true}
794
842
  params.merge!(optional_params)
795
843
  do_gesture(params)
796
- do_sleep( speed )
844
+ do_sleep( speed )
797
845
 
798
- rescue Exception => e
846
+ rescue Exception => e
799
847
 
800
- $logger.log "behaviour" , "FAIL;Failed move with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
801
- Kernel::raise e
848
+ $logger.behaviour "FAIL;Failed move with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
849
+ Kernel::raise e
802
850
 
803
- end
851
+ end
804
852
 
805
- $logger.log "behaviour" , "PASS;Operation move executed successfully with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
853
+ $logger.behaviour "PASS;Operation move executed successfully with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
806
854
 
807
- self
855
+ self
808
856
 
809
- end
857
+ end
810
858
 
811
859
 
812
860
  # == nodoc
813
- # utility function for getting the x coordinate of the center of the object, should this be private method?
814
- def object_center_x
815
- center_x
816
- end
861
+ # utility function for getting the x coordinate of the center of the object, should this be private method?
862
+ def object_center_x
863
+ center_x
864
+ end
817
865
 
818
866
  # == nodoc
819
- # utility function for getting the y coordinate of the center of the object, should this be private method?
820
- def object_center_y
821
- center_y
822
- end
867
+ # utility function for getting the y coordinate of the center of the object, should this be private method?
868
+ def object_center_y
869
+ center_y
870
+ end
823
871
 
824
872
  private
825
873
 
826
- # Performs the actual gesture operation.
827
- # Verifies that the parameters are correct and send the command
828
- # to the sut.
829
- # gesture_type: :MouseGesture, :MouseGestureTo, :MouseGestureToCoordinates
830
- # params = {:direction => :Up, duration => 2, :distance =>100, :isDrag =>false, :isMove =>false }
831
- def do_gesture(params)
832
- validate_gesture_params!(params)
833
-
834
- if attribute('objectType') == 'Embedded' or attribute('objectType') == 'Web'
835
- params['obj_x'] = center_x
836
- params['obj_y'] = center_y
837
- params['useCoordinates'] = 'true'
838
- end
874
+ # Performs the actual gesture operation.
875
+ # Verifies that the parameters are correct and send the command
876
+ # to the sut.
877
+ # gesture_type: :MouseGesture, :MouseGestureTo, :MouseGestureToCoordinates
878
+ # params = {:direction => :Up, duration => 2, :distance =>100, :isDrag =>false, :isMove =>false }
879
+ def do_gesture(params)
839
880
 
840
- command = command_params #in qt_behaviour
841
- command.command_name(params[:gesture_type].to_s)
842
- command.command_params( params )
843
- @sut.execute_command( command )
844
- end
881
+ validate_gesture_params!(params)
845
882
 
846
- def validate_gesture_params!(params)
847
- #direction
848
- if params[:gesture_type] == :MouseGesture or params[:gesture_type] == :MouseGestureFromCoordinates
849
- if params[:direction].kind_of?(Integer)
850
- raise ArgumentError.new( "Invalid direction." ) unless 0 <= params[:direction].to_i and params[:direction].to_i <= 360
851
- else
852
- raise ArgumentError.new( "Invalid direction." ) unless @@_valid_directions.include?(params[:direction])
853
- params[:direction] = @@_direction_map[params[:direction]]
854
- end
855
- #distance
856
- params[:distance] = params[:distance].to_i unless params[:distance].kind_of?(Integer)
857
- raise ArgumentError.new( "Distance must be an integer and greater than zero." ) unless params[:distance] > 0
858
- elsif params[:gesture_type] == :MouseGestureToCoordinates or params[:gesture_type] == :MouseGestureFromCoordinates
859
- raise ArgumentError.new("X and Y must be integers.") unless params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
860
- elsif params[:gesture_type] == :MouseGestureTo
861
- raise ArgumentError.new("targetId and targetType must be defined.") unless params[:targetId] and params[:targetType]
862
- end
863
-
864
- #duration/speed
865
- params[:speed] = params[:speed].to_f unless params[:speed].kind_of?(Numeric)
866
- raise ArgumentError.new( "Duration must be a number and greated than zero, was:" + params[:speed].to_s) unless params[:speed] > 0
867
- duration_secs = params[:speed].to_f
868
- duration_secs = duration_secs*1000
869
- params[:speed] = duration_secs.to_i
870
-
871
- #mouseMove true always
872
- params[:mouseMove] = true
883
+ if attribute('objectType') == 'Embedded' or attribute('objectType') == 'Web'
884
+ params['obj_x'] = center_x
885
+ params['obj_y'] = center_y
886
+ params['useCoordinates'] = 'true'
887
+ end
873
888
 
874
- params[:button] = :Left unless params[:button]
875
- raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(params[:button])
876
- params[:button] = @@_buttons_map[params[:button]]
889
+ command = command_params #in qt_behaviour
890
+ command.command_name(params[:gesture_type].to_s)
891
+ command.command_params( params )
892
+ @sut.execute_command( command )
893
+ end
877
894
 
878
- if params[:isMove] == true
879
- params[:press] = 'false'
880
- params[:release] = 'false'
881
- end
895
+ def validate_gesture_params!(params)
896
+ #direction
897
+ if params[:gesture_type] == :MouseGesture or params[:gesture_type] == :MouseGestureFromCoordinates
898
+ if params[:direction].kind_of?(Integer)
899
+ raise ArgumentError.new( "Invalid direction." ) unless 0 <= params[:direction].to_i and params[:direction].to_i <= 360
900
+ else
901
+ raise ArgumentError.new( "Invalid direction." ) unless @@_valid_directions.include?(params[:direction])
902
+ params[:direction] = @@_direction_map[params[:direction]]
903
+ end
904
+ #distance
905
+ params[:distance] = params[:distance].to_i unless params[:distance].kind_of?(Integer)
906
+ raise ArgumentError.new( "Distance must be an integer and greater than zero." ) unless params[:distance] > 0
907
+ elsif params[:gesture_type] == :MouseGestureToCoordinates or params[:gesture_type] == :MouseGestureFromCoordinates
908
+ raise ArgumentError.new("X and Y must be integers.") unless params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
909
+ elsif params[:gesture_type] == :MouseGestureTo
910
+ raise ArgumentError.new("targetId and targetType must be defined.") unless params[:targetId] and params[:targetType]
911
+ end
912
+
913
+ #duration/speed
914
+ params[:speed] = params[:speed].to_f unless params[:speed].kind_of?(Numeric)
915
+ raise ArgumentError.new( "Duration must be a number and greated than zero, was:" + params[:speed].to_s) unless params[:speed] > 0
916
+ duration_secs = params[:speed].to_f
917
+ duration_secs = duration_secs*1000
918
+ params[:speed] = duration_secs.to_i
919
+
920
+ #mouseMove true always
921
+ params[:mouseMove] = true
922
+
923
+ params[:button] = :Left unless params[:button]
924
+ raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(params[:button])
925
+ params[:button] = @@_buttons_map[params[:button]]
926
+
927
+ if params[:isMove] == true
928
+ params[:press] = 'false'
929
+ params[:release] = 'false'
930
+ end
882
931
 
883
- end
932
+ end
884
933
 
885
- def do_sleep(time)
934
+ def do_sleep(time)
886
935
 
887
- if $parameters[ @sut.id ][ :sleep_disabled, nil ] != true
936
+ if sut_parameters[ :sleep_disabled, nil ] != true
888
937
 
889
- time = time.to_f * 1.3
938
+ time = time.to_f * 1.3
890
939
 
891
- #for flicks the duration of the gesture is short but animation (scroll etc..) may not
892
- #so wait at least one second
893
- time = 1 if time < 1
940
+ #for flicks the duration of the gesture is short but animation (scroll etc..) may not
941
+ #so wait at least one second
942
+ time = 1 if time < 1
894
943
 
895
- sleep time
944
+ sleep time
896
945
 
897
- else
946
+ else
898
947
 
899
- # store the biggest value which will then be used in multitouch situations to sleep
900
- $parameters[ @sut.id ][ :skipped_sleep_time ] = time if time > $parameters[ @sut.id ][ :skipped_sleep_time, 0 ]
948
+ # store the biggest value which will then be used in multitouch situations to sleep
949
+ sut_parameters[ :skipped_sleep_time ] = time if time > sut_parameters[ :skipped_sleep_time, 0 ]
901
950
 
902
- end
951
+ end
903
952
 
904
- end
953
+ end
905
954
 
906
- def calculate_speed(distance, speed)
955
+ def calculate_speed(distance, speed)
907
956
 
908
- distance = distance.to_f
909
- speed = speed.to_f
910
- duration = distance/speed
911
- duration
957
+ distance = distance.to_f
958
+ speed = speed.to_f
959
+ duration = distance/speed
960
+ duration
912
961
 
913
- end
962
+ end
914
963
 
915
- def distance_to_point(x, y)
964
+ def distance_to_point(x, y)
916
965
 
917
- x = x.to_i
918
- y = y.to_i
919
- dist_x = x - center_x.to_i
920
- dist_y = y - center_y.to_i
966
+ x = x.to_i
967
+ y = y.to_i
968
+ dist_x = x - center_x.to_i
969
+ dist_y = y - center_y.to_i
921
970
 
922
- return 0 if dist_y == 0 and dist_x == 0
923
- distance = Math.hypot( dist_x, dist_y )
924
- distance
971
+ return 0 if dist_y == 0 and dist_x == 0
972
+ distance = Math.hypot( dist_x, dist_y )
973
+ distance
925
974
 
926
- end
975
+ end
927
976
 
928
- # enable hooking for performance measurement & debug logging
929
- TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
977
+ # enable hooking for performance measurement & debug logging
978
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
930
979
 
931
- end
980
+ end
932
981
 
933
982
  end
934
983
  end