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.
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +7 -6
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +190 -182
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +2 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +17 -17
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +6 -6
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +6 -6
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +2 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +10 -14
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fps.rb +7 -7
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +387 -338
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +177 -5
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +5 -5
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +2 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +34 -7
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +4 -4
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +4 -4
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +6 -6
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +8 -12
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/settings.rb +8 -8
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +171 -115
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +2 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +11 -7
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +2 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +5 -5
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +13 -13
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +54 -63
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +45 -28
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/version.rb +34 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +2 -2
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +174 -121
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +35 -26
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/version.rb +56 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +64 -16
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +138 -40
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +91 -83
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +222 -44
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +176 -10
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +2 -2
- data/xml/behaviour/qt.xml +12 -0
- metadata +7 -5
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb
CHANGED
@@ -240,11 +240,11 @@ module MobyBehaviour
|
|
240
240
|
begin
|
241
241
|
returnValue = @sut.execute_command( command )
|
242
242
|
rescue
|
243
|
-
$logger.
|
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.
|
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
|
|
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb
CHANGED
@@ -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
|
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(
|
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
|
72
|
+
if attribute( 'objectType' ) == 'Embedded'
|
73
73
|
command.application_id( get_application_id )
|
74
|
-
command.
|
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.
|
79
|
-
command.object_type(
|
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(
|
91
|
+
command.set_event_type(sut_parameters[ :event_type, "0" ])
|
90
92
|
command.application_id( get_application_id )
|
91
|
-
command.
|
92
|
-
command.object_type(
|
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 =
|
113
|
-
#width =
|
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
|
-
( (
|
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 =
|
124
|
-
#height =
|
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
|
-
( (
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
114
|
+
$logger.behaviour "FAIL;Failed disable_events.;#{ identity };disable_events;"
|
115
115
|
Kernel::raise e
|
116
116
|
end
|
117
117
|
|
118
|
-
$logger.
|
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.
|
149
|
+
$logger.behaviour "FAIL;Failed get_events.;#{ identity };get_events;"
|
150
150
|
Kernel::raise e
|
151
151
|
|
152
152
|
end
|
153
153
|
|
154
|
-
$logger.
|
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.
|
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.
|
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 =>
|
93
|
-
ret =
|
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 =>
|
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.
|
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.
|
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 =>
|
158
|
-
ret =
|
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 =>
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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 =
|
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
|
-
|
45
|
+
module Gesture
|
46
46
|
|
47
|
-
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
48
|
|
49
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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
|
-
|
97
|
-
do_sleep(speed)
|
98
|
-
|
99
|
-
rescue Exception => e
|
101
|
+
params.merge!(optional_params)
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
|
103
|
+
do_gesture(params)
|
104
|
+
do_sleep(speed)
|
105
|
+
|
106
|
+
rescue Exception => e
|
104
107
|
|
105
|
-
|
108
|
+
$logger.behaviour "FAIL;Failed flick with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
|
109
|
+
Kernel::raise e
|
110
|
+
end
|
106
111
|
|
107
|
-
|
108
|
-
end
|
112
|
+
$logger.behaviour "PASS;Operation flick executed successfully with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
|
109
113
|
|
110
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
163
|
-
Kernel::raise e
|
164
|
-
end
|
187
|
+
end
|
165
188
|
|
166
|
-
|
189
|
+
$logger.behaviour "PASS;Operation flick_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
167
190
|
|
168
|
-
|
191
|
+
self
|
169
192
|
|
170
|
-
|
193
|
+
end
|
171
194
|
|
172
195
|
|
173
|
-
|
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
|
-
|
204
|
-
|
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
|
-
|
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
|
-
|
250
|
+
def gesture( direction, speed, distance, optional_params = {:button => :Left, :isDrag => false})
|
228
251
|
|
229
|
-
|
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
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
-
|
275
|
+
rescue Exception => e
|
251
276
|
|
252
|
-
|
253
|
-
|
254
|
-
|
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
|
-
|
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
|
-
|
261
|
-
|
283
|
+
self
|
284
|
+
end
|
262
285
|
|
263
|
-
|
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
|
-
|
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
|
-
|
321
|
+
begin
|
325
322
|
|
326
|
-
|
327
|
-
|
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
|
-
|
331
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
411
|
+
begin
|
391
412
|
|
392
|
-
|
393
|
-
|
394
|
-
|
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
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
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
|
-
|
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
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
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
|
-
|
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
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
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
|
-
|
496
|
+
rescue Exception => e
|
466
497
|
|
467
|
-
|
468
|
-
|
498
|
+
$logger.behaviour "FAIL;Failed gesture_to_object with button.;#{identity};drag;"
|
499
|
+
Kernel::raise e
|
469
500
|
|
470
|
-
|
501
|
+
end
|
471
502
|
|
472
|
-
|
503
|
+
$logger.behaviour "PASS;Operation gesture_to_object executed successfully with button.;#{identity};drag;"
|
473
504
|
|
474
|
-
|
505
|
+
self
|
475
506
|
|
476
|
-
|
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
|
-
|
543
|
+
def gesture_points( points, duration, mouse_details = { :press => true, :release => true, :button => :Left, :isDrag => true}, optional_params = {} )
|
513
544
|
|
514
|
-
|
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
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
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
|
-
|
560
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(mouse_details[:button])
|
526
561
|
|
527
|
-
|
528
|
-
|
529
|
-
|
562
|
+
command = command_params #in qt_behaviour
|
563
|
+
command.command_name('MouseGesturePoints')
|
564
|
+
params = {'mouseMove'=>'true'}
|
530
565
|
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
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
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
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
|
-
|
582
|
+
@sut.execute_command(command)
|
548
583
|
|
549
|
-
|
584
|
+
do_sleep(duration)
|
550
585
|
|
551
|
-
|
586
|
+
rescue Exception => e
|
552
587
|
|
553
|
-
|
554
|
-
|
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
|
-
|
591
|
+
end
|
558
592
|
|
559
|
-
|
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
|
-
|
563
|
-
|
595
|
+
self
|
596
|
+
end
|
564
597
|
|
565
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
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
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
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
|
-
|
661
|
+
end
|
623
662
|
|
624
|
-
|
663
|
+
$logger.behaviour "PASS;Operation drag executed successfully with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
|
625
664
|
|
626
|
-
|
627
|
-
|
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
|
-
|
703
|
+
def drag_to( x, y, button = :Left, optional_params= {} )
|
665
704
|
|
666
705
|
begin
|
667
|
-
optional_params.merge!({ :isDrag => true
|
706
|
+
optional_params.merge!({ :isDrag => true, :button=>button})
|
668
707
|
distance = distance_to_point(x,y)
|
669
|
-
speed = calculate_speed(distance,
|
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.
|
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.
|
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
|
-
|
752
|
+
def drag_to_object(target_object, button = :Left, optional_params = {})
|
753
|
+
|
754
|
+
begin
|
714
755
|
|
715
|
-
|
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
|
-
|
722
|
-
|
723
|
-
|
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
|
-
|
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
|
-
|
774
|
+
do_sleep(speed)
|
732
775
|
|
733
|
-
|
776
|
+
rescue Exception => e
|
734
777
|
|
735
|
-
|
736
|
-
|
778
|
+
$logger.behaviour "FAIL;Failed drag_to_object with button \"#{button.to_s}\".;#{identity};drag;"
|
779
|
+
Kernel::raise e
|
737
780
|
|
738
|
-
|
781
|
+
end
|
739
782
|
|
740
|
-
|
783
|
+
$logger.behaviour "PASS;Operation drag_to_object executed successfully with button \"#{button.to_s}\".;#{identity};drag;"
|
741
784
|
|
742
|
-
|
785
|
+
self
|
743
786
|
|
744
|
-
|
787
|
+
end
|
745
788
|
|
746
|
-
|
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
|
-
|
827
|
+
def move(direction, distance, button = :Left, optional_params = {})
|
828
|
+
|
829
|
+
begin
|
785
830
|
|
786
|
-
|
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
|
-
|
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
|
-
|
844
|
+
do_sleep( speed )
|
797
845
|
|
798
|
-
|
846
|
+
rescue Exception => e
|
799
847
|
|
800
|
-
|
801
|
-
|
848
|
+
$logger.behaviour "FAIL;Failed move with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
|
849
|
+
Kernel::raise e
|
802
850
|
|
803
|
-
|
851
|
+
end
|
804
852
|
|
805
|
-
|
853
|
+
$logger.behaviour "PASS;Operation move executed successfully with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
|
806
854
|
|
807
|
-
|
855
|
+
self
|
808
856
|
|
809
|
-
|
857
|
+
end
|
810
858
|
|
811
859
|
|
812
860
|
# == nodoc
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
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
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
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
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
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
|
-
|
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
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
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
|
-
|
875
|
-
|
876
|
-
|
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
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
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
|
-
|
932
|
+
end
|
884
933
|
|
885
|
-
|
934
|
+
def do_sleep(time)
|
886
935
|
|
887
|
-
|
936
|
+
if sut_parameters[ :sleep_disabled, nil ] != true
|
888
937
|
|
889
|
-
|
938
|
+
time = time.to_f * 1.3
|
890
939
|
|
891
|
-
|
892
|
-
|
893
|
-
|
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
|
-
|
944
|
+
sleep time
|
896
945
|
|
897
|
-
|
946
|
+
else
|
898
947
|
|
899
|
-
|
900
|
-
|
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
|
-
|
951
|
+
end
|
903
952
|
|
904
|
-
|
953
|
+
end
|
905
954
|
|
906
|
-
|
955
|
+
def calculate_speed(distance, speed)
|
907
956
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
957
|
+
distance = distance.to_f
|
958
|
+
speed = speed.to_f
|
959
|
+
duration = distance/speed
|
960
|
+
duration
|
912
961
|
|
913
|
-
|
962
|
+
end
|
914
963
|
|
915
|
-
|
964
|
+
def distance_to_point(x, y)
|
916
965
|
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
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
|
-
|
923
|
-
|
924
|
-
|
971
|
+
return 0 if dist_y == 0 and dist_x == 0
|
972
|
+
distance = Math.hypot( dist_x, dist_y )
|
973
|
+
distance
|
925
974
|
|
926
|
-
|
975
|
+
end
|
927
976
|
|
928
|
-
|
929
|
-
|
977
|
+
# enable hooking for performance measurement & debug logging
|
978
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
930
979
|
|
931
|
-
|
980
|
+
end
|
932
981
|
|
933
982
|
end
|
934
983
|
end
|