testability-driver-qt-sut-plugin 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/env.rb +26 -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 +156 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +318 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/attribute.rb +227 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +140 -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/events.rb +165 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +333 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +80 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +178 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +906 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +604 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/key_press.rb +152 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +151 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/method.rb +85 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/multitouch.rb +455 -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 +124 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/screen_capture.rb +283 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +492 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +113 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +93 -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 +230 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +663 -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 +50 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +45 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/group.rb +48 -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 +170 -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/widget.rb +226 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +264 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +60 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +114 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +67 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +52 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +62 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +99 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +51 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +72 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +119 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +225 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +154 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/controller.rb +58 -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/widget.rb +82 -0
- data/lib/testability-driver-qt-sut-plugin.rb +24 -0
- data/xml/behaviour/qt.xml +717 -0
- data/xml/defaults/sut_qt.xml +9 -0
- data/xml/keymap/qt.xml +321 -0
- data/xml/template/qt.xml +124 -0
- metadata +141 -0
@@ -0,0 +1,80 @@
|
|
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
|
+
# Find behaviours
|
21
|
+
#
|
22
|
+
# Methods for finding test objects on the suttest objet state
|
23
|
+
module MobyBehaviour
|
24
|
+
|
25
|
+
module QT
|
26
|
+
|
27
|
+
# == description
|
28
|
+
# Defines methods to find test objects and scroll them to the display
|
29
|
+
#
|
30
|
+
# == behaviour
|
31
|
+
# QtFind
|
32
|
+
#
|
33
|
+
# == requires
|
34
|
+
# testability-driver-qt-sut-plugin
|
35
|
+
#
|
36
|
+
# == input_type
|
37
|
+
# *
|
38
|
+
#
|
39
|
+
# == sut_type
|
40
|
+
# qt
|
41
|
+
#
|
42
|
+
# == sut_version
|
43
|
+
# *
|
44
|
+
#
|
45
|
+
# == objects
|
46
|
+
# *
|
47
|
+
#
|
48
|
+
module Find
|
49
|
+
include MobyBehaviour::QT::Behaviour
|
50
|
+
|
51
|
+
def find_and_center (find_hash = {})
|
52
|
+
begin
|
53
|
+
search_result = find(find_hash)
|
54
|
+
|
55
|
+
## Calculate Center
|
56
|
+
myWindow = search_result.sut.application.find(:parent => 0, :isWindow => "true") # throws multiple found exeptions
|
57
|
+
window_width = myWindow.attribute('width').to_i/2
|
58
|
+
window_height = myWindow.attribute('height').to_i/2
|
59
|
+
window_x = myWindow.attribute('x_absolute').to_i + window_width.to_i
|
60
|
+
window_y = myWindow.attribute('y_absolute').to_i + window_height.to_i
|
61
|
+
|
62
|
+
## flick_to (center)
|
63
|
+
search_result.flick_to(window_x.to_i, window_y.to_i)
|
64
|
+
rescue Exception => e
|
65
|
+
##MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed to find test object.;#{id.to_s};sut;{};find;" << (find_hash.kind_of?(Hash) ? find_hash.inspect : find_hash.class.to_s)
|
66
|
+
## Rescue from center and flick
|
67
|
+
Kernel::raise e
|
68
|
+
end
|
69
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Test object found and centered.;#{id.to_s};sut;{};application;" << find_hash.inspect
|
70
|
+
search_result
|
71
|
+
end
|
72
|
+
|
73
|
+
# enable hooking for performance measurement & debug logging
|
74
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
75
|
+
|
76
|
+
end # module Find
|
77
|
+
|
78
|
+
end # module QT
|
79
|
+
|
80
|
+
end # module MobyBehaviour
|
@@ -0,0 +1,178 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of TDriver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyBehaviour
|
21
|
+
|
22
|
+
module QT
|
23
|
+
|
24
|
+
# == description
|
25
|
+
# Fixture specific behaviours
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# QtFixture
|
29
|
+
#
|
30
|
+
# == requires
|
31
|
+
# testability-driver-qt-sut-plugin
|
32
|
+
#
|
33
|
+
# == input_type
|
34
|
+
# *
|
35
|
+
#
|
36
|
+
# == sut_type
|
37
|
+
# qt
|
38
|
+
#
|
39
|
+
# == sut_version
|
40
|
+
# *
|
41
|
+
#
|
42
|
+
# == objects
|
43
|
+
# sut;*
|
44
|
+
#
|
45
|
+
module Fixture
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
|
50
|
+
# == description
|
51
|
+
# Sends a fixture call to the target. The fixture will be executed either
|
52
|
+
# inside the application process or the qttasserver process (if used for sut).
|
53
|
+
# The fixture will get a pointer to the object to which this call is made to.
|
54
|
+
#
|
55
|
+
#
|
56
|
+
# == arguments
|
57
|
+
# fixture_name
|
58
|
+
# String
|
59
|
+
# description: Name of the fixture. Fixture mapping is in the tdriverparameters.xml file.
|
60
|
+
# example: tasfixture
|
61
|
+
#
|
62
|
+
# fixture_method
|
63
|
+
# String
|
64
|
+
# description: Name of the action to be executed in the fixture.
|
65
|
+
# example: callApi
|
66
|
+
#
|
67
|
+
# parameters_hash
|
68
|
+
# Hash
|
69
|
+
# description: Optional hash of pareters passed on to the fixture.
|
70
|
+
# example: {:name => 'John'}
|
71
|
+
#
|
72
|
+
# == returns
|
73
|
+
# QString
|
74
|
+
# description: The value returned but the fixture.
|
75
|
+
# example: OK
|
76
|
+
#
|
77
|
+
# == exceptions
|
78
|
+
# ArgumentError
|
79
|
+
# description: In case the given parameters are not valid.
|
80
|
+
#
|
81
|
+
def fixture( fixture_name, fixture_method, parameters_hash = {} )
|
82
|
+
|
83
|
+
Kernel::raise ArgumentError.new("Fixture name -parameter was of wrong type: expected 'String' was '%s'" % fixture_name.class.to_s) unless fixture_name.kind_of?( String )
|
84
|
+
Kernel::raise ArgumentError.new("Fixture method -parameter was of wrong type: expected 'String' was '%s'" % fixture_method.class.to_s) unless fixture_method.kind_of?( String )
|
85
|
+
|
86
|
+
ret = nil
|
87
|
+
|
88
|
+
begin
|
89
|
+
#for sut send the fixture command to qttasserver (appid nil)
|
90
|
+
if self.class == MobyBase::SUT
|
91
|
+
ret = self.execute_command( MobyCommand::Fixture.new( nil, self.id, :Application, fixture_name, fixture_method, parameters_hash ) )
|
92
|
+
else
|
93
|
+
ret = @sut.execute_command( MobyCommand::Fixture.new( get_application_id, self.id, self.attribute( 'objectType' ).intern, fixture_name, fixture_method, parameters_hash ) )
|
94
|
+
end
|
95
|
+
rescue Exception => e
|
96
|
+
|
97
|
+
MobyUtil::Logger.instance.log "behaviour",
|
98
|
+
"FAIL;Failed when calling fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
|
99
|
+
|
100
|
+
Kernel::raise MobyBase::BehaviourError.new("Fixture", "Failed to execute fixture name #{fixture_name} method #{fixture_method}")
|
101
|
+
end
|
102
|
+
|
103
|
+
MobyUtil::Logger.instance.log "behaviour",
|
104
|
+
"PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
|
105
|
+
|
106
|
+
ret
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
# == description
|
111
|
+
# Sends a fixture call to the target. The fixture will be executed either
|
112
|
+
# inside the application process or the qttasserver process (if used for sut).
|
113
|
+
# The fixture will get a pointer to the object to which this call is made to.
|
114
|
+
# This version of the fixture call is asynchronous. This means that no return value
|
115
|
+
# is returned.
|
116
|
+
#
|
117
|
+
#
|
118
|
+
# == arguments
|
119
|
+
# fixture_name
|
120
|
+
# String
|
121
|
+
# description: Name of the fixture. Fixture mapping is in the tdriverparameters.xml file.
|
122
|
+
# example: tasfixture
|
123
|
+
#
|
124
|
+
# fixture_method
|
125
|
+
# String
|
126
|
+
# description: Name of the action to be executed in the fixture.
|
127
|
+
# example: callApi
|
128
|
+
#
|
129
|
+
# parameters_hash
|
130
|
+
# Hash
|
131
|
+
# description: Optional hash of pareters passed on to the fixture.
|
132
|
+
# example: {:name => 'John'}
|
133
|
+
#
|
134
|
+
# == returns
|
135
|
+
# NilClass
|
136
|
+
# description: -
|
137
|
+
# example: -
|
138
|
+
#
|
139
|
+
# == exceptions
|
140
|
+
# ArgumentError
|
141
|
+
# description: In case the given parameters are not valid.
|
142
|
+
#
|
143
|
+
def async_fixture( fixture_name, fixture_method, parameters_hash = {} )
|
144
|
+
|
145
|
+
Kernel::raise ArgumentError.new("Fixture name -parameter was of wrong type: expected 'String' was '%s'" % fixture_name.class.to_s) unless fixture_name.kind_of?( String )
|
146
|
+
Kernel::raise ArgumentError.new("Fixture method -parameter was of wrong type: expected 'String' was '%s'" % fixture_method.class.to_s) unless fixture_method.kind_of?( String )
|
147
|
+
|
148
|
+
ret = nil
|
149
|
+
|
150
|
+
begin
|
151
|
+
#for sut send the fixture command to qttasserver (appid nil)
|
152
|
+
if self.class == MobyBase::SUT
|
153
|
+
ret = self.execute_command( MobyCommand::Fixture.new( nil, self.id, :Application, fixture_name, fixture_method, parameters_hash, true ) )
|
154
|
+
else
|
155
|
+
ret = @sut.execute_command( MobyCommand::Fixture.new( get_application_id, self.id, self.attribute( 'objectType' ).intern, fixture_name, fixture_method, parameters_hash, true ) )
|
156
|
+
end
|
157
|
+
rescue Exception => e
|
158
|
+
|
159
|
+
MobyUtil::Logger.instance.log "behaviour" ,
|
160
|
+
"FAIL;Failed when calling async_fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
|
161
|
+
|
162
|
+
Kernel::raise MobyBase::BehaviourError.new("Fixture", "Failed to execute async_fixture name #{fixture_name} method #{fixture_method}")
|
163
|
+
end
|
164
|
+
|
165
|
+
MobyUtil::Logger.instance.log "behaviour",
|
166
|
+
"PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
|
167
|
+
|
168
|
+
ret
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
# enable hooking for performance measurement & debug logging
|
173
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,906 @@
|
|
1
|
+
############################################################################
|
2
|
+
##
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
4
|
+
## All rights reserved.
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
6
|
+
##
|
7
|
+
## This file is part of TDriver.
|
8
|
+
##
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
11
|
+
##
|
12
|
+
## This library is free software; you can redistribute it and/or
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
16
|
+
## of this file.
|
17
|
+
##
|
18
|
+
############################################################################
|
19
|
+
|
20
|
+
module MobyBehaviour
|
21
|
+
|
22
|
+
module QT
|
23
|
+
|
24
|
+
# == description
|
25
|
+
# Gesture behaviour methods are used to do different gestures with UI objects. Various methods exist for different speeds, targets and other options.
|
26
|
+
#
|
27
|
+
# == behaviour
|
28
|
+
# QtGesture
|
29
|
+
#
|
30
|
+
# == requires
|
31
|
+
# testability-driver-qt-sut-plugin
|
32
|
+
#
|
33
|
+
# == input_type
|
34
|
+
# *
|
35
|
+
#
|
36
|
+
# == sut_type
|
37
|
+
# QT
|
38
|
+
#
|
39
|
+
# == sut_version
|
40
|
+
# *
|
41
|
+
#
|
42
|
+
# == objects
|
43
|
+
# *
|
44
|
+
#
|
45
|
+
module Gesture
|
46
|
+
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
48
|
+
|
49
|
+
# == description
|
50
|
+
# Flick the screen at the location of the object (touch the object and do a flick gesture).
|
51
|
+
# Speed and distance of the flick are defined in the tdriver_parameters under the sut used.
|
52
|
+
# By default a flick is a fast gesture.
|
53
|
+
# For custom values see the gesture method.
|
54
|
+
#
|
55
|
+
# == arguments
|
56
|
+
# direction
|
57
|
+
# Symbol
|
58
|
+
# description: Direction of the flick. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
59
|
+
# example: :Left
|
60
|
+
# Integer
|
61
|
+
# description: Direction of the flick as degrees with 0 being up and 90 right.
|
62
|
+
# example: 270
|
63
|
+
#
|
64
|
+
# button
|
65
|
+
# Symbol
|
66
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
67
|
+
# example: :Middle
|
68
|
+
# default: :Left
|
69
|
+
#
|
70
|
+
# optional_params
|
71
|
+
# Hash
|
72
|
+
# description: The only optional argument supported by flick is :use_tap_screen.
|
73
|
+
# example: { :use_tap_screen => 'true' }
|
74
|
+
# default: { :use_tap_screen => 'false' }
|
75
|
+
#
|
76
|
+
# == returns
|
77
|
+
# NilClass
|
78
|
+
# description: Always returns nil
|
79
|
+
# example: nil
|
80
|
+
#
|
81
|
+
# == exceptions
|
82
|
+
# ArgumentError
|
83
|
+
# description: One of the arguments is not valid
|
84
|
+
def flick( direction, button = :Left, optional_params = {} )
|
85
|
+
|
86
|
+
begin
|
87
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
88
|
+
optional_params[:use_tap_screen].to_s
|
89
|
+
optional_params[:useTapScreen] = use_tap_screen
|
90
|
+
|
91
|
+
speed = calculate_speed(@sut.parameter[:gesture_flick_distance], @sut.parameter[:gesture_flick_speed])
|
92
|
+
distance = @sut.parameter[:gesture_flick_distance].to_i
|
93
|
+
params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => button, :useTapScreen => use_tap_screen}
|
94
|
+
params.merge!(optional_params)
|
95
|
+
|
96
|
+
do_gesture(params)
|
97
|
+
do_sleep(speed)
|
98
|
+
|
99
|
+
rescue Exception => e
|
100
|
+
|
101
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed flick with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
|
102
|
+
Kernel::raise e
|
103
|
+
end
|
104
|
+
|
105
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation flick executed successfully with direction \"#{direction}\", button \"#{button.to_s}\".;#{identity};flick;"
|
106
|
+
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
# == description
|
111
|
+
# Flick the screen at the location of the object (touch the object and do a flick gesture), ending the flick at the specified coordinates.
|
112
|
+
# Speed and distance of the flick are defined in the tdriver_parameters under the sut used.
|
113
|
+
# By default a flick is a fast gesture.
|
114
|
+
# For custom values see the gesture_to method.
|
115
|
+
#
|
116
|
+
# == arguments
|
117
|
+
# x
|
118
|
+
# Integer
|
119
|
+
# description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
120
|
+
# example: 300
|
121
|
+
#
|
122
|
+
# y
|
123
|
+
# Integer
|
124
|
+
# description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
125
|
+
# example: 300
|
126
|
+
#
|
127
|
+
# button
|
128
|
+
# Symbol
|
129
|
+
# description: The mouse button pressed while the flick is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
130
|
+
# example: :Middle
|
131
|
+
# default: :Left
|
132
|
+
#
|
133
|
+
# optional_params
|
134
|
+
# Hash
|
135
|
+
# description: The only optional argument supported by flick_to is :use_tap_screen.
|
136
|
+
# example: { :use_tap_screen => 'true' }
|
137
|
+
# default: { :use_tap_screen => 'false' }
|
138
|
+
#
|
139
|
+
# == returns
|
140
|
+
# NilClass
|
141
|
+
# description: Always returns nil
|
142
|
+
# example: nil
|
143
|
+
#
|
144
|
+
# == exceptions
|
145
|
+
# ArgumentError
|
146
|
+
# description: One of the arguments is not valid
|
147
|
+
def flick_to( x, y, button = :Left, optional_params = {})
|
148
|
+
|
149
|
+
begin
|
150
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
151
|
+
optional_params[:use_tap_screen].to_s
|
152
|
+
optional_params[:useTapScreen] = use_tap_screen
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
speed = calculate_speed( @sut.parameter[ :gesture_flick_distance ], @sut.parameter[ :gesture_flick_speed ] )
|
157
|
+
do_gesture({:gesture_type => :MouseGestureToCoordinates, :x => x, :y => y, :speed => speed, :isDrag => false, :button => button, :useTapScreen => use_tap_screen})
|
158
|
+
do_sleep(speed)
|
159
|
+
|
160
|
+
rescue Exception => e
|
161
|
+
|
162
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed flick_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
163
|
+
Kernel::raise e
|
164
|
+
end
|
165
|
+
|
166
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation flick_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
167
|
+
|
168
|
+
nil
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
# == description
|
174
|
+
# Perform a gesture with the object
|
175
|
+
#
|
176
|
+
# == arguments
|
177
|
+
# direction
|
178
|
+
# Symbol
|
179
|
+
# description: Direction of the gesture. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
180
|
+
# example: :Left
|
181
|
+
#
|
182
|
+
# Integer
|
183
|
+
# description: Direction of the gesture as degrees with 0 being up and 90 right.
|
184
|
+
# example: 270
|
185
|
+
#
|
186
|
+
# speed
|
187
|
+
# Numeric
|
188
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
189
|
+
# example: 1
|
190
|
+
#
|
191
|
+
# distance
|
192
|
+
# Integer
|
193
|
+
# description: Number of pixels that the object is to be moved in the gesture.
|
194
|
+
# example: 100
|
195
|
+
#
|
196
|
+
# optional_params
|
197
|
+
# Hash
|
198
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
199
|
+
# example: { :button => :Right }
|
200
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
201
|
+
#
|
202
|
+
# == tables
|
203
|
+
# directions_table
|
204
|
+
# title: Direction symbols table
|
205
|
+
# |Symbol|
|
206
|
+
# |:Left|
|
207
|
+
# |:Right|
|
208
|
+
# |:Up|
|
209
|
+
# |:Down|
|
210
|
+
#
|
211
|
+
# buttons_table
|
212
|
+
# title: Mouse button symbols table
|
213
|
+
# |Symbol|Description|
|
214
|
+
# |:Left|Simulate left mouse button|
|
215
|
+
# |:Middle|Simulate middle mouse button|
|
216
|
+
# |:Right|Simulate right mouse button|
|
217
|
+
# |:NoButton|Do not simulate any mouse button|
|
218
|
+
#
|
219
|
+
# == returns
|
220
|
+
# NilClass
|
221
|
+
# description: Always returns nil
|
222
|
+
# example: nil
|
223
|
+
#
|
224
|
+
# == exceptions
|
225
|
+
# ArgumentError
|
226
|
+
# description: One of the arguments is not valid
|
227
|
+
def gesture( direction, speed, distance, optional_params = {:button => :Left, :isDrag => false})
|
228
|
+
|
229
|
+
begin
|
230
|
+
# change the format for api consitency
|
231
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
232
|
+
optional_params[:use_tap_screen].to_s
|
233
|
+
optional_params[:useTapScreen] = use_tap_screen
|
234
|
+
|
235
|
+
|
236
|
+
#do_gesture(direction, speed, distance, isDrag, button)
|
237
|
+
params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance}
|
238
|
+
params.merge!(optional_params)
|
239
|
+
do_gesture(params)
|
240
|
+
do_sleep(speed)
|
241
|
+
|
242
|
+
rescue Exception => e
|
243
|
+
|
244
|
+
MobyUtil::Logger.instance.log "behaviour",
|
245
|
+
"FAIL;Failed gesture with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
|
246
|
+
Kernel::raise e
|
247
|
+
end
|
248
|
+
|
249
|
+
MobyUtil::Logger.instance.log "behaviour",
|
250
|
+
"PASS;Operation gesture executed successfully with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
|
251
|
+
|
252
|
+
nil
|
253
|
+
end
|
254
|
+
|
255
|
+
# == description
|
256
|
+
# Perform a gesture with the object, ending the gesture at the specified point.
|
257
|
+
#
|
258
|
+
# == arguments
|
259
|
+
# x
|
260
|
+
# Integer
|
261
|
+
# description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
262
|
+
# example: 300
|
263
|
+
#
|
264
|
+
# y
|
265
|
+
# Integer
|
266
|
+
# description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
267
|
+
# example: 300
|
268
|
+
#
|
269
|
+
# speed
|
270
|
+
# Numeric
|
271
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
272
|
+
# example: 1
|
273
|
+
#
|
274
|
+
# optional_params
|
275
|
+
# Hash
|
276
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
277
|
+
# example: { :button => :Right }
|
278
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
279
|
+
#
|
280
|
+
# == returns
|
281
|
+
# NilClass
|
282
|
+
# description: Always returns nil
|
283
|
+
# example: nil
|
284
|
+
#
|
285
|
+
# == exceptions
|
286
|
+
# ArgumentError
|
287
|
+
# description: One of the arguments is not valid
|
288
|
+
def gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false})
|
289
|
+
|
290
|
+
begin
|
291
|
+
# change the format for api consitency
|
292
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
293
|
+
optional_params[:use_tap_screen].to_s
|
294
|
+
optional_params[:useTapScreen] = use_tap_screen
|
295
|
+
|
296
|
+
|
297
|
+
params = {:gesture_type => :MouseGestureToCoordinates, :x => x, :y => y, :speed => speed}
|
298
|
+
params.merge!(optional_params)
|
299
|
+
do_gesture(params)
|
300
|
+
do_sleep(speed)
|
301
|
+
|
302
|
+
rescue Exception => e
|
303
|
+
|
304
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed gesture_to with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", button \".;#{identity};gesture;"
|
305
|
+
Kernel::raise e
|
306
|
+
end
|
307
|
+
|
308
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation gesture_to executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\".;#{identity};gesture;"
|
309
|
+
nil
|
310
|
+
end
|
311
|
+
|
312
|
+
# == description
|
313
|
+
# Perform a gesture with the object, starting the gesture at the specified point inside it.
|
314
|
+
#
|
315
|
+
# == arguments
|
316
|
+
# x
|
317
|
+
# Integer
|
318
|
+
# description: X coordinate of the start point. The coordinate is relative to the object top left corner.
|
319
|
+
# example: 20
|
320
|
+
#
|
321
|
+
# y
|
322
|
+
# Integer
|
323
|
+
# description: Y coordinate of the start point. The coordinate is relative to the object top left corner.
|
324
|
+
# example: 15
|
325
|
+
#
|
326
|
+
# speed
|
327
|
+
# Numeric
|
328
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
329
|
+
# example: 1
|
330
|
+
#
|
331
|
+
# direction
|
332
|
+
# Symbol
|
333
|
+
# description: Direction of the gesture. Please see this table for valid direction symbols.
|
334
|
+
# example: :Left
|
335
|
+
#
|
336
|
+
# Integer
|
337
|
+
# description: Direction of the gesture as degrees with 0 being up and 90 right.
|
338
|
+
# example: 270
|
339
|
+
#
|
340
|
+
# distance
|
341
|
+
# Integer
|
342
|
+
# description: Number of pixels that the object is to be moved in the gesture.
|
343
|
+
# example: 100
|
344
|
+
#
|
345
|
+
# optional_params
|
346
|
+
# Hash
|
347
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
348
|
+
# example: { :button => :Right }
|
349
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
350
|
+
#
|
351
|
+
# == returns
|
352
|
+
# NilClass
|
353
|
+
# description: Always returns nil
|
354
|
+
# example: nil
|
355
|
+
#
|
356
|
+
# == exceptions
|
357
|
+
# ArgumentError
|
358
|
+
# description: One of the arguments is not valid, or the initial point is outside the target object.
|
359
|
+
#
|
360
|
+
def gesture_from(x, y, speed, distance, direction, optional_params = {:button => :Left, :isDrag => false})
|
361
|
+
begin
|
362
|
+
raise ArgumentError.new( "Coordinate x:#{x} x_abs:#{x} outside object." ) unless ( x <= attribute( 'width' ).to_i and x >= 0 )
|
363
|
+
raise ArgumentError.new( "Coordinate y:#{y} y_abs:#{y} outside object." ) unless ( y <= attribute( 'height' ).to_i and y >= 0 )
|
364
|
+
|
365
|
+
x_absolute = attribute('x_absolute').to_i + x.to_i
|
366
|
+
y_absolute = attribute('y_absolute').to_i + y.to_i
|
367
|
+
|
368
|
+
params = {:gesture_type => :MouseGestureFromCoordinates, :x => x_absolute, :y => y_absolute, :speed => speed, :distance => distance, :direction => direction}
|
369
|
+
|
370
|
+
params.merge!(optional_params)
|
371
|
+
do_gesture(params)
|
372
|
+
do_sleep(speed)
|
373
|
+
|
374
|
+
|
375
|
+
rescue Exception => e
|
376
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed gesture_from with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\", button \".;#{identity};gesture;"
|
377
|
+
Kernel::raise e
|
378
|
+
end
|
379
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation gesture_from executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;"
|
380
|
+
nil
|
381
|
+
end
|
382
|
+
|
383
|
+
# == description
|
384
|
+
# Perform a gesture with the object, ending the gesture at the center of another object.
|
385
|
+
#
|
386
|
+
# == arguments
|
387
|
+
# target_object
|
388
|
+
# TestObject
|
389
|
+
# description: The object where the gesture should end.
|
390
|
+
# example: @app.Node
|
391
|
+
#
|
392
|
+
# duration
|
393
|
+
# Numeric
|
394
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
395
|
+
# example: 1
|
396
|
+
#
|
397
|
+
# optional_params
|
398
|
+
# Hash
|
399
|
+
# description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
|
400
|
+
# example: { :button => :Right }
|
401
|
+
# default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
|
402
|
+
#
|
403
|
+
# == returns
|
404
|
+
# NilClass
|
405
|
+
# description: Always returns nil
|
406
|
+
# example: nil
|
407
|
+
#
|
408
|
+
# == exceptions
|
409
|
+
# ArgumentError
|
410
|
+
# description: One of the arguments is not valid
|
411
|
+
def gesture_to_object(target_object, duration, optional_params = {:button => :Left, :isDrag => false})
|
412
|
+
|
413
|
+
begin
|
414
|
+
# change the format for api consitency
|
415
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
416
|
+
optional_params[:use_tap_screen].to_s
|
417
|
+
optional_params[:useTapScreen] = use_tap_screen
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
params = {:gesture_type => :MouseGestureTo, :speed => duration}
|
422
|
+
params[:targetId] = target_object.id
|
423
|
+
params[:targetType] = target_object.attribute('objectType')
|
424
|
+
params.merge!(optional_params)
|
425
|
+
do_gesture(params)
|
426
|
+
do_sleep(duration)
|
427
|
+
|
428
|
+
rescue Exception => e
|
429
|
+
|
430
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed gesture_to_object with button.;#{identity};drag;"
|
431
|
+
Kernel::raise e
|
432
|
+
|
433
|
+
end
|
434
|
+
|
435
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation gesture_to_object executed successfully with button.;#{identity};drag;"
|
436
|
+
|
437
|
+
nil
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
# == description
|
442
|
+
# Perform a gesture following a track of points.
|
443
|
+
#
|
444
|
+
# == arguments
|
445
|
+
# points
|
446
|
+
# Array
|
447
|
+
# description: Each element of this Array defines a point of the gesture as a Hash. Three keys with Integer values are defined for a point: the coordinate as "x" and "y" keys and "interval" as seconds (Note that this is likely a very short time, i.e. fraction of a second).
|
448
|
+
# example: [{"x" => 200,"y" => 100, "interval" => 0.15},{"x" => 200,"y" => 110, "interval" => 0.30}]
|
449
|
+
#
|
450
|
+
# duration
|
451
|
+
# Numeric
|
452
|
+
# description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
|
453
|
+
# example: 1
|
454
|
+
#
|
455
|
+
# mouse_details
|
456
|
+
# Hash
|
457
|
+
# description: Mouse usage details can be defined by setting the :press, :release and :isDrag keys to true or false. Valid values for the :button key are described in [link="#buttons_table"]the buttons table[/link].
|
458
|
+
# example: { :press => true, :release => true, :button => :Right, :isDrag => false}
|
459
|
+
# default: { :press => true, :release => true, :button => :Left, :isDrag => true}
|
460
|
+
#
|
461
|
+
# optional_params
|
462
|
+
# Hash
|
463
|
+
# description: This method only supports the :use_tap_screen optional parameter.
|
464
|
+
# example: { :use_tap_screen => true }
|
465
|
+
# default: { :use_tap_screen => false }
|
466
|
+
#
|
467
|
+
# == returns
|
468
|
+
# NilClass
|
469
|
+
# description: Always returns nil
|
470
|
+
# example: nil
|
471
|
+
#
|
472
|
+
# == exceptions
|
473
|
+
# ArgumentError
|
474
|
+
# description: One of the arguments is not valid
|
475
|
+
def gesture_points( points, duration, mouse_details = { :press => true, :release => true, :button => :Left, :isDrag => true}, optional_params = {} )
|
476
|
+
|
477
|
+
begin
|
478
|
+
|
479
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
480
|
+
optional_params[:use_tap_screen].to_s
|
481
|
+
optional_params[:useTapScreen] = use_tap_screen
|
482
|
+
|
483
|
+
mouse_details[:press] = true unless mouse_details.has_value?(:press)
|
484
|
+
mouse_details[:release] = true unless mouse_details.has_value?(:release)
|
485
|
+
mouse_details[:button] = :Left unless mouse_details.has_value?(:button)
|
486
|
+
mouse_details[:isDrag] = true unless mouse_details.has_value?(:isDrag)
|
487
|
+
|
488
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(mouse_details[:button])
|
489
|
+
|
490
|
+
command = command_params #in qt_behaviour
|
491
|
+
command.command_name('MouseGesturePoints')
|
492
|
+
params = {'mouseMove'=>'true'}
|
493
|
+
|
494
|
+
params['button'] = @@_buttons_map[mouse_details[:button]]
|
495
|
+
params['press'] = 'false' unless mouse_details[:press]
|
496
|
+
params['release'] = 'false' unless mouse_details[:release]
|
497
|
+
params['isDrag'] = 'true' if mouse_details[:isDrag]
|
498
|
+
params.merge!(optional_params)
|
499
|
+
|
500
|
+
|
501
|
+
millis = duration.to_f
|
502
|
+
millis = millis*1000
|
503
|
+
speed = millis.to_i
|
504
|
+
params['speed'] = speed.to_s
|
505
|
+
command.command_params(params)
|
506
|
+
point_string = ""
|
507
|
+
points.each { |point| point_string << point["x"].to_s << "," << point["y"].to_s << "," << (point["interval"]*1000).to_i.to_s << ";"}
|
508
|
+
command.command_value(point_string)
|
509
|
+
|
510
|
+
@sut.execute_command(command)
|
511
|
+
|
512
|
+
do_sleep(duration)
|
513
|
+
|
514
|
+
rescue Exception => e
|
515
|
+
|
516
|
+
MobyUtil::Logger.instance.log "behaviour",
|
517
|
+
"FAIL;Failed drag_to_object with points \"#{points.to_s}\", duration \"#{duration.to_s}\", mouse_details \"#{mouse_details.to_s}\".;#{identity};gesture_points;"
|
518
|
+
Kernel::raise e
|
519
|
+
|
520
|
+
end
|
521
|
+
|
522
|
+
MobyUtil::Logger.instance.log "behaviour",
|
523
|
+
"PASS;Operation drag_to_object executed successfully with points \"#{points.to_s}\", duration \"#{duration.to_s}\", mouse_details \"#{mouse_details.to_s}\".;#{identity};gesture_points;"
|
524
|
+
|
525
|
+
nil
|
526
|
+
end
|
527
|
+
|
528
|
+
# == description
|
529
|
+
# Drag the object for the given distance.
|
530
|
+
# By default a drag is a slow gesture.
|
531
|
+
#
|
532
|
+
# == arguments
|
533
|
+
# direction
|
534
|
+
# Symbol
|
535
|
+
# description: Direction of the drag. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
536
|
+
# example: :Left
|
537
|
+
#
|
538
|
+
# Integer
|
539
|
+
# description: Direction of the drag as degrees with 0 being up and 90 right.
|
540
|
+
# example: 270
|
541
|
+
#
|
542
|
+
# distance
|
543
|
+
# Integer
|
544
|
+
# description: Number of pixels that the object is to be dragged.
|
545
|
+
# example: 100
|
546
|
+
#
|
547
|
+
# button
|
548
|
+
# Symbol
|
549
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
550
|
+
# example: :Right
|
551
|
+
# default: :Left
|
552
|
+
#
|
553
|
+
# optional_params
|
554
|
+
# Hash
|
555
|
+
# description: The only optional argument supported by drag is :use_tap_screen.
|
556
|
+
# example: { :use_tap_screen => 'true' }
|
557
|
+
# default: { :use_tap_screen => 'false' }
|
558
|
+
#
|
559
|
+
# == returns
|
560
|
+
# NilClass
|
561
|
+
# description: Always returns nil
|
562
|
+
# example: nil
|
563
|
+
#
|
564
|
+
# == exceptions
|
565
|
+
# ArgumentError
|
566
|
+
# description: One of the arguments is not valid
|
567
|
+
def drag(direction, distance, button = :Left, optional_params = {})
|
568
|
+
|
569
|
+
begin
|
570
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
571
|
+
optional_params[:use_tap_screen].to_s
|
572
|
+
optional_params[:useTapScreen] = use_tap_screen
|
573
|
+
|
574
|
+
speed = calculate_speed( distance, @sut.parameter[ :gesture_drag_speed ] )
|
575
|
+
params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => true, :button => button}
|
576
|
+
params.merge!(optional_params)
|
577
|
+
do_gesture(params)
|
578
|
+
do_sleep( speed )
|
579
|
+
|
580
|
+
rescue Exception => e
|
581
|
+
|
582
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed drag with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
|
583
|
+
Kernel::raise e
|
584
|
+
|
585
|
+
end
|
586
|
+
|
587
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation drag executed successfully with direction \"#{direction}\", distance \"#{distance}\", button \"#{button.to_s}\".;#{identity};drag;"
|
588
|
+
|
589
|
+
nil
|
590
|
+
end
|
591
|
+
|
592
|
+
# == description
|
593
|
+
# Drag the object to the given coordinates.
|
594
|
+
# By default a drag is a slow gesture.
|
595
|
+
#
|
596
|
+
# == arguments
|
597
|
+
# x
|
598
|
+
# Integer
|
599
|
+
# description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
600
|
+
# example: 300
|
601
|
+
#
|
602
|
+
# y
|
603
|
+
# Integer
|
604
|
+
# description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
|
605
|
+
# example: 300
|
606
|
+
#
|
607
|
+
# button
|
608
|
+
# Symbol
|
609
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
610
|
+
# example: :Right
|
611
|
+
# default: :Left
|
612
|
+
#
|
613
|
+
# optional_params
|
614
|
+
# Hash
|
615
|
+
# description: The only optional argument supported by drag_to is :use_tap_screen.
|
616
|
+
# example: { :use_tap_screen => 'true' }
|
617
|
+
# default: { :use_tap_screen => 'false' }
|
618
|
+
#
|
619
|
+
# == returns
|
620
|
+
# NilClass
|
621
|
+
# description: Always returns nil
|
622
|
+
# example: nil
|
623
|
+
#
|
624
|
+
# == exceptions
|
625
|
+
# ArgumentError
|
626
|
+
# description: One of the arguments is not valid
|
627
|
+
def drag_to( x, y, button = :Left, optional_params= {} )
|
628
|
+
|
629
|
+
begin
|
630
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
631
|
+
optional_params[:use_tap_screen].to_s
|
632
|
+
optional_params[:useTapScreen] = use_tap_screen
|
633
|
+
|
634
|
+
|
635
|
+
distance = distance_to_point(x,y)
|
636
|
+
return if distance == 0
|
637
|
+
|
638
|
+
speed = calculate_speed(distance, @sut.parameter[:gesture_drag_speed])
|
639
|
+
params = {:gesture_type => :MouseGestureToCoordinates, :x => x, :y => y, :speed => speed, :isDrag => true, :button => button}
|
640
|
+
params.merge!(optional_params)
|
641
|
+
do_gesture(params)
|
642
|
+
do_sleep( speed )
|
643
|
+
|
644
|
+
rescue Exception => e
|
645
|
+
|
646
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed drag_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
647
|
+
Kernel::raise e
|
648
|
+
|
649
|
+
end
|
650
|
+
|
651
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation drag_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
|
652
|
+
|
653
|
+
nil
|
654
|
+
|
655
|
+
end
|
656
|
+
|
657
|
+
# == description
|
658
|
+
# Drag the object to the center of another object.
|
659
|
+
# By default a drag is a slow gesture.
|
660
|
+
#
|
661
|
+
# == arguments
|
662
|
+
# target_object
|
663
|
+
# TestObject
|
664
|
+
# description: The object that this object should be dragged to.
|
665
|
+
# example: @app.Node
|
666
|
+
#
|
667
|
+
# button
|
668
|
+
# Symbol
|
669
|
+
# description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
670
|
+
# example: :Right
|
671
|
+
# default: :Left
|
672
|
+
#
|
673
|
+
# optional_params
|
674
|
+
# Hash
|
675
|
+
# description: The only optional argument supported by drag_to_object is :use_tap_screen.
|
676
|
+
# example: { :use_tap_screen => 'true' }
|
677
|
+
# default: { :use_tap_screen => 'false' }
|
678
|
+
#
|
679
|
+
# == returns
|
680
|
+
# NilClass
|
681
|
+
# description: Always returns nil
|
682
|
+
# example: nil
|
683
|
+
#
|
684
|
+
# == exceptions
|
685
|
+
# ArgumentError
|
686
|
+
# description: One of the arguments is not valid
|
687
|
+
def drag_to_object(target_object, button = :Left, optional_params = {})
|
688
|
+
|
689
|
+
begin
|
690
|
+
|
691
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
692
|
+
optional_params[:use_tap_screen].to_s
|
693
|
+
optional_params[:useTapScreen] = use_tap_screen
|
694
|
+
|
695
|
+
distance = distance_to_point(target_object.object_center_x, target_object.object_center_y)
|
696
|
+
#no drag needed, maybe even attempting to drag to it self
|
697
|
+
return if distance == 0
|
698
|
+
|
699
|
+
speed = calculate_speed(distance, @sut.parameter[:gesture_drag_speed])
|
700
|
+
params = {:gesture_type => :MouseGestureTo, :speed => speed, :isDrag => true, :button => button}
|
701
|
+
params[:targetId] = target_object.id
|
702
|
+
params[:targetType] = target_object.attribute('objectType')
|
703
|
+
params.merge!(optional_params)
|
704
|
+
do_gesture(params)
|
705
|
+
do_sleep(speed)
|
706
|
+
|
707
|
+
rescue Exception => e
|
708
|
+
|
709
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed drag_to_object with button \"#{button.to_s}\".;#{identity};drag;"
|
710
|
+
Kernel::raise e
|
711
|
+
|
712
|
+
end
|
713
|
+
|
714
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation drag_to_object executed successfully with button \"#{button.to_s}\".;#{identity};drag;"
|
715
|
+
|
716
|
+
nil
|
717
|
+
|
718
|
+
end
|
719
|
+
|
720
|
+
# == description
|
721
|
+
# Perform a pointer move starting at the object
|
722
|
+
#
|
723
|
+
# == arguments
|
724
|
+
# direction
|
725
|
+
# Symbol
|
726
|
+
# description: Direction of the move. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
|
727
|
+
# example: :Left
|
728
|
+
#
|
729
|
+
# Integer
|
730
|
+
# description: Direction of the move as degrees with 0 being up and 90 right.
|
731
|
+
# example: 270
|
732
|
+
#
|
733
|
+
# distance
|
734
|
+
# Integer
|
735
|
+
# description: Number of pixels to be moved.
|
736
|
+
# example: 100
|
737
|
+
#
|
738
|
+
# button
|
739
|
+
# Symbol
|
740
|
+
# description: The mouse button used with the move can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
|
741
|
+
# example: :Right
|
742
|
+
# default: :Left
|
743
|
+
#
|
744
|
+
# optional_params
|
745
|
+
# Hash
|
746
|
+
# description: The only optional argument supported by drag_to_object is :use_tap_screen.
|
747
|
+
# example: { :use_tap_screen => 'true' }
|
748
|
+
# default: { :use_tap_screen => 'false' }
|
749
|
+
#
|
750
|
+
# == returns
|
751
|
+
# NilClass
|
752
|
+
# description: Always returns nil
|
753
|
+
# example: nil
|
754
|
+
#
|
755
|
+
# == exceptions
|
756
|
+
# ArgumentError
|
757
|
+
# description: One of the arguments is not valid
|
758
|
+
def move(direction, distance, button = :Left, optional_params = {})
|
759
|
+
|
760
|
+
begin
|
761
|
+
|
762
|
+
use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
|
763
|
+
optional_params[:use_tap_screen].to_s
|
764
|
+
optional_params[:useTapScreen] = use_tap_screen
|
765
|
+
|
766
|
+
speed = calculate_speed( distance, @sut.parameter[ :gesture_drag_speed ] )
|
767
|
+
params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => button, :isMove => true}
|
768
|
+
params.merge!(optional_params)
|
769
|
+
do_gesture(params)
|
770
|
+
do_sleep( speed )
|
771
|
+
|
772
|
+
rescue Exception => e
|
773
|
+
|
774
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed move with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
|
775
|
+
Kernel::raise e
|
776
|
+
|
777
|
+
end
|
778
|
+
|
779
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation move executed successfully with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;"
|
780
|
+
|
781
|
+
nil
|
782
|
+
end
|
783
|
+
|
784
|
+
|
785
|
+
# == nodoc
|
786
|
+
# utility function for getting the x coordinate of the center of the object, should this be private method?
|
787
|
+
def object_center_x
|
788
|
+
center_x
|
789
|
+
end
|
790
|
+
|
791
|
+
# == nodoc
|
792
|
+
# utility function for getting the y coordinate of the center of the object, should this be private method?
|
793
|
+
def object_center_y
|
794
|
+
center_y
|
795
|
+
end
|
796
|
+
|
797
|
+
|
798
|
+
|
799
|
+
|
800
|
+
private
|
801
|
+
|
802
|
+
# Performs the actual gesture operation.
|
803
|
+
# Verifies that the parameters are correct and send the command
|
804
|
+
# to the sut.
|
805
|
+
# gesture_type: :MouseGesture, :MouseGestureTo, :MouseGestureToCoordinates
|
806
|
+
# params = {:direction => :Up, duration => 2, :distance =>100, :isDrag =>false, :isMove =>false }
|
807
|
+
def do_gesture(params)
|
808
|
+
validate_gesture_params!(params)
|
809
|
+
|
810
|
+
if attribute('objectType') == 'Embedded'
|
811
|
+
params['x'] = center_x
|
812
|
+
params['y'] = center_y
|
813
|
+
params['useCoordinates'] = 'true'
|
814
|
+
end
|
815
|
+
|
816
|
+
command = command_params #in qt_behaviour
|
817
|
+
command.command_name(params[:gesture_type].to_s)
|
818
|
+
command.command_params( params )
|
819
|
+
@sut.execute_command( command )
|
820
|
+
end
|
821
|
+
|
822
|
+
def validate_gesture_params!(params)
|
823
|
+
#direction
|
824
|
+
if params[:gesture_type] == :MouseGesture or params[:gesture_type] == :MouseGestureFromCoordinates
|
825
|
+
if params[:direction].kind_of?(Integer)
|
826
|
+
raise ArgumentError.new( "Invalid direction." ) unless 0 <= params[:direction].to_i and params[:direction].to_i <= 360
|
827
|
+
else
|
828
|
+
raise ArgumentError.new( "Invalid direction." ) unless @@_valid_directions.include?(params[:direction])
|
829
|
+
params[:direction] = @@_direction_map[params[:direction]]
|
830
|
+
end
|
831
|
+
#distance
|
832
|
+
params[:distance] = params[:distance].to_i unless params[:distance].kind_of?(Integer)
|
833
|
+
raise ArgumentError.new( "Distance must be an integer and greater than zero." ) unless params[:distance] > 0
|
834
|
+
elsif params[:gesture_type] == :MouseGestureToCoordinates or params[:gesture_type] == :MouseGestureFromCoordinates
|
835
|
+
raise ArgumentError.new("X and Y must be integers.") unless params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
|
836
|
+
elsif params[:gesture_type] == :MouseGestureTo
|
837
|
+
raise ArgumentError.new("targetId and targetType must be defined.") unless params[:targetId] and params[:targetType]
|
838
|
+
end
|
839
|
+
|
840
|
+
#duration/speed
|
841
|
+
params[:speed] = params[:speed].to_f unless params[:speed].kind_of?(Numeric)
|
842
|
+
raise ArgumentError.new( "Duration must be a number and greated than zero, was:" + params[:speed].to_s) unless params[:speed] > 0
|
843
|
+
duration_secs = params[:speed].to_f
|
844
|
+
duration_secs = duration_secs*1000
|
845
|
+
params[:speed] = duration_secs.to_i
|
846
|
+
|
847
|
+
#mouseMove true always
|
848
|
+
params[:mouseMove] = true
|
849
|
+
|
850
|
+
params[:button] = :Left unless params[:button]
|
851
|
+
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(params[:button])
|
852
|
+
params[:button] = @@_buttons_map[params[:button]]
|
853
|
+
|
854
|
+
if params[:isMove] == true
|
855
|
+
params[:press] = 'false'
|
856
|
+
params[:release] = 'false'
|
857
|
+
end
|
858
|
+
|
859
|
+
end
|
860
|
+
|
861
|
+
|
862
|
+
def do_sleep(time)
|
863
|
+
|
864
|
+
if MobyUtil::Parameter[ @sut.id ][ :sleep_disabled, nil ] != 'true'
|
865
|
+
time = time.to_f
|
866
|
+
time = time * 1.3
|
867
|
+
#for flicks the duration of the gesture is short but animation (scroll etc..) may not
|
868
|
+
#so wait at least one second
|
869
|
+
time = 1 if time < 1
|
870
|
+
sleep time
|
871
|
+
else
|
872
|
+
#store the biggest value which will then be used in multitouch situations to sleep
|
873
|
+
MobyUtil::Parameter[ @sut.id ][ :skipped_sleep_time ] = time if time > MobyUtil::Parameter[ @sut.id ][ :skipped_sleep_time, 0]
|
874
|
+
end
|
875
|
+
|
876
|
+
end
|
877
|
+
|
878
|
+
def calculate_speed(distance, speed)
|
879
|
+
|
880
|
+
distance = distance.to_f
|
881
|
+
speed = speed.to_f
|
882
|
+
duration = distance/speed
|
883
|
+
duration
|
884
|
+
|
885
|
+
end
|
886
|
+
|
887
|
+
def distance_to_point(x, y)
|
888
|
+
|
889
|
+
x = x.to_i
|
890
|
+
y = y.to_i
|
891
|
+
dist_x = x - center_x.to_i
|
892
|
+
dist_y = y - center_y.to_i
|
893
|
+
|
894
|
+
return 0 if dist_y == 0 and dist_x == 0
|
895
|
+
distance = Math.hypot( dist_x, dist_y )
|
896
|
+
distance
|
897
|
+
|
898
|
+
end
|
899
|
+
|
900
|
+
# enable hooking for performance measurement & debug logging
|
901
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
902
|
+
|
903
|
+
end
|
904
|
+
|
905
|
+
end
|
906
|
+
end
|