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