cutedriver-qt-sut-plugin 2.0.0.20210120165900
Sign up to get free protection for your applications and to get access to all the features.
- 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,97 @@
|
|
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
|
+
# ViewItem specific behaviours
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# QtViewItem
|
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
|
+
# ItemData;QTreeWidgetItem;QListWidgetItem;QTableWidgetItem
|
44
|
+
#
|
45
|
+
module ViewItem
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
# == description
|
50
|
+
# Selects an item from a list that uses qt view model system (e.g. QTreeView)
|
51
|
+
# == returns
|
52
|
+
# NilClass
|
53
|
+
# description: -
|
54
|
+
# example: -
|
55
|
+
def select
|
56
|
+
|
57
|
+
ret = nil
|
58
|
+
|
59
|
+
begin
|
60
|
+
|
61
|
+
button = :Left
|
62
|
+
command = MobyCommand::WidgetCommand.new
|
63
|
+
command.set_object_id(attribute('viewPort'))
|
64
|
+
command.application_id(get_application_id)
|
65
|
+
command.object_type(:Standard)
|
66
|
+
command.command_name('Tap')
|
67
|
+
command.set_event_type(sut_parameters[ :event_type, "0" ])
|
68
|
+
|
69
|
+
mouse_move = @sut.parameter[:in_tap_move_pointer]
|
70
|
+
mouse_move = 'false' unless mouse_move
|
71
|
+
|
72
|
+
params = {'x'=>center_x, 'y' => center_y, 'count' => 1, 'button' => @@_buttons_map[button], 'mouseMove'=>mouse_move, 'useCoordinates' => 'true'}
|
73
|
+
|
74
|
+
command.set_event_type(sut_parameters[ :event_type, "0" ])
|
75
|
+
|
76
|
+
command.command_params(params)
|
77
|
+
@sut.execute_command(command)
|
78
|
+
|
79
|
+
rescue Exception => e
|
80
|
+
|
81
|
+
$logger.behaviour "FAIL;Failed select"#{identity};drag;"
|
82
|
+
raise e
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
$logger.behaviour "PASS;Operation select executed successfully"#{identity};drag;"
|
87
|
+
ret
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
# enable hooking for performance measurement & debug logging
|
92
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,272 @@
|
|
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
|
+
# Webkit specific behaviours
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# QtWebkit
|
29
|
+
#
|
30
|
+
# == requires
|
31
|
+
# testability-driver-qt-sut-plugin
|
32
|
+
#
|
33
|
+
# == input_type
|
34
|
+
# *
|
35
|
+
#
|
36
|
+
# == sut_type
|
37
|
+
# QT;S60QT
|
38
|
+
#
|
39
|
+
# == sut_version
|
40
|
+
# *
|
41
|
+
#
|
42
|
+
# == objects
|
43
|
+
# *
|
44
|
+
#
|
45
|
+
module Webkit
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
# == nodoc
|
50
|
+
# == description
|
51
|
+
# Send javascript to target object on the screen
|
52
|
+
# == params
|
53
|
+
# java_script::( )java script to be executed to target object
|
54
|
+
# == returns
|
55
|
+
# == raises
|
56
|
+
# TestObjectNotFoundError:: If a graphics item is not visible on screen
|
57
|
+
# ArgumentError:: If an invalid button type is given
|
58
|
+
# ArgumentError:: If coordinates are outside of the object
|
59
|
+
# === examples
|
60
|
+
# @object.execute_javascript_query
|
61
|
+
def execute_javascript_query(java_script, locator_query = nil, index = -1, webframe_id = 0)
|
62
|
+
|
63
|
+
returnValue = ""
|
64
|
+
|
65
|
+
begin
|
66
|
+
|
67
|
+
command = command_params #in qt_behaviour
|
68
|
+
=begin
|
69
|
+
if(locator_query == nil)
|
70
|
+
command.command_name('ExecuteJavaScriptOnQWebFrame')
|
71
|
+
locator_query=""
|
72
|
+
else
|
73
|
+
command.command_name('ExecuteJavaScriptOnWebElement')
|
74
|
+
end
|
75
|
+
=end
|
76
|
+
|
77
|
+
if type != "QWebFrame"
|
78
|
+
command.command_name('ExecuteJavaScriptOnWebElement')
|
79
|
+
webframe_id = attribute('webFrame') if webframe_id.to_s == "0"
|
80
|
+
else
|
81
|
+
command.command_name('ExecuteJavaScriptOnQWebFrame')
|
82
|
+
end
|
83
|
+
|
84
|
+
command.service( 'webkitCommand' )
|
85
|
+
params = {
|
86
|
+
'java_script' => java_script,
|
87
|
+
'locator_query' => locator_query,
|
88
|
+
'index' => index.to_s,
|
89
|
+
'elementId' => @id.to_s,
|
90
|
+
'webframe_id' => webframe_id.to_s
|
91
|
+
}
|
92
|
+
|
93
|
+
command.command_params( params )
|
94
|
+
|
95
|
+
returnValue = @sut.execute_command( command )
|
96
|
+
|
97
|
+
rescue Exception => e
|
98
|
+
|
99
|
+
$logger.behaviour "FAIL;Failed send javascript with execute_javascript \"#{java_script}\""
|
100
|
+
raise e
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
$logger.behaviour "PASS;Operation send javascript executed successfully with execute_javascript \"#{java_script}\""
|
105
|
+
|
106
|
+
returnValue
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
# == description
|
111
|
+
# Executes java script on the target test object
|
112
|
+
#
|
113
|
+
# == arguments
|
114
|
+
# java_script
|
115
|
+
# String
|
116
|
+
# description: Script to be executed to target object
|
117
|
+
# example: "this.onclick();"
|
118
|
+
#
|
119
|
+
# == returns
|
120
|
+
# MobyBase::TestObject
|
121
|
+
# description: Target test object
|
122
|
+
# example: -
|
123
|
+
#
|
124
|
+
# == raises
|
125
|
+
# RuntimeError
|
126
|
+
# description: When executing JavaScript to QWebFrame: QWebPage not found.
|
127
|
+
#
|
128
|
+
# RuntimeError
|
129
|
+
# description: When executing JavaScript to QWebFrame: QWebFrame not found.
|
130
|
+
#
|
131
|
+
# RuntimeError
|
132
|
+
# description: When executing JavaScript to WebElement: QWebPage not found.
|
133
|
+
#
|
134
|
+
# RuntimeError
|
135
|
+
# description: When executing JavaScript to WebElement: QWebElement not found.
|
136
|
+
#
|
137
|
+
def execute_javascript( java_script )
|
138
|
+
|
139
|
+
webframe_id = 0
|
140
|
+
query = ""
|
141
|
+
index = -1
|
142
|
+
if type == "QWebFrame"
|
143
|
+
query = nil
|
144
|
+
else
|
145
|
+
query << self.type.to_s
|
146
|
+
creation_attributes.each {|param, value|
|
147
|
+
if param.to_s == "__index"
|
148
|
+
index=value.to_i
|
149
|
+
next
|
150
|
+
end
|
151
|
+
query << "[" << param.to_s << "='" << value.to_s << "'" << "]"
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
if type != "QWebFrame" #&& parent_object.type == "QWebFrame")
|
156
|
+
#webframe_id = parent_object.id
|
157
|
+
webframe_id = attribute('webFrame')
|
158
|
+
end
|
159
|
+
|
160
|
+
execute_javascript_query( java_script, nil, index, webframe_id)
|
161
|
+
end
|
162
|
+
|
163
|
+
# == description
|
164
|
+
# Scroll QWebFrame to correct position. Valid target object types are: QWebFrame, all QWebElements.
|
165
|
+
#
|
166
|
+
# == arguments
|
167
|
+
# dx
|
168
|
+
# Fixnum
|
169
|
+
# description: Delta x in pixels, positive value to right negative to left. Ignored for QWebElements.
|
170
|
+
# example: 313
|
171
|
+
#
|
172
|
+
# dy
|
173
|
+
# Fixnum
|
174
|
+
# description: Delta y in pixels, positive value to down negative to up. Ignored for QWebElements.
|
175
|
+
# example: 313
|
176
|
+
#
|
177
|
+
# center
|
178
|
+
# Fixnum
|
179
|
+
# description: Value 1 means that scroll is done only to reveal the center position of the element. Value 0 means that element is tried to bring fully visible. Ignored for QWebFrame.
|
180
|
+
# example: 1
|
181
|
+
#
|
182
|
+
# == returns
|
183
|
+
# NilClass
|
184
|
+
# description: -
|
185
|
+
# example: -
|
186
|
+
#
|
187
|
+
# == exceptions
|
188
|
+
# RuntimeError
|
189
|
+
# description: Scrollign webframe failed with error: %s
|
190
|
+
#
|
191
|
+
# === examples
|
192
|
+
# @QwebFrame.scroll(0, 10)
|
193
|
+
# @app.a.scroll()
|
194
|
+
def scroll( dx = 0, dy = 0, center = 0 )
|
195
|
+
temp_id = ""
|
196
|
+
|
197
|
+
if type == "QWebFrame"
|
198
|
+
temp_id = @id
|
199
|
+
else
|
200
|
+
temp_id = attribute('webFrame')
|
201
|
+
|
202
|
+
elemens_xml_data, unused_rule = @test_object_adapter.get_objects( @sut.xml_data, { :id => attribute('webFrame')}, true )
|
203
|
+
object_xml_data = elemens_xml_data[0]
|
204
|
+
object_attributes = @test_object_adapter.test_object_attributes(object_xml_data)
|
205
|
+
x_absolute = object_attributes['x_absolute'].to_i
|
206
|
+
y_absolute = object_attributes['y_absolute'].to_i
|
207
|
+
width = object_attributes['width'].to_i
|
208
|
+
height = object_attributes['height'].to_i
|
209
|
+
horizontalScrollBarHeight = object_attributes['horizontalScrollBarHeight'].to_i
|
210
|
+
verticalScrollBarWidth = object_attributes['verticalScrollBarWidth'].to_i
|
211
|
+
|
212
|
+
#calculate borders
|
213
|
+
frame_down_border = y_absolute + height - horizontalScrollBarHeight
|
214
|
+
frame_right_border = x_absolute + width - verticalScrollBarWidth
|
215
|
+
|
216
|
+
if(center==1)
|
217
|
+
|
218
|
+
#adjust image to be visible for tap
|
219
|
+
if(center_y.to_i > frame_down_border)
|
220
|
+
dy = center_y.to_i - frame_down_border + 5
|
221
|
+
elsif (center_y.to_i < y_absolute)
|
222
|
+
dy = center_y.to_i - y_absolute - 5
|
223
|
+
end
|
224
|
+
|
225
|
+
if(center_x.to_i > frame_right_border)
|
226
|
+
dx = center_x.to_i - frame_right_border + 1
|
227
|
+
elsif (center_x.to_i < x_absolute)
|
228
|
+
dx = center_x.to_i - x_absolute - 1
|
229
|
+
end
|
230
|
+
else
|
231
|
+
#bring fully visible
|
232
|
+
if(center_y.to_i > frame_down_border)
|
233
|
+
dy = attribute("y_absolute").to_i + attribute("height").to_i - y_absolute - height + horizontalScrollBarHeight
|
234
|
+
elsif (center_y.to_i < y_absolute)
|
235
|
+
dy = attribute("y_absolute").to_i - y_absolute
|
236
|
+
end
|
237
|
+
|
238
|
+
if(center_x.to_i > frame_right_border)
|
239
|
+
dx = attribute("x_absolute").to_i + attribute("width").to_i - x_absolute - width + verticalScrollBarWidth
|
240
|
+
elsif (center_x.to_i < x_absolute)
|
241
|
+
dx = attribute("x_absolute").to_i - x_absolute
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
command = command_params #in qt_behaviour
|
247
|
+
command.command_name('ScrollQWebFrame')
|
248
|
+
|
249
|
+
command.service( 'webkitCommand' )
|
250
|
+
params = {
|
251
|
+
'dx' => dx.to_s,
|
252
|
+
'dy'=> dy.to_s,
|
253
|
+
'target_webframe'=> temp_id
|
254
|
+
}
|
255
|
+
|
256
|
+
command.command_params( params )
|
257
|
+
|
258
|
+
returnValue = @sut.execute_command( command )
|
259
|
+
raise RuntimeError.new( "Scrollign webframe failed with error: %s" % [ returnValue ] ) if ( returnValue != "OK" )
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
# enable hooking for performance measurement & debug logging
|
265
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
266
|
+
|
267
|
+
|
268
|
+
end # Webkit
|
269
|
+
|
270
|
+
end # QT
|
271
|
+
|
272
|
+
end # MobyBehaviour
|
@@ -0,0 +1,877 @@
|
|
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
|
+
# TODO: document
|
21
|
+
module MobyBehaviour
|
22
|
+
|
23
|
+
module QT
|
24
|
+
|
25
|
+
# == description
|
26
|
+
# Widget specific behaviours
|
27
|
+
#
|
28
|
+
# == behaviour
|
29
|
+
# QtWidget
|
30
|
+
#
|
31
|
+
# == requires
|
32
|
+
# testability-driver-qt-sut-plugin
|
33
|
+
#
|
34
|
+
# == input_type
|
35
|
+
# touch
|
36
|
+
#
|
37
|
+
# == sut_type
|
38
|
+
# qt
|
39
|
+
#
|
40
|
+
# == sut_version
|
41
|
+
# *
|
42
|
+
#
|
43
|
+
# == objects
|
44
|
+
# *
|
45
|
+
#
|
46
|
+
module Widget
|
47
|
+
|
48
|
+
include MobyBehaviour::QT::Behaviour
|
49
|
+
|
50
|
+
# == description
|
51
|
+
# Moves the mouse to the object it was called on.
|
52
|
+
# == arguments
|
53
|
+
# move_params
|
54
|
+
# Boolean
|
55
|
+
# description: if true will cause the framework to refresh the UI state
|
56
|
+
# example: true
|
57
|
+
# == returns
|
58
|
+
# NilClass
|
59
|
+
# description: -
|
60
|
+
# example: -
|
61
|
+
# == examples
|
62
|
+
# @object.move_mouse
|
63
|
+
def move_mouse( move_params = false )
|
64
|
+
|
65
|
+
$stderr.puts "#{ caller(0).last.to_s } warning: move_mouse(boolean) is deprecated; use move_mouse(Hash)" if move_params == true
|
66
|
+
|
67
|
+
begin
|
68
|
+
# Hide all future params in a hash
|
69
|
+
use_tap_screen = false
|
70
|
+
if move_params.kind_of? Hash
|
71
|
+
use_tap_screen = move_params[:use_tap_screen].nil? ? sut_parameters[ :use_tap_screen, 'false'] : move_params[:use_tap_screen].to_s
|
72
|
+
else
|
73
|
+
use_tap_screen = sut_parameters[ :use_tap_screen, 'false']
|
74
|
+
end
|
75
|
+
command = command_params #in qt_behaviour
|
76
|
+
command.command_name('MouseMove')
|
77
|
+
|
78
|
+
if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
|
79
|
+
params = {
|
80
|
+
'x' => center_x,
|
81
|
+
'y' => center_y,
|
82
|
+
'useCoordinates' => 'true',
|
83
|
+
'useTapScreen' => use_tap_screen,
|
84
|
+
'x_off' => sut_parameters[:tap_x_offset , '0' ],
|
85
|
+
'y_off' => sut_parameters[:tap_y_offset , '0' ]
|
86
|
+
}
|
87
|
+
else
|
88
|
+
params = {'useTapScreen' => use_tap_screen.to_s}
|
89
|
+
end
|
90
|
+
command.command_params(params)
|
91
|
+
|
92
|
+
execute_behavior(move_params, command)
|
93
|
+
|
94
|
+
rescue Exception
|
95
|
+
|
96
|
+
$logger.behaviour "FAIL;Failed to mouse_move"
|
97
|
+
|
98
|
+
raise
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
$logger.behaviour "PASS;Operation mouse_move executed successfully"
|
103
|
+
|
104
|
+
nil
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
# == description
|
109
|
+
# Taps the screen on the coordinates of the object.
|
110
|
+
#
|
111
|
+
# == arguments
|
112
|
+
# tap_params
|
113
|
+
# Hash
|
114
|
+
# description: arguments hash, see table below. If integer instead of a Hash, then this has deprecated meaning tap_count, which is also why default value is a number.
|
115
|
+
# example: -
|
116
|
+
# interval
|
117
|
+
# Integer
|
118
|
+
# description: DEPRECATED, use hash key :interval instead
|
119
|
+
# example: -
|
120
|
+
# button
|
121
|
+
# Symbol
|
122
|
+
# description: DEPRECATED, use hash key :button instead
|
123
|
+
# example: -
|
124
|
+
#
|
125
|
+
# == tables
|
126
|
+
# tap_params_table
|
127
|
+
# title: Hash argument tap_params
|
128
|
+
# description: Valid keys for argument tap_params as hash
|
129
|
+
# |Key|Description|Type|Example|Default|
|
130
|
+
# |:button|Button to use for tapping|Symbol|:Right|:Left|
|
131
|
+
# |:duration|Duration in seconds for a single left button press, all other arguments ignored|Numeric|0.1|-|
|
132
|
+
# |:interval|This method sleeps tap_count times interval|Integer|2|1|
|
133
|
+
# |:tap_count|Number of taps to do|Integer|2|1|
|
134
|
+
# |:use_tap_screen|Should tapping be done on screen or as mouse event to the object|Boolean|true|see TDriver parameters table below|
|
135
|
+
# |:ensure_event|Verify that an event is sent to the target object. Retry if not received by target|Boolean|true|false|
|
136
|
+
#
|
137
|
+
# tdriver_params_table
|
138
|
+
# title: Default values read from tdriver parameters
|
139
|
+
# description: These setting values are read from tdriver_parameters.xml
|
140
|
+
# |Name|Description|Default if missing from parameters|
|
141
|
+
# |use_tap_screen|See :use_tap_screen above|false|
|
142
|
+
# |in_tap_move_pointer|Wether to actually move mouse pointer to tap coordinates|false|
|
143
|
+
# |:ensure_event|Verify that an event is sent to the target object. Retry if not received by target|false|
|
144
|
+
#
|
145
|
+
# == returns
|
146
|
+
# NilClass
|
147
|
+
# description: -
|
148
|
+
# example: -
|
149
|
+
#
|
150
|
+
# == exceptions
|
151
|
+
# TestObjectNotFoundError
|
152
|
+
# description: object is not visible on screen
|
153
|
+
# ArgumentError
|
154
|
+
# description: Invalid button or non-integer interval
|
155
|
+
def tap( tap_params = 1, interval = nil, button = :Left )
|
156
|
+
# tapMeasure = Time.now
|
157
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - tap start"
|
158
|
+
|
159
|
+
# delegate duration taps to grouped behaviors
|
160
|
+
if tap_params.kind_of?(Hash) && !tap_params[:duration].nil?
|
161
|
+
@sut.group_behaviours(tap_params[:duration], get_application) {
|
162
|
+
tap_down
|
163
|
+
tap_up
|
164
|
+
}
|
165
|
+
return
|
166
|
+
end
|
167
|
+
|
168
|
+
begin
|
169
|
+
#for api compatibility
|
170
|
+
if interval and interval.kind_of?(Symbol)
|
171
|
+
button = interval
|
172
|
+
interval = nil
|
173
|
+
end
|
174
|
+
|
175
|
+
# Another one, first param a has for the rest
|
176
|
+
if tap_params.kind_of?(Hash)
|
177
|
+
interval = tap_params[:interval]
|
178
|
+
if tap_params[:button].nil?
|
179
|
+
button = :Left
|
180
|
+
else
|
181
|
+
button = tap_params[:button]
|
182
|
+
end
|
183
|
+
|
184
|
+
tap_count = tap_params[:tap_count].nil? ? 1 : tap_params[:tap_count]
|
185
|
+
use_tap_screen = tap_params[:use_tap_screen].nil? ? sut_parameters[ :use_tap_screen, 'false'] : tap_params[:use_tap_screen].to_s
|
186
|
+
|
187
|
+
else
|
188
|
+
tap_count = tap_params
|
189
|
+
|
190
|
+
use_tap_screen = sut_parameters[ :use_tap_screen, 'false']
|
191
|
+
end
|
192
|
+
|
193
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
|
194
|
+
if interval
|
195
|
+
raise ArgumentError.new( "Invalid interval must be an integer." ) unless interval.kind_of?(Integer)
|
196
|
+
end
|
197
|
+
|
198
|
+
command = command_params #in qt_behaviour
|
199
|
+
command.command_name('Tap')
|
200
|
+
|
201
|
+
params = {
|
202
|
+
'count' => tap_count.to_s,
|
203
|
+
'button' => @@_buttons_map[button],
|
204
|
+
'mouseMove' => sut_parameters[ :in_tap_move_pointer, 'false' ],
|
205
|
+
'useTapScreen' => use_tap_screen,
|
206
|
+
'x_off' => sut_parameters[:tap_x_offset , '0' ],
|
207
|
+
'y_off' => sut_parameters[:tap_y_offset , '0' ]
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
if interval
|
212
|
+
params[:interval] = (interval.to_f * 1000).to_i
|
213
|
+
end
|
214
|
+
|
215
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - before webs"
|
216
|
+
|
217
|
+
if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
|
218
|
+
#params['obj_x'] = (center_x.to_i - 1).to_s
|
219
|
+
#params['obj_y'] = (center_y.to_i - 1).to_s
|
220
|
+
params['x'] = (center_x.to_i - 1).to_s
|
221
|
+
params['y'] = (center_y.to_i - 5).to_s #make sure we do not tap between two line links
|
222
|
+
params['useCoordinates'] = 'true'
|
223
|
+
end
|
224
|
+
|
225
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - before 2 webs"
|
226
|
+
|
227
|
+
if(attribute('objectType') == 'Web')
|
228
|
+
#check that type is not QWebFrame and that QWebFrame is found for object
|
229
|
+
if type != "QWebFrame" and attributes.key?('webFrame')
|
230
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - Not q webframe"
|
231
|
+
elemens_xml_data, unused_rule = @test_object_adapter.get_objects( @sut.xml_data, { :id => attribute('webFrame')}, true )
|
232
|
+
object_xml_data = elemens_xml_data[0]
|
233
|
+
object_attributes = @test_object_adapter.test_object_attributes(object_xml_data)
|
234
|
+
x_absolute = object_attributes['x_absolute'].to_i
|
235
|
+
y_absolute = object_attributes['y_absolute'].to_i
|
236
|
+
width = object_attributes['width'].to_i
|
237
|
+
height = object_attributes['height'].to_i
|
238
|
+
horizontalScrollBarHeight = object_attributes['horizontalScrollBarHeight'].to_i
|
239
|
+
verticalScrollBarWidth = object_attributes['verticalScrollBarWidth'].to_i
|
240
|
+
|
241
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - x_a(#{x_absolute}), y_a(#{y_absolute}), w(#{width}), h(#{height})"
|
242
|
+
|
243
|
+
|
244
|
+
if(object_attributes['baseUrl'] != "" and (
|
245
|
+
(center_x.to_i < x_absolute) or
|
246
|
+
(center_x.to_i > x_absolute + width - verticalScrollBarWidth) or
|
247
|
+
(center_y.to_i < y_absolute) or
|
248
|
+
(center_y.to_i > y_absolute + height - horizontalScrollBarHeight)
|
249
|
+
)
|
250
|
+
)
|
251
|
+
#puts "web element scroll"
|
252
|
+
scroll(0,0,1) # enable tap centralization
|
253
|
+
#puts "web element force refresh in tap"
|
254
|
+
force_refresh({:id => get_application_id})
|
255
|
+
tap(tap_params, interval, button)
|
256
|
+
return
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
command.command_params(params)
|
261
|
+
|
262
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - tap about to execute "
|
263
|
+
execute_behavior(tap_params, command)
|
264
|
+
|
265
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - executed"
|
266
|
+
#do not allow operations to continue untill taps done
|
267
|
+
if interval
|
268
|
+
sleep interval * tap_count
|
269
|
+
end
|
270
|
+
|
271
|
+
rescue Exception
|
272
|
+
|
273
|
+
$logger.behaviour "FAIL;Failed tap with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};tap;"
|
274
|
+
|
275
|
+
raise
|
276
|
+
|
277
|
+
end
|
278
|
+
|
279
|
+
$logger.behaviour "PASS;Operation tap executed successfully with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};tap;"
|
280
|
+
|
281
|
+
# puts "tap: " + (Time.now - tapMeasure).to_s + " s - tapping ending"
|
282
|
+
|
283
|
+
|
284
|
+
nil
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
|
289
|
+
# == description
|
290
|
+
# Taps the screen on the specified coordinates of the object. Given coordinates are relative to the object.
|
291
|
+
#
|
292
|
+
# == arguments
|
293
|
+
# x
|
294
|
+
# Integer
|
295
|
+
# description: x coordinate inside object to click
|
296
|
+
# example: 5
|
297
|
+
#
|
298
|
+
# y
|
299
|
+
# Integer
|
300
|
+
# description: y coordinate inside object to click
|
301
|
+
# example: 5
|
302
|
+
#
|
303
|
+
# tap_count
|
304
|
+
# Integer
|
305
|
+
# description: number of times to tap the screen
|
306
|
+
# example: 1
|
307
|
+
#
|
308
|
+
# button
|
309
|
+
# Symbol
|
310
|
+
# description: button symbol supported values are: :NoButton, :Left, :Right, :Middle
|
311
|
+
# example: :Left
|
312
|
+
#
|
313
|
+
# tap_params
|
314
|
+
# Hash
|
315
|
+
# description: parameter that also incorporate all previous tap_object_* commands :command, :behavior_name and :use_tap_screen
|
316
|
+
# example: { }
|
317
|
+
#
|
318
|
+
# == returns
|
319
|
+
# NilClass
|
320
|
+
# description: -
|
321
|
+
# example: nil
|
322
|
+
#
|
323
|
+
# == exceptions
|
324
|
+
# TestObjectNotFoundError
|
325
|
+
# description: If a graphics item is not visible on screen
|
326
|
+
#
|
327
|
+
# ArgumentError
|
328
|
+
# description: If coordinates are outside of the object
|
329
|
+
#
|
330
|
+
def tap_object( x, y, tap_count = 1, button = :Left, tap_params = nil )
|
331
|
+
|
332
|
+
begin
|
333
|
+
|
334
|
+
# New hash format for the parameter. Also incorporates all
|
335
|
+
# previous tap_object_* commands that were redundant.
|
336
|
+
if tap_params.kind_of? Hash
|
337
|
+
command_name = tap_params[:command].nil? ? 'Tap' : tap_params[:command]
|
338
|
+
behavior_name = tap_params[:behavior_name].nil? ? 'tap_object' : tap_params[:behavior_name]
|
339
|
+
|
340
|
+
use_tap_screen = tap_params[:use_tap_screen].nil? ? sut_parameters[ :use_tap_screen, 'false'] : tap_params[:use_tap_screen].to_s
|
341
|
+
else
|
342
|
+
use_tap_screen = sut_parameters[ :use_tap_screen, 'false']
|
343
|
+
command_name = 'Tap'
|
344
|
+
behavior_name = 'tap_object'
|
345
|
+
end
|
346
|
+
|
347
|
+
raise ArgumentError.new( "Coordinate x:#{x} x_abs:#{x} outside object." ) unless ( x <= attribute( 'width' ).to_i and x >= 0 )
|
348
|
+
raise ArgumentError.new( "Coordinate y:#{y} y_abs:#{y} outside object." ) unless ( y <= attribute( 'height' ).to_i and y >= 0 )
|
349
|
+
|
350
|
+
command = command_params #in qt_behaviour
|
351
|
+
command.command_name(command_name)
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
command.command_params(
|
356
|
+
'x' => ( attribute('x_absolute').to_i + x.to_i ).to_s,
|
357
|
+
'y' => ( attribute('y_absolute').to_i + y.to_i ).to_s,
|
358
|
+
'count' => tap_count.to_s,
|
359
|
+
'button' => @@_buttons_map[ button ],
|
360
|
+
'mouseMove' => sut_parameters[ :in_tap_move_pointer, 'false' ],
|
361
|
+
'useCoordinates' => 'true',
|
362
|
+
'useTapScreen' => use_tap_screen,
|
363
|
+
'x_off' => sut_parameters[:tap_x_offset , '0' ],
|
364
|
+
'y_off' => sut_parameters[:tap_y_offset , '0' ]
|
365
|
+
|
366
|
+
)
|
367
|
+
|
368
|
+
execute_behavior(tap_params, command)
|
369
|
+
|
370
|
+
rescue Exception
|
371
|
+
|
372
|
+
$logger.behaviour "FAIL;Failed #{behavior_name} with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};#{behavior_name};"
|
373
|
+
|
374
|
+
raise
|
375
|
+
|
376
|
+
end
|
377
|
+
|
378
|
+
$logger.behaviour "PASS;Operation #{behavior_name} executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};#{behavior_name};"
|
379
|
+
|
380
|
+
nil
|
381
|
+
|
382
|
+
end
|
383
|
+
|
384
|
+
|
385
|
+
# == description
|
386
|
+
# Tap down the screen on the specified coordinates of the object. TBA link to generic information about tapping, options read from TDriver parameters etc.
|
387
|
+
#
|
388
|
+
# == arguments
|
389
|
+
# x
|
390
|
+
# Integer
|
391
|
+
# description: X-coordinate inside the object
|
392
|
+
# example: 10
|
393
|
+
# y
|
394
|
+
# Integer
|
395
|
+
# description: Y-coordinate inside the object
|
396
|
+
# example: 11
|
397
|
+
# button
|
398
|
+
# Symbol
|
399
|
+
# description: button to tap down
|
400
|
+
# example: :Right
|
401
|
+
# tap_params
|
402
|
+
# Hash
|
403
|
+
# description: arguments, link to table TBA
|
404
|
+
# example: -
|
405
|
+
#
|
406
|
+
# == returns
|
407
|
+
# NilClass
|
408
|
+
# description: -
|
409
|
+
# example: nil
|
410
|
+
#
|
411
|
+
# == exceptions
|
412
|
+
# Exception
|
413
|
+
# description: see tap_object method for exceptions
|
414
|
+
def tap_down_object( x, y, button = :Left, tap_params = {} )
|
415
|
+
tap_params[:behavior_name] = 'tap_down_object'
|
416
|
+
tap_params[:command] = 'MousePress'
|
417
|
+
tap_object(x,y,1,button,tap_params)
|
418
|
+
end
|
419
|
+
|
420
|
+
# == description
|
421
|
+
# Release mouse tap on the specified coordinates of the object. TBA link to generic information about tapping, options read from TDriver parameters etc.
|
422
|
+
#
|
423
|
+
# == arguments
|
424
|
+
# x
|
425
|
+
# Integer
|
426
|
+
# description: X-coordinate inside the object
|
427
|
+
# example: 10
|
428
|
+
# y
|
429
|
+
# Integer
|
430
|
+
# description: Y-coordinate inside the object
|
431
|
+
# example: 11
|
432
|
+
# button
|
433
|
+
# Symbol
|
434
|
+
# description: button to tap up
|
435
|
+
# example: :Right
|
436
|
+
# tap_params
|
437
|
+
# Hash
|
438
|
+
# description: arguments, link to table TBA
|
439
|
+
# example: -
|
440
|
+
#
|
441
|
+
# == returns
|
442
|
+
# NilClass
|
443
|
+
# description: -
|
444
|
+
# example: nil
|
445
|
+
#
|
446
|
+
# == exceptions
|
447
|
+
# Exception
|
448
|
+
# description: see tap_object method for exceptions
|
449
|
+
def tap_up_object( x, y = -1, button = :Left, tap_params = {} )
|
450
|
+
tap_params[:behavior_name] = 'tap_up_object'
|
451
|
+
tap_params[:command] = 'MouseRelease'
|
452
|
+
tap_object(x,y,1,button,tap_params)
|
453
|
+
end
|
454
|
+
|
455
|
+
# == description
|
456
|
+
# Taps the screen on the coordinates of the object for the period of time given is seconds.
|
457
|
+
#
|
458
|
+
# == arguments
|
459
|
+
# time
|
460
|
+
# Integer
|
461
|
+
# description: Number of seconds to hold the pointer down.
|
462
|
+
# example: 5
|
463
|
+
# default: 1
|
464
|
+
#
|
465
|
+
# button
|
466
|
+
# Symbol
|
467
|
+
# description: Button symbol supported values are: :NoButton, :Left, :Right, :Middle .
|
468
|
+
# example: :Right
|
469
|
+
# default: :Left
|
470
|
+
#
|
471
|
+
# tap_params
|
472
|
+
# Hash
|
473
|
+
# description: Hash with additional tap parameters. Link to table TBA
|
474
|
+
# example: {:behavior_name => 'long_tap', :use_tap_screen => true}
|
475
|
+
# default: {}
|
476
|
+
#
|
477
|
+
# == returns
|
478
|
+
# NilClass
|
479
|
+
# description: -
|
480
|
+
# example: -
|
481
|
+
#
|
482
|
+
# == exceptions
|
483
|
+
# ArgumentError
|
484
|
+
# description: If tap_params is not a Hash or a Fixnum type
|
485
|
+
#
|
486
|
+
def long_tap( time = 1, button = :Left, tap_params = {} )
|
487
|
+
|
488
|
+
logging_enabled = $logger.enabled
|
489
|
+
$logger.enabled = false
|
490
|
+
|
491
|
+
raise ArgumentError.new("First parameter should be time between taps or Hash") unless tap_params.kind_of? Hash or tap_params.kind_of? Fixnum
|
492
|
+
|
493
|
+
begin
|
494
|
+
ens = param_set_configured?(tap_params, :ensure_event)
|
495
|
+
tap_params[:ensure_event] = false
|
496
|
+
if ens
|
497
|
+
ensure_event(:retry_timeout => 5, :retry_interval => 0.5) {
|
498
|
+
tap_down(button, false, tap_params)
|
499
|
+
sleep time
|
500
|
+
tap_up(button, false, tap_params)
|
501
|
+
}
|
502
|
+
else
|
503
|
+
tap_down(button, false, tap_params)
|
504
|
+
sleep time
|
505
|
+
tap_up(button, false, tap_params)
|
506
|
+
end
|
507
|
+
|
508
|
+
|
509
|
+
rescue Exception
|
510
|
+
|
511
|
+
$logger.enabled = logging_enabled
|
512
|
+
|
513
|
+
$logger.behaviour "FAIL;Failed long_tap with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap;"
|
514
|
+
|
515
|
+
raise
|
516
|
+
|
517
|
+
end
|
518
|
+
$logger.enabled = logging_enabled
|
519
|
+
$logger.behaviour "PASS;Operation long_tap executed successfully with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap;"
|
520
|
+
|
521
|
+
nil
|
522
|
+
|
523
|
+
end
|
524
|
+
|
525
|
+
# == description
|
526
|
+
# Long tap on the screen on the given relative coordinates of the object for the period of time given is seconds.
|
527
|
+
#
|
528
|
+
# == arguments
|
529
|
+
# x
|
530
|
+
# Integer
|
531
|
+
# description: X-coordinate inside the object
|
532
|
+
# example: 10
|
533
|
+
# y
|
534
|
+
# Integer
|
535
|
+
# description: Y-coordinate inside the object
|
536
|
+
# example: 11
|
537
|
+
#
|
538
|
+
# time
|
539
|
+
# Integer
|
540
|
+
# description: Number of seconds to hold the pointer down.
|
541
|
+
# example: 5
|
542
|
+
# default: 1
|
543
|
+
#
|
544
|
+
# button
|
545
|
+
# Symbol
|
546
|
+
# description: Button symbol supported values are: :NoButton, :Left, :Right, :Middle .
|
547
|
+
# example: :Right
|
548
|
+
# default: :Left
|
549
|
+
#
|
550
|
+
# tap_params
|
551
|
+
# Hash
|
552
|
+
# description: Hash with additional tap parameters. Link to table TBA
|
553
|
+
# example: {:behavior_name => 'long_tap', :use_tap_screen => true}
|
554
|
+
# default: {}
|
555
|
+
#
|
556
|
+
# == returns
|
557
|
+
# NilClass
|
558
|
+
# description: -
|
559
|
+
# example: -
|
560
|
+
#
|
561
|
+
# == exceptions
|
562
|
+
#
|
563
|
+
def long_tap_object( x, y, time = 1, button = :Left, tap_params = {} )
|
564
|
+
|
565
|
+
begin
|
566
|
+
|
567
|
+
tap_down_object(x, y, button, tap_params)
|
568
|
+
sleep time
|
569
|
+
tap_up_object(x, y, button, tap_params)
|
570
|
+
|
571
|
+
rescue Exception
|
572
|
+
|
573
|
+
$logger.behaviour "FAIL;Failed long_tap_object with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap_object;"
|
574
|
+
|
575
|
+
raise
|
576
|
+
|
577
|
+
end
|
578
|
+
|
579
|
+
$logger.behaviour "PASS;Operation long_tap_object executed successfully with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_tap_object;"
|
580
|
+
|
581
|
+
nil
|
582
|
+
|
583
|
+
end
|
584
|
+
|
585
|
+
|
586
|
+
# == description
|
587
|
+
# Tap down the screen on the coordinates of the object. TBA link to generic information about tapping, options read from TDriver parameters etc.
|
588
|
+
#
|
589
|
+
# == arguments
|
590
|
+
# button
|
591
|
+
# Symbol
|
592
|
+
# description: button to tap down
|
593
|
+
# example: :Right
|
594
|
+
# refresh
|
595
|
+
# Boolean
|
596
|
+
# description: if true, object will be refreshed after tap_down
|
597
|
+
# example: true
|
598
|
+
# tap_params
|
599
|
+
# Hash
|
600
|
+
# description: arguments, link to table TBA
|
601
|
+
# example: -
|
602
|
+
#
|
603
|
+
# == returns
|
604
|
+
# NilClass
|
605
|
+
# description: -
|
606
|
+
# example: nil
|
607
|
+
#
|
608
|
+
# == exceptions
|
609
|
+
# TestObjectNotFoundError
|
610
|
+
# description: object is not visible on screen
|
611
|
+
# ArgumentError
|
612
|
+
# description: invalid button
|
613
|
+
def tap_down( button = :Left, refresh = false, tap_params = {} )
|
614
|
+
|
615
|
+
begin
|
616
|
+
use_tap_screen = tap_params[:use_tap_screen].nil? ? sut_parameters[ :use_tap_screen, 'false'] : tap_params[:use_tap_screen].to_s
|
617
|
+
tap_params[:useTapScreen] = use_tap_screen
|
618
|
+
|
619
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
|
620
|
+
command = command_params #in qt_behaviour
|
621
|
+
command.command_name('MousePress')
|
622
|
+
|
623
|
+
params = {
|
624
|
+
'button' => @@_buttons_map[button],
|
625
|
+
'mouseMove' => sut_parameters[ :in_tap_move_pointer, 'false' ],
|
626
|
+
'useTapScreen' => use_tap_screen,
|
627
|
+
'x_off' => sut_parameters[:tap_x_offset , '0' ],
|
628
|
+
'y_off' => sut_parameters[:tap_y_offset , '0' ]
|
629
|
+
}
|
630
|
+
|
631
|
+
if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
|
632
|
+
params['x'] = center_x
|
633
|
+
params['y'] = center_y
|
634
|
+
params['useCoordinates'] = 'true'
|
635
|
+
end
|
636
|
+
params.merge!(tap_params)
|
637
|
+
|
638
|
+
command.command_params(params)
|
639
|
+
execute_behavior(tap_params, command)
|
640
|
+
|
641
|
+
force_refresh( :id => get_application_id ) if refresh
|
642
|
+
|
643
|
+
rescue Exception
|
644
|
+
|
645
|
+
$logger.behaviour "FAIL;Failed tap_down with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_down;"
|
646
|
+
|
647
|
+
raise
|
648
|
+
|
649
|
+
end
|
650
|
+
|
651
|
+
$logger.behaviour "PASS;Operation tap_down executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_down;"
|
652
|
+
|
653
|
+
nil
|
654
|
+
|
655
|
+
end
|
656
|
+
|
657
|
+
|
658
|
+
|
659
|
+
# == description
|
660
|
+
# Release tap on the coordinates of the object. TBA link to generic information about tapping, options read from TDriver parameters etc.
|
661
|
+
#
|
662
|
+
# == arguments
|
663
|
+
# button
|
664
|
+
# Symbol
|
665
|
+
# description: button to tap down
|
666
|
+
# example: :Right
|
667
|
+
# refresh
|
668
|
+
# Boolean
|
669
|
+
# description: if true, object will be refreshed after tap_down
|
670
|
+
# example: false
|
671
|
+
# tap_params
|
672
|
+
# Hash
|
673
|
+
# description: arguments, link to table TBA
|
674
|
+
# example: -
|
675
|
+
#
|
676
|
+
# == returns
|
677
|
+
# NilClass
|
678
|
+
# description: -
|
679
|
+
# example: nil
|
680
|
+
#
|
681
|
+
# == exceptions
|
682
|
+
# TestObjectNotFoundError
|
683
|
+
# description: object is not visible on screen
|
684
|
+
# ArgumentError
|
685
|
+
# description: invalid button
|
686
|
+
def tap_up( button = :Left, refresh = true, tap_params = {} )
|
687
|
+
|
688
|
+
begin
|
689
|
+
use_tap_screen = tap_params[:use_tap_screen].nil? ? sut_parameters[ :use_tap_screen, 'false'] : tap_params[:use_tap_screen].to_s
|
690
|
+
tap_params[:useTapScreen] = use_tap_screen
|
691
|
+
|
692
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
|
693
|
+
command = command_params #in qt_behaviour
|
694
|
+
command.command_name('MouseRelease')
|
695
|
+
params = {'button' => @@_buttons_map[button], 'useTapScreen' => use_tap_screen}
|
696
|
+
|
697
|
+
if attribute('objectType') == 'Web' or attribute('objectType') == 'Embedded'
|
698
|
+
params['x'] = center_x
|
699
|
+
params['y'] = center_y
|
700
|
+
params['useCoordinates'] = 'true'
|
701
|
+
params['x_off'] = sut_parameters[:tap_x_offset , '0' ]
|
702
|
+
params['y_off'] = sut_parameters[:tap_y_offset , '0' ]
|
703
|
+
|
704
|
+
end
|
705
|
+
params.merge!(tap_params)
|
706
|
+
|
707
|
+
command.command_params(params)
|
708
|
+
|
709
|
+
execute_behavior(tap_params, command)
|
710
|
+
force_refresh({:id => get_application_id}) if refresh
|
711
|
+
|
712
|
+
rescue Exception
|
713
|
+
|
714
|
+
$logger.behaviour "FAIL;Failed tap_up with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_up;"
|
715
|
+
|
716
|
+
raise
|
717
|
+
|
718
|
+
end
|
719
|
+
|
720
|
+
$logger.behaviour "PASS;Operation tap_up executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};tap_up;"
|
721
|
+
|
722
|
+
nil
|
723
|
+
|
724
|
+
end
|
725
|
+
|
726
|
+
# TODO: [2009-04-02] Remove deprevated methods?
|
727
|
+
|
728
|
+
# warning: TestObject#press is deprecated; use TestObject#tap
|
729
|
+
# == deprecated
|
730
|
+
# 0.8.x
|
731
|
+
# == description
|
732
|
+
# TestObject#press is deprecated, use TestObject#tap instead.
|
733
|
+
def press( tap_count = 1, button = :Left )
|
734
|
+
|
735
|
+
$stderr.puts "#{ caller(0).last.to_s } warning: TestObject#press is deprecated; use TestObject#tap"
|
736
|
+
|
737
|
+
begin
|
738
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(button)
|
739
|
+
|
740
|
+
command = command_params #in qt_behaviour
|
741
|
+
|
742
|
+
command.command_name('Tap')
|
743
|
+
|
744
|
+
command.command_params(
|
745
|
+
'x' => center_x,
|
746
|
+
'y' => center_y,
|
747
|
+
'count' => tap_count.to_s,
|
748
|
+
'button' => @@_buttons_map[button],
|
749
|
+
'mouseMove'=>'true',
|
750
|
+
'x_off' => sut_parameters[:tap_x_offset , '0' ],
|
751
|
+
'y_off' => sut_parameters[:tap_y_offset , '0' ]
|
752
|
+
)
|
753
|
+
|
754
|
+
@sut.execute_command(command)
|
755
|
+
|
756
|
+
rescue Exception
|
757
|
+
|
758
|
+
$logger.behaviour "FAIL;Failed press with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};press;"
|
759
|
+
|
760
|
+
raise
|
761
|
+
|
762
|
+
end
|
763
|
+
|
764
|
+
$logger.behaviour "PASS;Operation press executed successfully with tap_count \"#{tap_count}\", button \"#{button.to_s}\".;#{identity};press;"
|
765
|
+
|
766
|
+
nil
|
767
|
+
|
768
|
+
end
|
769
|
+
|
770
|
+
# TestObject#long_press is deprecated; use TestObject#long_tap
|
771
|
+
# == deprecated
|
772
|
+
# 0.8.x
|
773
|
+
# == description
|
774
|
+
# TestObject#long_press is deprecated, use TestObject#long_tap instead.
|
775
|
+
def long_press( time = 1, button = :Left )
|
776
|
+
|
777
|
+
$stderr.puts "#{ caller(0).last.to_s } warning: TestObject#long_press is deprecated; use TestObject#long_tap"
|
778
|
+
|
779
|
+
begin
|
780
|
+
|
781
|
+
long_tap(time, button)
|
782
|
+
|
783
|
+
rescue Exception
|
784
|
+
|
785
|
+
$logger.behaviour "FAIL;Failed long_press with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_press;"
|
786
|
+
|
787
|
+
raise
|
788
|
+
|
789
|
+
end
|
790
|
+
|
791
|
+
$logger.behaviour "PASS;Operation long_press executed successfully with time \"#{time.to_s}\", button \"#{button.to_s}\".;#{identity};long_press;"
|
792
|
+
|
793
|
+
nil
|
794
|
+
|
795
|
+
end
|
796
|
+
|
797
|
+
# TestObject#hold is deprecated; use TestObject#tap_down
|
798
|
+
# == deprecated
|
799
|
+
# 0.8.x
|
800
|
+
# == description
|
801
|
+
# TestObject#hold is deprecated, use TestObject#tap_down instead.
|
802
|
+
def hold(button = :Left, refresh = true)
|
803
|
+
|
804
|
+
$stderr.puts "#{ caller(0).last.to_s } warning: TestObject#hold is deprecated; use TestObject#tap_down"
|
805
|
+
|
806
|
+
begin
|
807
|
+
|
808
|
+
tap_down(button, refresh)
|
809
|
+
|
810
|
+
rescue Exception
|
811
|
+
|
812
|
+
$logger.behaviour "FAIL;Failed hold with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};hold;"
|
813
|
+
|
814
|
+
raise
|
815
|
+
|
816
|
+
end
|
817
|
+
|
818
|
+
$logger.behaviour "PASS;Operation hold executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};hold;"
|
819
|
+
|
820
|
+
nil
|
821
|
+
|
822
|
+
end
|
823
|
+
|
824
|
+
# TestObject#release is deprecated; use TestObject#tap_up
|
825
|
+
# == deprecated
|
826
|
+
# 0.8.x
|
827
|
+
# == description
|
828
|
+
# TestObject#release is deprecated, use TestObject#tap_up instead.
|
829
|
+
def release( button = :Left, refresh = true )
|
830
|
+
|
831
|
+
$stderr.puts "#{ caller(0).last.to_s } warning: TestObject#release is deprecated; use TestObject#tap_up"
|
832
|
+
|
833
|
+
begin
|
834
|
+
|
835
|
+
tap_up(button, refresh)
|
836
|
+
|
837
|
+
rescue Exception
|
838
|
+
|
839
|
+
$logger.behaviour "FAIL;Failed release with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};release;"
|
840
|
+
|
841
|
+
raise
|
842
|
+
|
843
|
+
end
|
844
|
+
|
845
|
+
$logger.behaviour "PASS;Operation release executed successfully with with button \"#{button.to_s}\", refresh \"#{refresh.to_s}\".;#{identity};release;"
|
846
|
+
|
847
|
+
nil
|
848
|
+
|
849
|
+
end
|
850
|
+
|
851
|
+
=begin
|
852
|
+
private
|
853
|
+
|
854
|
+
def center_x
|
855
|
+
x = attribute('x_absolute').to_i
|
856
|
+
width = attribute('width').to_i
|
857
|
+
x = x + (width/2)
|
858
|
+
x.to_s
|
859
|
+
end
|
860
|
+
|
861
|
+
def center_y
|
862
|
+
y = attribute('y_absolute').to_i
|
863
|
+
height = attribute('height').to_i
|
864
|
+
y = y + (height/2)
|
865
|
+
y.to_s
|
866
|
+
end
|
867
|
+
=end
|
868
|
+
|
869
|
+
# enable hooking for performance measurement & debug logging
|
870
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
871
|
+
|
872
|
+
end # Widget
|
873
|
+
|
874
|
+
|
875
|
+
end # QT
|
876
|
+
|
877
|
+
end # MobyBehaviour
|