cutedriver-qt-sut-plugin 2.0.0.20210120165900
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.
- checksums.yaml +7 -0
- data/env.rb +24 -0
- data/installer/extconf.rb +62 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin.rb +23 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/action.rb +157 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +312 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +300 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +214 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +317 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_cpu.rb +145 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_gpu.rb +147 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_mem.rb +142 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/cute_pwr.rb +146 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +192 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +375 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +82 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +214 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fps.rb +189 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +1039 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +767 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +166 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +157 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +112 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +474 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/os.rb +100 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/qt_api_method.rb +148 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +134 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +279 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/settings.rb +302 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +840 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +257 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +117 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/type_text.rb +97 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +97 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +272 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +877 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/action.rb +30 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/configure_command.rb +38 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/drag.rb +44 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/find_object.rb +67 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +44 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/infologger_command.rb +38 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/qt.rb +171 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/tap.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/version.rb +34 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/widget.rb +199 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/agent.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +192 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +53 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +48 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +65 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +57 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +53 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +93 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +53 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +62 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/version.rb +46 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +98 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +200 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +466 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +185 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +69 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +287 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb +77 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +370 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb +79 -0
- data/lib/testability-driver-qt-sut-plugin.rb +24 -0
- data/xml/behaviour/qt.xml +845 -0
- data/xml/defaults/sut_qt.xml +9 -0
- data/xml/keymap/qt.xml +321 -0
- data/xml/keymap/win.xml +174 -0
- data/xml/template/qt.xml +141 -0
- metadata +127 -0
@@ -0,0 +1,214 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of TDriver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyBehaviour
|
21
|
+
|
22
|
+
module QT
|
23
|
+
|
24
|
+
# == description
|
25
|
+
# Fixture specific behaviours
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# QtFixture
|
29
|
+
#
|
30
|
+
# == requires
|
31
|
+
# testability-driver-qt-sut-plugin
|
32
|
+
#
|
33
|
+
# == input_type
|
34
|
+
# *
|
35
|
+
#
|
36
|
+
# == sut_type
|
37
|
+
# qt
|
38
|
+
#
|
39
|
+
# == sut_version
|
40
|
+
# *
|
41
|
+
#
|
42
|
+
# == objects
|
43
|
+
# sut;*
|
44
|
+
#
|
45
|
+
module Fixture
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
# == description
|
50
|
+
# Sends a fixture call to the target. The fixture will be executed either
|
51
|
+
# inside the application process or the qttasserver process (if used for sut).
|
52
|
+
# The fixture will get a pointer to the object to which this call is made to.
|
53
|
+
#
|
54
|
+
#
|
55
|
+
# == arguments
|
56
|
+
# fixture_name
|
57
|
+
# String
|
58
|
+
# description: Name of the fixture. Fixture mapping is in the tdriver_parameters.xml file.
|
59
|
+
# example: tasfixture
|
60
|
+
#
|
61
|
+
# fixture_method
|
62
|
+
# String
|
63
|
+
# description: Name of the action to be executed in the fixture.
|
64
|
+
# example: callApi
|
65
|
+
#
|
66
|
+
# parameters_hash
|
67
|
+
# Hash
|
68
|
+
# description: Optional hash of pareters passed on to the fixture.
|
69
|
+
# example: {:name => 'John'}
|
70
|
+
#
|
71
|
+
# == returns
|
72
|
+
# QString
|
73
|
+
# description: The value returned but the fixture.
|
74
|
+
# example: OK
|
75
|
+
#
|
76
|
+
# == exceptions
|
77
|
+
# ArgumentError
|
78
|
+
# description: In case the given parameters are not valid.
|
79
|
+
#
|
80
|
+
def fixture( fixture_name, fixture_method, parameters_hash = {} )
|
81
|
+
|
82
|
+
# verify that arguments were given in correct format
|
83
|
+
fixture_name.check_type String, 'wrong argument type $1 for fixture name (expected $2)'
|
84
|
+
|
85
|
+
fixture_method.check_type String, 'wrong argument type $1 for fixture method name (expected $2)'
|
86
|
+
|
87
|
+
parameters_hash.check_type Hash, 'wrong argument type $1 for fixture parameters (expected $2)'
|
88
|
+
|
89
|
+
result = nil
|
90
|
+
|
91
|
+
begin
|
92
|
+
|
93
|
+
# default parameters
|
94
|
+
params = { :name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => false }
|
95
|
+
|
96
|
+
# for sut send the fixture command to qttasserver (appid nil)
|
97
|
+
if sut?
|
98
|
+
|
99
|
+
params.merge!( :application_id => nil, :object_id => @id, :object_type => :Application )
|
100
|
+
|
101
|
+
else
|
102
|
+
|
103
|
+
params.merge!( :application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).to_sym )
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
result = @sut.execute_command( MobyCommand::Fixture.new( params ) )
|
108
|
+
|
109
|
+
rescue
|
110
|
+
|
111
|
+
$logger.behaviour "FAIL;Failed when calling fixture with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
|
112
|
+
|
113
|
+
raise MobyBase::BehaviourError.new( "Fixture", "Failed to execute fixture name #{ fixture_name.inspect } method #{ fixture_method.inspect }" )
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
$logger.behaviour "PASS;The fixture command was executed successfully with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
|
118
|
+
|
119
|
+
result
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
# == description
|
124
|
+
# Sends a fixture call to the target. The fixture will be executed either
|
125
|
+
# inside the application process or the qttasserver process (if used for sut).
|
126
|
+
# The fixture will get a pointer to the object to which this call is made to.
|
127
|
+
# This version of the fixture call is asynchronous. This means that no return value
|
128
|
+
# is returned.
|
129
|
+
#
|
130
|
+
#
|
131
|
+
# == arguments
|
132
|
+
# fixture_name
|
133
|
+
# String
|
134
|
+
# description: Name of the fixture. Fixture mapping is in the tdriver_parameters.xml file
|
135
|
+
# example: tasfixture
|
136
|
+
#
|
137
|
+
# fixture_method
|
138
|
+
# String
|
139
|
+
# description: Name of the action to be executed in the fixture
|
140
|
+
# example: callApi
|
141
|
+
#
|
142
|
+
# parameters_hash
|
143
|
+
# Hash
|
144
|
+
# description: Optional hash of parameters passed on to the fixture
|
145
|
+
# example: {:name => 'John'}
|
146
|
+
#
|
147
|
+
# == returns
|
148
|
+
# NilClass
|
149
|
+
# description: -
|
150
|
+
# example: -
|
151
|
+
#
|
152
|
+
# == exceptions
|
153
|
+
# ArgumentError
|
154
|
+
# description: In case the given parameters are not valid.
|
155
|
+
#
|
156
|
+
def async_fixture( fixture_name, fixture_method, parameters_hash = {} )
|
157
|
+
|
158
|
+
# verify that arguments were given in correct format
|
159
|
+
fixture_name.check_type String, 'wrong argument type $1 for fixture name (expected $2)'
|
160
|
+
|
161
|
+
fixture_method.check_type String, 'wrong argument type $1 for fixture method name (expected $2)'
|
162
|
+
|
163
|
+
parameters_hash.check_type Hash, 'wrong argument type $1 for fixture parameters (expected $2)'
|
164
|
+
|
165
|
+
result = nil
|
166
|
+
|
167
|
+
begin
|
168
|
+
|
169
|
+
# default parameters
|
170
|
+
params = { :name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => true }
|
171
|
+
|
172
|
+
# for sut send the fixture command to qttasserver (appid nil)
|
173
|
+
if sut?
|
174
|
+
|
175
|
+
params.merge!( :application_id => nil, :object_id => @id, :object_type => :Application )
|
176
|
+
|
177
|
+
else
|
178
|
+
|
179
|
+
params.merge!( :application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).to_sym )
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
result = @sut.execute_command( MobyCommand::Fixture.new( params ) )
|
184
|
+
|
185
|
+
rescue
|
186
|
+
|
187
|
+
$logger.behaviour "FAIL;Failed when calling async_fixture with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
|
188
|
+
|
189
|
+
raise MobyBase::BehaviourError.new("Fixture", "Failed to execute async_fixture name #{ fixture_name.inspect } method #{ fixture_method.inspect }")
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
$logger.behaviour "PASS;The fixture command was executed successfully with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
|
194
|
+
|
195
|
+
result
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
# == nodoc
|
200
|
+
def fixtures
|
201
|
+
|
202
|
+
# pass call to fixtures service object
|
203
|
+
TDriver::FixtureService.new( :target => self )
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
# enable hooking for performance measurement & debug logging
|
208
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
209
|
+
|
210
|
+
end # Fixture
|
211
|
+
|
212
|
+
end # QT
|
213
|
+
|
214
|
+
end # MobyBehaviour
|
@@ -0,0 +1,189 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of TDriver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyBehaviour
|
21
|
+
|
22
|
+
module QT
|
23
|
+
|
24
|
+
# == description
|
25
|
+
#
|
26
|
+
# == behaviour
|
27
|
+
# QtFps
|
28
|
+
#
|
29
|
+
# == requires
|
30
|
+
# testability-driver-qt-sut-plugin
|
31
|
+
#
|
32
|
+
# == input_type
|
33
|
+
# *
|
34
|
+
#
|
35
|
+
# == sut_type
|
36
|
+
# QT
|
37
|
+
#
|
38
|
+
# == sut_version
|
39
|
+
# *
|
40
|
+
#
|
41
|
+
# == objects
|
42
|
+
# *
|
43
|
+
#
|
44
|
+
module Fps
|
45
|
+
|
46
|
+
include MobyBehaviour::QT::Behaviour
|
47
|
+
|
48
|
+
# == description
|
49
|
+
# Start collecting frames per second data for the object.
|
50
|
+
# Testability driver qttas package provides a fixture for measuring fps of a component.
|
51
|
+
# This behaviour is a wrapper for the fixture.
|
52
|
+
# The fixture intercepts paint events send to the target of the fps measurement and simply
|
53
|
+
# counts how many occur during each second. The way this is done differs a bit depending
|
54
|
+
# on the target object. For normal QWidgets the fps values are measured to the target
|
55
|
+
# object direclty. QGraphicsItem based objects this is not the case. For QGrapchisItem
|
56
|
+
# based objects the system determines the QGraphicsView the item is in and starts to
|
57
|
+
# listen to paint evets send to the viewport of the QGraphicsView. If you measure the
|
58
|
+
# QGraphicsView object directly the measurement is also done for the viewport.
|
59
|
+
#
|
60
|
+
# == returns
|
61
|
+
# NilClass
|
62
|
+
# description: -
|
63
|
+
# example: -
|
64
|
+
#
|
65
|
+
# == exceptions
|
66
|
+
# ArgumentError
|
67
|
+
# description: In case the given parameters are not valid.
|
68
|
+
#
|
69
|
+
def start_fps_measurement
|
70
|
+
|
71
|
+
begin
|
72
|
+
|
73
|
+
fixture('fps', 'startFps')
|
74
|
+
|
75
|
+
rescue Exception
|
76
|
+
|
77
|
+
$logger.behaviour "FAIL;Failed start_fps_measurement.;#{ identity };start_fps_measurement;"
|
78
|
+
raise
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
$logger.behaviour "PASS;Operation start_fps_measurement executed successfully.;#{ identity };start_fps_measurement;"
|
83
|
+
|
84
|
+
nil
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
# == description
|
89
|
+
# Stop collecting frames per second data for the object.
|
90
|
+
#
|
91
|
+
# == returns
|
92
|
+
# Array
|
93
|
+
# description: An Array of fps entries. Each entry is a hash table that contains the value and time stamp {value => 12, time_stamp => 06:49:42.259}
|
94
|
+
# example: [{value => 12, time_stamp => 06:49:42.259}, {value => 11, time_stamp => 06:49:43.259}]
|
95
|
+
#
|
96
|
+
# == exceptions
|
97
|
+
# ArgumentError
|
98
|
+
# description: In case the given parameters are not valid.
|
99
|
+
#
|
100
|
+
def stop_fps_measurement
|
101
|
+
|
102
|
+
begin
|
103
|
+
|
104
|
+
results = parse_results( fixture('fps', 'stopFps') )
|
105
|
+
|
106
|
+
rescue Exception
|
107
|
+
|
108
|
+
$logger.behaviour "FAIL;Failed stop_fps_measurement.;#{ identity };stop_fps_measurement;"
|
109
|
+
|
110
|
+
raise
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
$logger.behaviour "PASS;Operation stop_fps_measurement executed successfully.;#{ identity };stop_fps_measurement;"
|
115
|
+
|
116
|
+
results
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
# == description
|
121
|
+
# Collect the stored fps results from the target. This will not stop the measurement but it will restart it
|
122
|
+
# so the results returned will not be included in the next data request. Measuring fps will have a small impact
|
123
|
+
# on the software performance and memory consumption so it is recommended that the collection is stopped if no longer
|
124
|
+
# needed.
|
125
|
+
#
|
126
|
+
# == returns
|
127
|
+
# Array
|
128
|
+
# description: An Array of fps entries. Each entry is a hash table that contains the
|
129
|
+
# value and time stamp {value => 12, time_stamp => 06:49:42.259}
|
130
|
+
# example: [{value => 12, time_stamp => 06:49:42.259}, {value => 11, time_stamp => 06:49:43.259}]
|
131
|
+
#
|
132
|
+
# == exceptions
|
133
|
+
# ArgumentError
|
134
|
+
# description: In case the given parameters are not valid.
|
135
|
+
#
|
136
|
+
def collect_fps_data
|
137
|
+
|
138
|
+
begin
|
139
|
+
|
140
|
+
results = parse_results( fixture('fps', 'collectData') )
|
141
|
+
|
142
|
+
rescue Exception
|
143
|
+
|
144
|
+
$logger.behaviour "FAIL;Failed collect_fps_data.;#{ identity };collect_fps_data;"
|
145
|
+
|
146
|
+
raise
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
$logger.behaviour "PASS;Operation collect_fps_data executed successfully.;#{ identity };collect_fps_data;"
|
151
|
+
|
152
|
+
results
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def parse_results( results_xml )
|
159
|
+
|
160
|
+
state_object = @sut.state_object( results_xml )
|
161
|
+
|
162
|
+
results = []
|
163
|
+
|
164
|
+
count = state_object.results.attribute('count').to_i
|
165
|
+
|
166
|
+
for i in 0...count
|
167
|
+
|
168
|
+
value = state_object.fps(:id => i.to_s).attribute('frameCount').to_i
|
169
|
+
|
170
|
+
time_stamp = state_object.fps(:id => i.to_s).attribute('timeStamp')
|
171
|
+
|
172
|
+
entry = {:value => value, :time_stamp => time_stamp}
|
173
|
+
|
174
|
+
results.push(entry)
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
results
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
# enable hooking for performance measurement & debug logging
|
183
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
184
|
+
|
185
|
+
end # Fps
|
186
|
+
|
187
|
+
end # QT
|
188
|
+
|
189
|
+
end # MobyBase
|
@@ -0,0 +1,1039 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of TDriver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyBehaviour
|
21
|
+
|
22
|
+
module QT
|
23
|
+
|
24
|
+
# == description
|
25
|
+
# Gesture behaviour methods are used to do different gestures with UI objects. Various methods exist for different speeds, targets and other options.
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# QtGesture
|
29
|
+
#
|
30
|
+
# == requires
|
31
|
+
# testability-driver-qt-sut-plugin
|
32
|
+
#
|
33
|
+
# == input_type
|
34
|
+
# *
|
35
|
+
#
|
36
|
+
# == sut_type
|
37
|
+
# QT
|
38
|
+
#
|
39
|
+
# == sut_version
|
40
|
+
# *
|
41
|
+
#
|
42
|
+
# == objects
|
43
|
+
# *
|
44
|
+
#
|
45
|
+
module Gesture
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
# == description
|
50
|
+
# Flick the screen at the location of the object (touch the object and do a flick gesture).
|
51
|
+
# Speed and distance of the flick are defined in the tdriver_parameters under the sut used.
|
52
|
+
# By default a flick is a fast gesture.
|
53
|
+
# For custom values see the gesture method.
|
54
|
+
#
|
55
|
+
# == arguments
|
56
|
+
# direction
|
57
|
+
# Symbol
|
58
|
+
# description: Direction of the flick. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
59
|
+
# example: :Left
|
60
|
+
# Integer
|
61
|
+
# description: Direction of the flick as degrees with 0 being up and 90 right.
|
62
|
+
# example: 270
|
63
|
+
#
|
64
|
+
# button
|
65
|
+
# Symbol
|
66
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
67
|
+
# example: :Middle
|
68
|
+
# default: :Left
|
69
|
+
#
|
70
|
+
# optional_params
|
71
|
+
# Hash
|
72
|
+
# description: The only optional argument supported by flick is :use_tap_screen.
|
73
|
+
# example: { :use_tap_screen => 'true' }
|
74
|
+
# default: { :use_tap_screen => 'false' }
|
75
|
+
#
|
76
|
+
# == returns
|
77
|
+
# NilClass
|
78
|
+
# description: Always returns nil
|
79
|
+
# example: nil
|
80
|
+
#
|
81
|
+
# == exceptions
|
82
|
+
# ArgumentError
|
83
|
+
# description: One of the arguments is not valid
|
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
|
93
|
+
|
94
|
+
optional_params[:useTapScreen] = use_tap_screen
|
95
|
+
|
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}
|
100
|
+
|
101
|
+
params.merge!(optional_params)
|
102
|
+
|
103
|
+
do_gesture(params)
|
104
|
+
do_sleep(speed)
|
105
|
+
|
106
|
+
rescue Exception => e
|
107
|
+
|
108
|
+
$logger.behaviour "FAIL;Failed flick with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
|
109
|
+
raise e
|
110
|
+
end
|
111
|
+
|
112
|
+
$logger.behaviour "PASS;Operation flick executed successfully with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
|
113
|
+
|
114
|
+
self
|
115
|
+
end
|
116
|
+
|
117
|
+
# == description
|
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.
|
119
|
+
# Speed and distance of the flick are defined in the tdriver_parameters under the sut used.
|
120
|
+
# By default a flick is a fast gesture.
|
121
|
+
# For custom values see the gesture_to method.
|
122
|
+
#
|
123
|
+
# == arguments
|
124
|
+
# x
|
125
|
+
# Integer
|
126
|
+
# description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
127
|
+
# example: 300
|
128
|
+
#
|
129
|
+
# y
|
130
|
+
# Integer
|
131
|
+
# description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
132
|
+
# example: 300
|
133
|
+
#
|
134
|
+
# button
|
135
|
+
# Symbol
|
136
|
+
# description: The mouse button pressed while the flick is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
137
|
+
# example: :Middle
|
138
|
+
# default: :Left
|
139
|
+
#
|
140
|
+
# optional_params
|
141
|
+
# Hash
|
142
|
+
# description: The only optional argument supported by flick_to is :use_tap_screen.
|
143
|
+
# example: { :use_tap_screen => 'true' }
|
144
|
+
# default: { :use_tap_screen => 'false' }
|
145
|
+
#
|
146
|
+
# == returns
|
147
|
+
# NilClass
|
148
|
+
# description: Always returns nil
|
149
|
+
# example: nil
|
150
|
+
#
|
151
|
+
# == exceptions
|
152
|
+
# ArgumentError
|
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
|
165
|
+
|
166
|
+
speed = calculate_speed( sut_parameters[ :gesture_flick_distance ], sut_parameters[ :gesture_flick_speed ] )
|
167
|
+
|
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)
|
181
|
+
|
182
|
+
rescue Exception => e
|
183
|
+
|
184
|
+
$logger.behaviour "FAIL;Failed flick_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
185
|
+
raise e
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
$logger.behaviour "PASS;Operation flick_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
190
|
+
|
191
|
+
self
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
|
196
|
+
# == description
|
197
|
+
# Perform a gesture with the object
|
198
|
+
#
|
199
|
+
# == arguments
|
200
|
+
# direction
|
201
|
+
# Symbol
|
202
|
+
# description: Direction of the gesture. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
203
|
+
# example: :Left
|
204
|
+
#
|
205
|
+
# Integer
|
206
|
+
# description: Direction of the gesture as degrees with 0 being up and 90 right.
|
207
|
+
# example: 270
|
208
|
+
#
|
209
|
+
# speed
|
210
|
+
# Numeric
|
211
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
212
|
+
# example: 1
|
213
|
+
#
|
214
|
+
# distance
|
215
|
+
# Integer
|
216
|
+
# description: Number of pixels that the object is to be moved in the gesture.
|
217
|
+
# example: 100
|
218
|
+
#
|
219
|
+
# optional_params
|
220
|
+
# Hash
|
221
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
222
|
+
# example: { :button => :Right }
|
223
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
224
|
+
#
|
225
|
+
# == tables
|
226
|
+
# directions_table
|
227
|
+
# title: Direction symbols table
|
228
|
+
# |Symbol|
|
229
|
+
# |:Left|
|
230
|
+
# |:Right|
|
231
|
+
# |:Up|
|
232
|
+
# |:Down|
|
233
|
+
#
|
234
|
+
# buttons_table
|
235
|
+
# title: Mouse button symbols table
|
236
|
+
# |Symbol|Description|
|
237
|
+
# |:Left|Simulate left mouse button|
|
238
|
+
# |:Middle|Simulate middle mouse button|
|
239
|
+
# |:Right|Simulate right mouse button|
|
240
|
+
# |:NoButton|Do not simulate any mouse button|
|
241
|
+
#
|
242
|
+
# == returns
|
243
|
+
# NilClass
|
244
|
+
# description: Always returns nil
|
245
|
+
# example: nil
|
246
|
+
#
|
247
|
+
# == exceptions
|
248
|
+
# ArgumentError
|
249
|
+
# description: One of the arguments is not valid
|
250
|
+
def gesture( direction, speed, distance, optional_params = {:button => :Left, :isDrag => false})
|
251
|
+
|
252
|
+
begin
|
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
|
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' ]
|
263
|
+
|
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)
|
274
|
+
|
275
|
+
rescue Exception => e
|
276
|
+
|
277
|
+
$logger.behaviour "FAIL;Failed gesture with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
|
278
|
+
raise e
|
279
|
+
end
|
280
|
+
|
281
|
+
$logger.behaviour "PASS;Operation gesture executed successfully with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
|
282
|
+
|
283
|
+
self
|
284
|
+
end
|
285
|
+
|
286
|
+
# == description
|
287
|
+
# Perform a gesture with the object, ending the gesture at the specified point.
|
288
|
+
#
|
289
|
+
# == arguments
|
290
|
+
# x
|
291
|
+
# Integer
|
292
|
+
# description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
293
|
+
# example: 300
|
294
|
+
#
|
295
|
+
# y
|
296
|
+
# Integer
|
297
|
+
# description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
298
|
+
# example: 300
|
299
|
+
#
|
300
|
+
# speed
|
301
|
+
# Numeric
|
302
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
303
|
+
# example: 1
|
304
|
+
#
|
305
|
+
# optional_params
|
306
|
+
# Hash
|
307
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
308
|
+
# example: { :button => :Right }
|
309
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
310
|
+
#
|
311
|
+
# == returns
|
312
|
+
# NilClass
|
313
|
+
# description: Always returns nil
|
314
|
+
# example: nil
|
315
|
+
#
|
316
|
+
# == exceptions
|
317
|
+
# ArgumentError
|
318
|
+
# description: One of the arguments is not valid
|
319
|
+
def gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false})
|
320
|
+
|
321
|
+
begin
|
322
|
+
|
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
|
327
|
+
end
|
328
|
+
|
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
|
+
raise e
|
355
|
+
end
|
356
|
+
|
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
|
362
|
+
# Perform a gesture with the object, starting the gesture at the specified point inside it.
|
363
|
+
#
|
364
|
+
# == arguments
|
365
|
+
# x
|
366
|
+
# Integer
|
367
|
+
# description: X coordinate of the start point. The coordinate is relative to the object top left corner.
|
368
|
+
# example: 20
|
369
|
+
#
|
370
|
+
# y
|
371
|
+
# Integer
|
372
|
+
# description: Y coordinate of the start point. The coordinate is relative to the object top left corner.
|
373
|
+
# example: 15
|
374
|
+
#
|
375
|
+
# speed
|
376
|
+
# Numeric
|
377
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
378
|
+
# example: 1
|
379
|
+
#
|
380
|
+
# direction
|
381
|
+
# Symbol
|
382
|
+
# description: Direction of the gesture. Please see this table for valid direction symbols.
|
383
|
+
# example: :Left
|
384
|
+
#
|
385
|
+
# Integer
|
386
|
+
# description: Direction of the gesture as degrees with 0 being up and 90 right.
|
387
|
+
# example: 270
|
388
|
+
#
|
389
|
+
# distance
|
390
|
+
# Integer
|
391
|
+
# description: Number of pixels that the object is to be moved in the gesture.
|
392
|
+
# example: 100
|
393
|
+
#
|
394
|
+
# optional_params
|
395
|
+
# Hash
|
396
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
397
|
+
# example: { :button => :Right }
|
398
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
399
|
+
#
|
400
|
+
# == returns
|
401
|
+
# NilClass
|
402
|
+
# description: Always returns nil
|
403
|
+
# example: nil
|
404
|
+
#
|
405
|
+
# == exceptions
|
406
|
+
# ArgumentError
|
407
|
+
# description: One of the arguments is not valid, or the initial point is outside the target object.
|
408
|
+
#
|
409
|
+
def gesture_from(x, y, speed, distance, direction, optional_params = {:button => :Left, :isDrag => false})
|
410
|
+
|
411
|
+
begin
|
412
|
+
|
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
|
418
|
+
|
419
|
+
params = {:gesture_type => :MouseGestureFromCoordinates, :x => x_absolute, :y => y_absolute, :speed => speed, :distance => distance, :direction => direction}
|
420
|
+
|
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
|
+
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
|
432
|
+
|
433
|
+
# == description
|
434
|
+
# Perform a gesture with the object, ending the gesture at the center of another object.
|
435
|
+
#
|
436
|
+
# == arguments
|
437
|
+
# target_object
|
438
|
+
# TestObject
|
439
|
+
# description: The object where the gesture should end.
|
440
|
+
# example: @app.Node
|
441
|
+
#
|
442
|
+
# duration
|
443
|
+
# Numeric
|
444
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
445
|
+
# example: 1
|
446
|
+
#
|
447
|
+
# optional_params
|
448
|
+
# Hash
|
449
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
450
|
+
# example: { :button => :Right }
|
451
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
452
|
+
#
|
453
|
+
# == returns
|
454
|
+
# NilClass
|
455
|
+
# description: Always returns nil
|
456
|
+
# example: nil
|
457
|
+
#
|
458
|
+
# == exceptions
|
459
|
+
# ArgumentError
|
460
|
+
# description: One of the arguments is not valid
|
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
|
478
|
+
|
479
|
+
begin
|
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
|
486
|
+
|
487
|
+
optional_params[:useTapScreen] = use_tap_screen
|
488
|
+
|
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)
|
495
|
+
|
496
|
+
rescue Exception => e
|
497
|
+
|
498
|
+
$logger.behaviour "FAIL;Failed gesture_to_object with button.;#{identity};drag;"
|
499
|
+
raise e
|
500
|
+
|
501
|
+
end
|
502
|
+
|
503
|
+
$logger.behaviour "PASS;Operation gesture_to_object executed successfully with button.;#{identity};drag;"
|
504
|
+
|
505
|
+
self
|
506
|
+
|
507
|
+
end
|
508
|
+
|
509
|
+
# == description
|
510
|
+
# Perform a gesture following a track of points.
|
511
|
+
#
|
512
|
+
# == arguments
|
513
|
+
# points
|
514
|
+
# Array
|
515
|
+
# description: Each element of this Array defines a point of the gesture as a Hash. Three keys with Integer values are defined for a point: the coordinate as "x" and "y" keys and "interval" as seconds (Note that this is likely a very short time, i.e. fraction of a second).
|
516
|
+
# example: [{"x" => 200,"y" => 100, "interval" => 0.15},{"x" => 200,"y" => 110, "interval" => 0.30}]
|
517
|
+
#
|
518
|
+
# duration
|
519
|
+
# Numeric
|
520
|
+
# description: Duration of the gesture in seconds. The value may be an integer or a fractional value as a floating point number.
|
521
|
+
# example: 1
|
522
|
+
#
|
523
|
+
# mouse_details
|
524
|
+
# Hash
|
525
|
+
# description: Mouse usage details can be defined by setting the :press, :release and :isDrag keys to true or false. Valid values for the :button key are described in [link="#buttons_table"]the buttons table[/link].
|
526
|
+
# example: { :press => true, :release => true, :button => :Right, :isDrag => false}
|
527
|
+
# default: { :press => true, :release => true, :button => :Left, :isDrag => true}
|
528
|
+
#
|
529
|
+
# optional_params
|
530
|
+
# Hash
|
531
|
+
# description: This method only supports the :use_tap_screen optional parameter.
|
532
|
+
# example: { :use_tap_screen => true }
|
533
|
+
# default: { :use_tap_screen => false }
|
534
|
+
#
|
535
|
+
# == returns
|
536
|
+
# NilClass
|
537
|
+
# description: Always returns nil
|
538
|
+
# example: nil
|
539
|
+
#
|
540
|
+
# == exceptions
|
541
|
+
# ArgumentError
|
542
|
+
# description: One of the arguments is not valid
|
543
|
+
def gesture_points( points, duration, mouse_details = {}, optional_params = {} )
|
544
|
+
|
545
|
+
begin
|
546
|
+
|
547
|
+
# verify that "duration" argument type is correct
|
548
|
+
duration.check_type [ Fixnum, Float ], 'wrong argument type $1 for duration value (expected $2)'
|
549
|
+
|
550
|
+
# verify that "points" argument type is correct
|
551
|
+
points.check_type Array, 'wrong argument type $1 for gesture points array (expected $2)'
|
552
|
+
|
553
|
+
# verify that "mouse_details" argument type is correct
|
554
|
+
mouse_details.check_type Hash, 'wrong argument type $1 for mouse details hash (expected $2)'
|
555
|
+
|
556
|
+
# verify that "optional_params" argument type is correct
|
557
|
+
optional_params.check_type Hash, 'wrong argument type $1 for optional parameters hash (expected $2)'
|
558
|
+
|
559
|
+
# set default values unless given by caller
|
560
|
+
mouse_details.default_values(
|
561
|
+
|
562
|
+
:press => true,
|
563
|
+
:release => true,
|
564
|
+
:button => :Left,
|
565
|
+
:isDrag => true
|
566
|
+
|
567
|
+
)
|
568
|
+
|
569
|
+
# verify that given button is valid
|
570
|
+
mouse_details[ :button ].validate @@_valid_buttons, 'unsupported button $3 for gesture points (expected $2)'
|
571
|
+
|
572
|
+
# initialize command parameters class
|
573
|
+
command = command_params # in qt_behaviour
|
574
|
+
|
575
|
+
# set command name
|
576
|
+
command.command_name( 'MouseGesturePoints' )
|
577
|
+
|
578
|
+
# set command parameters
|
579
|
+
command.command_params(
|
580
|
+
|
581
|
+
{
|
582
|
+
|
583
|
+
'mouseMove' => true,
|
584
|
+
'button' => @@_buttons_map[ mouse_details[ :button ] ],
|
585
|
+
'press' => mouse_details[ :press ].true?,
|
586
|
+
'release' => mouse_details[ :release ].true?,
|
587
|
+
'isDrag' => mouse_details[ :isDrag ].true?,
|
588
|
+
'speed' => ( duration.to_f * 1000 ).to_i,
|
589
|
+
'useTapScreen' => ( optional_params.delete( :use_tap_screen ) || sut_parameters[ :use_tap_screen, false ] ).true?
|
590
|
+
|
591
|
+
}.merge!( optional_params )
|
592
|
+
|
593
|
+
)
|
594
|
+
|
595
|
+
# collect points as string
|
596
|
+
command.command_value(
|
597
|
+
|
598
|
+
points.inject(""){ | result, point |
|
599
|
+
|
600
|
+
result << "#{ point['x'].to_s },#{ point['y'].to_s },#{ (point['interval']*1000).to_i.to_s };"
|
601
|
+
|
602
|
+
}
|
603
|
+
|
604
|
+
)
|
605
|
+
|
606
|
+
# execute the command
|
607
|
+
execute_behavior(optional_params, command)
|
608
|
+
|
609
|
+
# wait until duration is exceeded
|
610
|
+
do_sleep duration.to_f
|
611
|
+
|
612
|
+
rescue
|
613
|
+
|
614
|
+
$logger.behaviour "FAIL;Failed gesture_points with points #{ points.inspect }, duration #{ duration.inspect }, mouse_details #{ mouse_details.inspect }.;#{ identity };gesture_points;"
|
615
|
+
|
616
|
+
raise
|
617
|
+
|
618
|
+
end
|
619
|
+
|
620
|
+
$logger.behaviour "PASS;Operation gesture_points executed successfully with points #{ points.inspect }, duration #{ duration.inspect }, mouse_details #{ mouse_details.inspect }.;#{ identity };gesture_points;"
|
621
|
+
|
622
|
+
self
|
623
|
+
|
624
|
+
end
|
625
|
+
|
626
|
+
# == description
|
627
|
+
# Drag the object for the given distance.
|
628
|
+
# By default a drag is a slow gesture.
|
629
|
+
#
|
630
|
+
# == arguments
|
631
|
+
# direction
|
632
|
+
# Symbol
|
633
|
+
# description: Direction of the drag. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
634
|
+
# example: :Left
|
635
|
+
#
|
636
|
+
# Integer
|
637
|
+
# description: Direction of the drag as degrees with 0 being up and 90 right.
|
638
|
+
# example: 270
|
639
|
+
#
|
640
|
+
# distance
|
641
|
+
# Integer
|
642
|
+
# description: Number of pixels that the object is to be dragged.
|
643
|
+
# example: 100
|
644
|
+
#
|
645
|
+
# button
|
646
|
+
# Symbol
|
647
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
648
|
+
# example: :Right
|
649
|
+
# default: :Left
|
650
|
+
#
|
651
|
+
# optional_params
|
652
|
+
# Hash
|
653
|
+
# description: The only optional argument supported by drag is :use_tap_screen.
|
654
|
+
# example: { :use_tap_screen => 'true' }
|
655
|
+
# default: { :use_tap_screen => 'false' }
|
656
|
+
#
|
657
|
+
# == returns
|
658
|
+
# NilClass
|
659
|
+
# description: Always returns nil
|
660
|
+
# example: nil
|
661
|
+
#
|
662
|
+
# == exceptions
|
663
|
+
# ArgumentError
|
664
|
+
# description: One of the arguments is not valid
|
665
|
+
def drag(direction, distance, button = :Left, optional_params = {})
|
666
|
+
|
667
|
+
begin
|
668
|
+
|
669
|
+
if optional_params[:use_tap_screen].nil?
|
670
|
+
use_tap_screen = sut_parameters[:use_tap_screen, 'false']
|
671
|
+
else
|
672
|
+
use_tap_screen = optional_params[:use_tap_screen].to_s
|
673
|
+
end
|
674
|
+
|
675
|
+
optional_params[:useTapScreen] = use_tap_screen
|
676
|
+
|
677
|
+
speed = calculate_speed( distance, sut_parameters[ :gesture_drag_speed ] )
|
678
|
+
|
679
|
+
params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => true, :button => button}
|
680
|
+
params.merge!(optional_params)
|
681
|
+
do_gesture(params)
|
682
|
+
do_sleep( speed )
|
683
|
+
|
684
|
+
rescue Exception => e
|
685
|
+
|
686
|
+
$logger.behaviour "FAIL;Failed drag with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
|
687
|
+
raise e
|
688
|
+
|
689
|
+
end
|
690
|
+
|
691
|
+
$logger.behaviour "PASS;Operation drag executed successfully with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
|
692
|
+
|
693
|
+
self
|
694
|
+
end
|
695
|
+
|
696
|
+
# == description
|
697
|
+
# Drag the object to the given coordinates.
|
698
|
+
# By default a drag is a slow gesture.
|
699
|
+
#
|
700
|
+
# == arguments
|
701
|
+
# x
|
702
|
+
# Integer
|
703
|
+
# description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
704
|
+
# example: 300
|
705
|
+
#
|
706
|
+
# y
|
707
|
+
# Integer
|
708
|
+
# description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
709
|
+
# example: 300
|
710
|
+
#
|
711
|
+
# button
|
712
|
+
# Symbol
|
713
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
714
|
+
# example: :Right
|
715
|
+
# default: :Left
|
716
|
+
#
|
717
|
+
# optional_params
|
718
|
+
# Hash
|
719
|
+
# description: The only optional argument supported by drag_to is :use_tap_screen.
|
720
|
+
# example: { :use_tap_screen => 'true' }
|
721
|
+
# default: { :use_tap_screen => 'false' }
|
722
|
+
#
|
723
|
+
# == returns
|
724
|
+
# NilClass
|
725
|
+
# description: Always returns nil
|
726
|
+
# example: nil
|
727
|
+
#
|
728
|
+
# == exceptions
|
729
|
+
# ArgumentError
|
730
|
+
# description: One of the arguments is not valid
|
731
|
+
def drag_to( x, y, button = :Left, optional_params= {} )
|
732
|
+
|
733
|
+
begin
|
734
|
+
optional_params.merge!({ :isDrag => true, :button=>button})
|
735
|
+
distance = distance_to_point(x,y)
|
736
|
+
speed = calculate_speed(distance, sut_parameters[:gesture_drag_speed])
|
737
|
+
gesture_to(x, y, speed, optional_params )
|
738
|
+
|
739
|
+
rescue Exception => e
|
740
|
+
$logger.behaviour "FAIL;Failed drag_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
741
|
+
raise e
|
742
|
+
end
|
743
|
+
|
744
|
+
$logger.behaviour "PASS;Operation drag_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
745
|
+
|
746
|
+
self
|
747
|
+
|
748
|
+
end
|
749
|
+
|
750
|
+
# == description
|
751
|
+
# Drag the object to the center of another object.
|
752
|
+
# By default a drag is a slow gesture.
|
753
|
+
#
|
754
|
+
# == arguments
|
755
|
+
# target_object
|
756
|
+
# TestObject
|
757
|
+
# description: The object that this object should be dragged to.
|
758
|
+
# example: @app.Node
|
759
|
+
#
|
760
|
+
# button
|
761
|
+
# Symbol
|
762
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
763
|
+
# example: :Right
|
764
|
+
# default: :Left
|
765
|
+
#
|
766
|
+
# optional_params
|
767
|
+
# Hash
|
768
|
+
# description: The only optional argument supported by drag_to_object is :use_tap_screen.
|
769
|
+
# example: { :use_tap_screen => 'true' }
|
770
|
+
# default: { :use_tap_screen => 'false' }
|
771
|
+
#
|
772
|
+
# == returns
|
773
|
+
# NilClass
|
774
|
+
# description: Always returns nil
|
775
|
+
# example: nil
|
776
|
+
#
|
777
|
+
# == exceptions
|
778
|
+
# ArgumentError
|
779
|
+
# description: One of the arguments is not valid
|
780
|
+
def drag_to_object(target_object, button = :Left, optional_params = {})
|
781
|
+
|
782
|
+
begin
|
783
|
+
|
784
|
+
if optional_params[:use_tap_screen].nil?
|
785
|
+
use_tap_screen = sut_parameters[:use_tap_screen, 'false']
|
786
|
+
else
|
787
|
+
use_tap_screen = optional_params[:use_tap_screen].to_s
|
788
|
+
end
|
789
|
+
|
790
|
+
optional_params[:useTapScreen] = use_tap_screen
|
791
|
+
|
792
|
+
distance = distance_to_point(target_object.object_center_x, target_object.object_center_y)
|
793
|
+
#no drag needed, maybe even attempting to drag to it self
|
794
|
+
return if distance == 0
|
795
|
+
|
796
|
+
speed = calculate_speed(distance, sut_parameters[:gesture_drag_speed])
|
797
|
+
params = {:gesture_type => :MouseGestureTo, :speed => speed, :isDrag => true, :button => button}
|
798
|
+
params[:targetId] = target_object.id
|
799
|
+
params[:targetType] = target_object.attribute('objectType')
|
800
|
+
params.merge!(optional_params)
|
801
|
+
do_gesture(params)
|
802
|
+
do_sleep(speed)
|
803
|
+
|
804
|
+
rescue Exception => e
|
805
|
+
|
806
|
+
$logger.behaviour "FAIL;Failed drag_to_object with button \"#{button.to_s}\".;#{identity};drag;"
|
807
|
+
raise e
|
808
|
+
|
809
|
+
end
|
810
|
+
|
811
|
+
$logger.behaviour "PASS;Operation drag_to_object executed successfully with button \"#{button.to_s}\".;#{identity};drag;"
|
812
|
+
|
813
|
+
self
|
814
|
+
|
815
|
+
end
|
816
|
+
|
817
|
+
# == description
|
818
|
+
# Perform a pointer move starting at the object
|
819
|
+
#
|
820
|
+
# == arguments
|
821
|
+
# direction
|
822
|
+
# Symbol
|
823
|
+
# description: Direction of the move. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
824
|
+
# example: :Left
|
825
|
+
#
|
826
|
+
# Integer
|
827
|
+
# description: Direction of the move as degrees with 0 being up and 90 right.
|
828
|
+
# example: 270
|
829
|
+
#
|
830
|
+
# distance
|
831
|
+
# Integer
|
832
|
+
# description: Number of pixels to be moved.
|
833
|
+
# example: 100
|
834
|
+
#
|
835
|
+
# button
|
836
|
+
# Symbol
|
837
|
+
# description: The mouse button used with the move can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
838
|
+
# example: :Right
|
839
|
+
# default: :Left
|
840
|
+
#
|
841
|
+
# optional_params
|
842
|
+
# Hash
|
843
|
+
# description: The only optional argument supported by drag_to_object is :use_tap_screen.
|
844
|
+
# example: {:use_tap_screen => 'true'}
|
845
|
+
# default: {:use_tap_screen => 'false'}
|
846
|
+
#
|
847
|
+
# == returns
|
848
|
+
# NilClass
|
849
|
+
# description: Always returns nil
|
850
|
+
# example: nil
|
851
|
+
#
|
852
|
+
# == exceptions
|
853
|
+
# ArgumentError
|
854
|
+
# description: One of the arguments is not valid
|
855
|
+
def move(direction, distance, button = :Left, optional_params = {})
|
856
|
+
|
857
|
+
begin
|
858
|
+
|
859
|
+
if optional_params[:use_tap_screen].nil?
|
860
|
+
use_tap_screen = sut_parameters[:use_tap_screen, 'false']
|
861
|
+
else
|
862
|
+
use_tap_screen = optional_params[:use_tap_screen].to_s
|
863
|
+
end
|
864
|
+
|
865
|
+
optional_params[:use_tap_screen].to_s
|
866
|
+
optional_params[:useTapScreen] = use_tap_screen
|
867
|
+
|
868
|
+
speed = calculate_speed( distance, sut_parameters[ :gesture_drag_speed ] )
|
869
|
+
params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => button, :isMove => true}
|
870
|
+
params.merge!(optional_params)
|
871
|
+
do_gesture(params)
|
872
|
+
do_sleep( speed )
|
873
|
+
|
874
|
+
rescue Exception => e
|
875
|
+
|
876
|
+
$logger.behaviour "FAIL;Failed move with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
|
877
|
+
raise e
|
878
|
+
|
879
|
+
end
|
880
|
+
|
881
|
+
$logger.behaviour "PASS;Operation move executed successfully with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
|
882
|
+
|
883
|
+
self
|
884
|
+
|
885
|
+
end
|
886
|
+
|
887
|
+
# == nodoc
|
888
|
+
# utility function for getting the x coordinate of the center of the object, should this be private method?
|
889
|
+
def object_center_x
|
890
|
+
center_x
|
891
|
+
end
|
892
|
+
|
893
|
+
# == nodoc
|
894
|
+
# utility function for getting the y coordinate of the center of the object, should this be private method?
|
895
|
+
def object_center_y
|
896
|
+
center_y
|
897
|
+
end
|
898
|
+
|
899
|
+
private
|
900
|
+
|
901
|
+
# Performs the actual gesture operation.
|
902
|
+
# Verifies that the parameters are correct and send the command
|
903
|
+
# to the sut.
|
904
|
+
# gesture_type: :MouseGesture, :MouseGestureTo, :MouseGestureToCoordinates
|
905
|
+
# params = {:direction => :Up, duration => 2, :distance =>100, :isDrag =>false, :isMove =>false }
|
906
|
+
def do_gesture( params )
|
907
|
+
|
908
|
+
validate_gesture_params!( params )
|
909
|
+
|
910
|
+
object_type = attribute('objectType')
|
911
|
+
|
912
|
+
if object_type == 'Embedded' or object_type == 'Web'
|
913
|
+
params['obj_x'] = center_x
|
914
|
+
params['obj_y'] = center_y
|
915
|
+
params['useCoordinates'] = 'true'
|
916
|
+
end
|
917
|
+
|
918
|
+
command = command_params #in qt_behaviour
|
919
|
+
|
920
|
+
command.command_name( params[:gesture_type].to_s )
|
921
|
+
|
922
|
+
command.command_params( params )
|
923
|
+
|
924
|
+
execute_behavior(params, command)
|
925
|
+
|
926
|
+
end
|
927
|
+
|
928
|
+
def validate_gesture_params!( params )
|
929
|
+
|
930
|
+
#direction
|
931
|
+
if params[:gesture_type] == :MouseGesture or params[:gesture_type] == :MouseGestureFromCoordinates
|
932
|
+
|
933
|
+
if params[:direction].kind_of?(Integer)
|
934
|
+
|
935
|
+
raise ArgumentError.new( "Invalid direction." ) unless 0 <= params[:direction] and params[:direction] <= 360
|
936
|
+
|
937
|
+
else
|
938
|
+
|
939
|
+
raise ArgumentError.new( "Invalid direction." ) unless @@_valid_directions.include?(params[:direction])
|
940
|
+
|
941
|
+
params[:direction] = @@_direction_map[params[:direction]]
|
942
|
+
|
943
|
+
end
|
944
|
+
|
945
|
+
#distance
|
946
|
+
params[:distance] = params[:distance].to_i unless params[:distance].kind_of?(Integer)
|
947
|
+
|
948
|
+
raise ArgumentError.new( "Distance must be an integer and greater than zero." ) unless params[:distance] > 0
|
949
|
+
|
950
|
+
elsif params[:gesture_type] == :MouseGestureTo
|
951
|
+
|
952
|
+
raise ArgumentError.new("targetId and targetType must be defined.") unless params.has_key?(:targetId) and params.has_key?(:targetType)
|
953
|
+
|
954
|
+
end
|
955
|
+
|
956
|
+
if params[:gesture_type] == :MouseGestureToCoordinates or params[:gesture_type] == :MouseGestureFromCoordinates
|
957
|
+
|
958
|
+
raise ArgumentError.new("X and Y must be integers.") unless params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
|
959
|
+
|
960
|
+
end
|
961
|
+
|
962
|
+
#duration/speed
|
963
|
+
params[:speed] = params[:speed].to_f unless params[:speed].kind_of?( Numeric )
|
964
|
+
|
965
|
+
raise ArgumentError.new( "Duration must be a number and greated than zero, was:" + params[:speed].to_s) unless params[:speed] > 0
|
966
|
+
|
967
|
+
params[:speed] = ( params[ :speed ].to_f * 1000 ).to_i
|
968
|
+
|
969
|
+
#mouseMove true always
|
970
|
+
params[:mouseMove] = true
|
971
|
+
|
972
|
+
params[:button] = :Left unless params[:button]
|
973
|
+
|
974
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(params[:button])
|
975
|
+
|
976
|
+
params[:button] = @@_buttons_map[params[:button]]
|
977
|
+
|
978
|
+
if params[:isMove] == true
|
979
|
+
|
980
|
+
params[:press] = 'false'
|
981
|
+
|
982
|
+
params[:release] = 'false'
|
983
|
+
|
984
|
+
end
|
985
|
+
|
986
|
+
end
|
987
|
+
|
988
|
+
def do_sleep( time )
|
989
|
+
|
990
|
+
if sut_parameters[ :sleep_disabled, nil ] != true
|
991
|
+
|
992
|
+
time = time.to_f * 1.3
|
993
|
+
|
994
|
+
#for flicks the duration of the gesture is short but animation (scroll etc..) may not
|
995
|
+
#so wait at least one second
|
996
|
+
time = 1 if time < 1
|
997
|
+
|
998
|
+
sleep time
|
999
|
+
|
1000
|
+
else
|
1001
|
+
|
1002
|
+
# store the biggest value which will be used in multitouch situations to sleep
|
1003
|
+
sut_parameters[ :skipped_sleep_time ] = time if time > sut_parameters[ :skipped_sleep_time, 0 ]
|
1004
|
+
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
def calculate_speed( distance, speed )
|
1010
|
+
|
1011
|
+
distance.to_f / speed.to_f
|
1012
|
+
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
def distance_to_point( x, y )
|
1016
|
+
|
1017
|
+
dist_x = x.to_i - center_x.to_i
|
1018
|
+
|
1019
|
+
dist_y = y.to_i - center_y.to_i
|
1020
|
+
|
1021
|
+
unless dist_y == 0 && dist_x == 0
|
1022
|
+
|
1023
|
+
Math.hypot( dist_x, dist_y )
|
1024
|
+
|
1025
|
+
else
|
1026
|
+
|
1027
|
+
0
|
1028
|
+
|
1029
|
+
end
|
1030
|
+
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
# enable hooking for performance measurement & debug logging
|
1034
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
1035
|
+
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
end
|
1039
|
+
end
|