testability-driver-qt-sut-plugin 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/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,227 @@
|
|
|
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
|
+
# Behaviours for handling attributes
|
|
26
|
+
#
|
|
27
|
+
# == behaviour
|
|
28
|
+
# QtAttribute
|
|
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 Attribute
|
|
46
|
+
|
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
|
48
|
+
|
|
49
|
+
# == description
|
|
50
|
+
# Sets an attribute of the target object.
|
|
51
|
+
#
|
|
52
|
+
# == arguments
|
|
53
|
+
# attribute
|
|
54
|
+
# String
|
|
55
|
+
# description: Name of the attribute to be set
|
|
56
|
+
# example: "text"
|
|
57
|
+
#
|
|
58
|
+
# value
|
|
59
|
+
# String
|
|
60
|
+
# description: New value of the attribute.
|
|
61
|
+
# example: "Menu"
|
|
62
|
+
#
|
|
63
|
+
# Integer
|
|
64
|
+
# description: New value of the attribute.
|
|
65
|
+
# example: 200
|
|
66
|
+
#
|
|
67
|
+
# Boolean
|
|
68
|
+
# description: New value of the attribute.
|
|
69
|
+
# example: true
|
|
70
|
+
#
|
|
71
|
+
# type
|
|
72
|
+
# String
|
|
73
|
+
# description: Type of the value. If this argument is not given, the type will be detected based on the class of the value argument.
|
|
74
|
+
# example: "QPoint"
|
|
75
|
+
# default: nil
|
|
76
|
+
#
|
|
77
|
+
# == tables
|
|
78
|
+
# attribute_types_table
|
|
79
|
+
# title: Valid type argument values
|
|
80
|
+
# |Type|Example|
|
|
81
|
+
# |QRect|'10,10,150,150'|
|
|
82
|
+
# |QPoint|'100,200'|
|
|
83
|
+
# |QSize|'50,80'|
|
|
84
|
+
# |QDate|'15.08.2009'|
|
|
85
|
+
# |QDateTime|'1373352400'|
|
|
86
|
+
#
|
|
87
|
+
# == returns
|
|
88
|
+
# NilClass
|
|
89
|
+
# description: Always returns nil
|
|
90
|
+
# example: nil
|
|
91
|
+
#
|
|
92
|
+
# == exceptions
|
|
93
|
+
# ArgumentError
|
|
94
|
+
# description: One of the arguments is not valid
|
|
95
|
+
# RuntimeError
|
|
96
|
+
# description: Setting of the attribute failed
|
|
97
|
+
def set_attribute(attribute, value, type = nil)
|
|
98
|
+
|
|
99
|
+
Kernel::raise ArgumentError.new( "Attribute-name was empty" ) if attribute.empty?
|
|
100
|
+
Kernel::raise ArgumentError.new( "Argument type must be nil or a non empty String." ) unless type.nil? || ( type.kind_of?( String ) && !type.empty? )
|
|
101
|
+
|
|
102
|
+
command = command_params #in qt_behaviour
|
|
103
|
+
command.transitions_off
|
|
104
|
+
command.command_name( 'SetAttribute' )
|
|
105
|
+
|
|
106
|
+
case type
|
|
107
|
+
|
|
108
|
+
when nil
|
|
109
|
+
|
|
110
|
+
# Implicit typing
|
|
111
|
+
|
|
112
|
+
# by class
|
|
113
|
+
if value.kind_of? Integer
|
|
114
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s.strip, 'attribute_type' => 'int'}
|
|
115
|
+
|
|
116
|
+
elsif value.kind_of? Date
|
|
117
|
+
temp_date = value.day.to_s << '.' << value.month.to_s << '.' << value.year.to_s
|
|
118
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => temp_date, 'attribute_type' => 'QDate' }
|
|
119
|
+
|
|
120
|
+
elsif value.kind_of? Time
|
|
121
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_i.to_s, 'attribute_type' => 'QDateTime' }
|
|
122
|
+
|
|
123
|
+
elsif value.kind_of? DateTime
|
|
124
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => Time.parse(value.to_s).to_i.to_s, 'attribute_type' => 'QDateTime' }
|
|
125
|
+
|
|
126
|
+
elsif value.kind_of? TrueClass
|
|
127
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s.downcase, 'attribute_type' => 'bool'}
|
|
128
|
+
|
|
129
|
+
elsif value.kind_of? FalseClass
|
|
130
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s.downcase, 'attribute_type' => 'bool'}
|
|
131
|
+
|
|
132
|
+
else
|
|
133
|
+
# by format
|
|
134
|
+
# if ( value.kind_of?( Integer ) || ( value.kind_of?( String ) && value.strip == value.strip.to_i.to_s ) )
|
|
135
|
+
if value.kind_of?( String ) && value.strip == value.strip.to_i.to_s
|
|
136
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s.strip, 'attribute_type' => 'int'}
|
|
137
|
+
|
|
138
|
+
elsif (value == true || value == false || (value.kind_of?(String) && (value.strip.downcase == "true" || value.strip.downcase == "false")))
|
|
139
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s.downcase, 'attribute_type' => 'bool'}
|
|
140
|
+
|
|
141
|
+
else
|
|
142
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s, 'attribute_type' => 'string'}
|
|
143
|
+
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
when "QRect"
|
|
149
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s, 'attribute_type' => 'QRect'}
|
|
150
|
+
|
|
151
|
+
when "QPoint"
|
|
152
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s, 'attribute_type' => 'QPoint'}
|
|
153
|
+
|
|
154
|
+
when "QSize"
|
|
155
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s, 'attribute_type' => 'QSize'}
|
|
156
|
+
|
|
157
|
+
when "QDateTime"
|
|
158
|
+
|
|
159
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_type' => 'QDateTime' }
|
|
160
|
+
|
|
161
|
+
if value.kind_of? String
|
|
162
|
+
params[ 'attribute_value' ] = value.to_s
|
|
163
|
+
|
|
164
|
+
elsif value.kind_of? Integer
|
|
165
|
+
params[ 'attribute_value' ] = value.to_s
|
|
166
|
+
|
|
167
|
+
elsif value.kind_of? Time
|
|
168
|
+
params[ 'attribute_value' ] = value.to_i.to_s
|
|
169
|
+
|
|
170
|
+
elsif value.kind_of? DateTime
|
|
171
|
+
params[ 'attribute_value' ] = Time.parse( value.to_s ).to_i.to_s
|
|
172
|
+
|
|
173
|
+
else
|
|
174
|
+
Kernel::raise ArgumentError.new( "The value for QDateTime type attributes must be of type String, Integer, Time or DateTime, it was #{value.class.to_s}." )
|
|
175
|
+
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
when "QDate"
|
|
179
|
+
|
|
180
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_type' => 'QDate' }
|
|
181
|
+
|
|
182
|
+
if value.kind_of? String
|
|
183
|
+
params[ 'attribute_value' ] = value.to_s
|
|
184
|
+
|
|
185
|
+
elsif value.kind_of? Date
|
|
186
|
+
temp_date = value.day.to_s << '.' << value.month.to_s << '.' << value.year.to_s
|
|
187
|
+
params[ 'attribute_value' ] = temp_date
|
|
188
|
+
|
|
189
|
+
else
|
|
190
|
+
Kernel::raise ArgumentError.new( "The value for QDate type attributes must be of type String or Date, it was #{value.class.to_s}." )
|
|
191
|
+
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
else
|
|
195
|
+
|
|
196
|
+
#puts "Unidentified.\nName: " << attribute.to_s << "\nValue: " << value.to_s << "\nType: " << type.to_s
|
|
197
|
+
params = { 'attribute_name' => attribute.to_s, 'attribute_value' => value.to_s, 'attribute_type' => type.to_s }
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
command.command_params( params )
|
|
202
|
+
command.service( 'objectManipulation' )
|
|
203
|
+
returnValue = @sut.execute_command( command )
|
|
204
|
+
|
|
205
|
+
returnValue = "OK"
|
|
206
|
+
begin
|
|
207
|
+
returnValue = @sut.execute_command( command )
|
|
208
|
+
rescue
|
|
209
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed when calling method set_attribute with values attribute:#{attribute.to_s} value:#{value.to_s}.;#{identity};set_attribute;"
|
|
210
|
+
Kernel::raise RuntimeError.new("Setting attribute '%s' to value '%s' failed with error: %s" % [attribute, value, returnValue])
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;The method set_attribute was executed successfully with with values attribute:#{attribute.to_s} value:#{value.to_s}.;#{identity};set_attribute;"
|
|
214
|
+
|
|
215
|
+
nil
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# enable hooking for performance measurement & debug logging
|
|
221
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
end
|
|
227
|
+
end
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
# Base behaviour
|
|
26
|
+
#
|
|
27
|
+
# == behaviour
|
|
28
|
+
# QtBehaviour
|
|
29
|
+
#
|
|
30
|
+
# == requires
|
|
31
|
+
# sut_qt
|
|
32
|
+
#
|
|
33
|
+
# == sut_type
|
|
34
|
+
# qt
|
|
35
|
+
#
|
|
36
|
+
# == input_type
|
|
37
|
+
# All
|
|
38
|
+
#
|
|
39
|
+
# == sut_version
|
|
40
|
+
# *
|
|
41
|
+
#
|
|
42
|
+
# == objects
|
|
43
|
+
# sut;application
|
|
44
|
+
#
|
|
45
|
+
module Behaviour
|
|
46
|
+
|
|
47
|
+
include MobyBehaviour::Behaviour
|
|
48
|
+
|
|
49
|
+
@@_valid_buttons = [ :NoButton, :Left, :Right, :Middle ]
|
|
50
|
+
@@_buttons_map = { :NoButton => '0', :Left => '1', :Right => '2', :Middle => '4' }
|
|
51
|
+
@@_valid_directions = [ :Up, :Down, :Left, :Right ]
|
|
52
|
+
@@_direction_map = { :Up => '0', :Down => '180', :Left => '270', :Right => '90' }
|
|
53
|
+
@@_pinch_directions = { :Horizontal => '90', :Vertical => '0'}
|
|
54
|
+
@@_rotate_direction = [ :Clockwise, :CounterClockwise ]
|
|
55
|
+
|
|
56
|
+
# == nodoc
|
|
57
|
+
# should this method be private?
|
|
58
|
+
def command_params( command = MobyCommand::WidgetCommand.new )
|
|
59
|
+
|
|
60
|
+
if self.attribute( 'objectType' ) == 'Graphics' and self.attribute( 'visibleOnScreen' ) == 'false' and self.creation_attributes[:visibleOnScreen] != 'false'
|
|
61
|
+
begin
|
|
62
|
+
self.creation_attributes.merge!({'visibleOnScreen' => 'true'})
|
|
63
|
+
self.parent.child(self.creation_attributes)
|
|
64
|
+
rescue
|
|
65
|
+
Kernel::raise MobyBase::TestObjectNotVisibleError
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
command.set_event_type(MobyUtil::Parameter[ @sut.id ][ :event_type, "0" ])
|
|
70
|
+
|
|
71
|
+
#for components with object visible on screen but not actual widgets or graphicsitems
|
|
72
|
+
if self.attribute( 'objectType' ) == 'Embedded'
|
|
73
|
+
command.application_id( get_application_id )
|
|
74
|
+
command.object_id( parent.id )
|
|
75
|
+
command.object_type( parent.attribute( 'objectType' ).intern )
|
|
76
|
+
else
|
|
77
|
+
command.application_id( get_application_id )
|
|
78
|
+
command.object_id( self.id )
|
|
79
|
+
command.object_type( self.attribute( 'objectType' ).intern )
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
command
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# == nodoc
|
|
87
|
+
# should this method be private?
|
|
88
|
+
def plugin_command( require_response = false, command = MobyCommand::WidgetCommand.new )
|
|
89
|
+
command.set_event_type(MobyUtil::Parameter[ @sut.id ][ :event_type, "0" ])
|
|
90
|
+
command.application_id( get_application_id )
|
|
91
|
+
command.object_id( self.id )
|
|
92
|
+
command.object_type( self.attribute('objectType' ).intern)
|
|
93
|
+
command.transitions_off
|
|
94
|
+
command
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
def do_sleep(time)
|
|
100
|
+
|
|
101
|
+
time = time.to_f
|
|
102
|
+
time = time * 1.3
|
|
103
|
+
#for flicks the duration of the gesture is short but animation (scroll etc..) may not
|
|
104
|
+
#so wait at least one second
|
|
105
|
+
time = 1 if time < 1
|
|
106
|
+
sleep time
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def center_x
|
|
111
|
+
|
|
112
|
+
#x = self.attribute( 'x_absolute' ).to_i
|
|
113
|
+
#width = self.attribute( 'width' ).to_i
|
|
114
|
+
#x = x + ( width/2 )
|
|
115
|
+
#x.to_s
|
|
116
|
+
|
|
117
|
+
( ( self.attribute( 'x_absolute' ).to_i ) + ( self.attribute( 'width' ).to_i / 2 ) ).to_s
|
|
118
|
+
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def center_y
|
|
122
|
+
|
|
123
|
+
#y = self.attribute( 'y_absolute' ).to_i
|
|
124
|
+
#height = self.attribute( 'height' ).to_i
|
|
125
|
+
#y = y + ( height/2 )
|
|
126
|
+
#y.to_s
|
|
127
|
+
|
|
128
|
+
( ( self.attribute( 'y_absolute' ).to_i ) + ( self.attribute( 'height' ).to_i / 2 ) ).to_s
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# enable hooking for performance measurement & debug logging
|
|
133
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
134
|
+
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
140
|
+
|
|
@@ -0,0 +1,317 @@
|
|
|
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
|
+
# Behaviours for configuring the logging services on the target.
|
|
26
|
+
#
|
|
27
|
+
# == behaviour
|
|
28
|
+
# QtConfigureBehaviour
|
|
29
|
+
#
|
|
30
|
+
# == requires
|
|
31
|
+
# testability-driver-qt-sut-plugin
|
|
32
|
+
#
|
|
33
|
+
# == sut_type
|
|
34
|
+
# qt
|
|
35
|
+
#
|
|
36
|
+
# == input_type
|
|
37
|
+
# All
|
|
38
|
+
#
|
|
39
|
+
# == sut_version
|
|
40
|
+
# *
|
|
41
|
+
#
|
|
42
|
+
# == objects
|
|
43
|
+
# sut;application
|
|
44
|
+
#
|
|
45
|
+
module ConfigureBehaviour
|
|
46
|
+
|
|
47
|
+
include MobyBehaviour::QT::Behaviour
|
|
48
|
+
|
|
49
|
+
@@_valid_levels = [ :FATAL, :ERROR, :INFO, :WARNING, :DEBUG ]
|
|
50
|
+
|
|
51
|
+
# == description
|
|
52
|
+
# Enabled the logging on the target for the given application or sut (qttasserver).
|
|
53
|
+
# Logs are written to the target in (\logs\testability)
|
|
54
|
+
#
|
|
55
|
+
# == returns
|
|
56
|
+
# NilClass
|
|
57
|
+
# description: -
|
|
58
|
+
# example: -
|
|
59
|
+
#
|
|
60
|
+
# == exceptions
|
|
61
|
+
# ArgumentError
|
|
62
|
+
# description: In case the given parameters are not valid.
|
|
63
|
+
def enable_logger
|
|
64
|
+
configure_logger( {:logEnabled => true} )
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# == description
|
|
68
|
+
# Disable the logging on the target for the given application or sut (qttasserver).
|
|
69
|
+
# Logs are left as they are.
|
|
70
|
+
#
|
|
71
|
+
# == returns
|
|
72
|
+
# NilClass
|
|
73
|
+
# description: -
|
|
74
|
+
# example: -
|
|
75
|
+
#
|
|
76
|
+
# == exceptions
|
|
77
|
+
# ArgumentError
|
|
78
|
+
# description: In case the given parameters are not valid.
|
|
79
|
+
def disable_logger
|
|
80
|
+
configure_logger( {:logEnabled => false} )
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# == description
|
|
84
|
+
# Set the log level for the application or sut (qttasserver). Affects only the running process.
|
|
85
|
+
# Will not be stored as permanent setting.
|
|
86
|
+
#
|
|
87
|
+
# == arguments
|
|
88
|
+
# level
|
|
89
|
+
# Symbol
|
|
90
|
+
# description:
|
|
91
|
+
# The log level.
|
|
92
|
+
# See [link="#log_levels_table"]Valid log levels table[/link] for valid keys.
|
|
93
|
+
# example: :INFO
|
|
94
|
+
#
|
|
95
|
+
# == tables
|
|
96
|
+
# log_levels_table
|
|
97
|
+
# title: Valid log levels
|
|
98
|
+
# |Level|Type|Description|
|
|
99
|
+
# |:FATAL|Symbol|Log fatal level message|
|
|
100
|
+
# |:ERROR|Symbol|Log fatal and error level messages|
|
|
101
|
+
# |:INFO|Symbol|Log fatal, error and info level messages|
|
|
102
|
+
# |:WARNING|Symbol|Log fatal, error, info and warning level messages|
|
|
103
|
+
# |:DEBUG|Symbol|Log all messages|
|
|
104
|
+
#
|
|
105
|
+
# == returns
|
|
106
|
+
# NilClass
|
|
107
|
+
# description: -
|
|
108
|
+
# example: -
|
|
109
|
+
#
|
|
110
|
+
# == exceptions
|
|
111
|
+
# ArgumentError
|
|
112
|
+
# description: In case the given level is not valid.
|
|
113
|
+
def set_log_level(level)
|
|
114
|
+
configure_logger( {:logLevel => level} )
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# == description
|
|
118
|
+
# Change the folder to where the logs are written to for the application or sut (qttasserver).
|
|
119
|
+
#
|
|
120
|
+
# == arguments
|
|
121
|
+
# folder
|
|
122
|
+
# String
|
|
123
|
+
# description:
|
|
124
|
+
# New location for the logs.
|
|
125
|
+
# example: '/tmp/logs'
|
|
126
|
+
#
|
|
127
|
+
# == returns
|
|
128
|
+
# NilClass
|
|
129
|
+
# description: -
|
|
130
|
+
# example: -
|
|
131
|
+
def set_log_folder(folder)
|
|
132
|
+
configure_logger( {:logFolder => folder} )
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# == description
|
|
136
|
+
# Can be used to set logging to be done to qDebug. All tdriver target logging
|
|
137
|
+
# will go to qDebug not the log file.
|
|
138
|
+
#
|
|
139
|
+
# == arguments
|
|
140
|
+
# to_qdebug
|
|
141
|
+
# boolean
|
|
142
|
+
# description:
|
|
143
|
+
# True to logs message to qDebug instead of a file.
|
|
144
|
+
# example: true
|
|
145
|
+
#
|
|
146
|
+
# == returns
|
|
147
|
+
# NilClass
|
|
148
|
+
# description: -
|
|
149
|
+
# example: -
|
|
150
|
+
def log_to_qdebug(to_qdebug = true)
|
|
151
|
+
configure_logger( {:logToQDebug => to_qdebug} )
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# == description
|
|
155
|
+
# Set the qDebug message to be append to the logs or not.
|
|
156
|
+
# By default qDebug messages are not written to the logs.
|
|
157
|
+
#
|
|
158
|
+
# == arguments
|
|
159
|
+
# include
|
|
160
|
+
# boolean
|
|
161
|
+
# description:
|
|
162
|
+
# True to log qDebug messages and false to not
|
|
163
|
+
# example: true
|
|
164
|
+
#
|
|
165
|
+
# == returns
|
|
166
|
+
# NilClass
|
|
167
|
+
# description: -
|
|
168
|
+
# example: -
|
|
169
|
+
def log_qdebug(include = true)
|
|
170
|
+
configure_logger( {:logQDebug => include} )
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# == description
|
|
174
|
+
# Set max size for the log file. When the level is reached the log file is renamed
|
|
175
|
+
# as old_"name of log file".log and a new file is started. By default the size is
|
|
176
|
+
# 100000.
|
|
177
|
+
#
|
|
178
|
+
# == arguments
|
|
179
|
+
# size
|
|
180
|
+
# integer
|
|
181
|
+
# description:
|
|
182
|
+
# The new log file size
|
|
183
|
+
# example: 500000
|
|
184
|
+
#
|
|
185
|
+
# == returns
|
|
186
|
+
# NilClass
|
|
187
|
+
# description: -
|
|
188
|
+
# example: -
|
|
189
|
+
def set_log_size(size)
|
|
190
|
+
configure_logger( {:logSize => size} )
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# == description
|
|
194
|
+
# Clears the log file.
|
|
195
|
+
#
|
|
196
|
+
# == returns
|
|
197
|
+
# NilClass
|
|
198
|
+
# description: -
|
|
199
|
+
# example: -
|
|
200
|
+
def clear_log
|
|
201
|
+
configure_logger( {:clearLog => true} )
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# == description
|
|
205
|
+
# Set the logger to log listed events. Events have to be separated by comma.
|
|
206
|
+
# e.g MouseEvent, Paint
|
|
207
|
+
# The event name does not have to be complete. e.g Mouse will log all events with the
|
|
208
|
+
# word Mouse.
|
|
209
|
+
#
|
|
210
|
+
# == arguments
|
|
211
|
+
# event_list
|
|
212
|
+
# String
|
|
213
|
+
# description:
|
|
214
|
+
# Comma separated list of events
|
|
215
|
+
# example: 'Mouse','Touch'
|
|
216
|
+
#
|
|
217
|
+
# == returns
|
|
218
|
+
# NilClass
|
|
219
|
+
# description: -
|
|
220
|
+
# example: -
|
|
221
|
+
#
|
|
222
|
+
def log_events( event_list = '')
|
|
223
|
+
begin
|
|
224
|
+
|
|
225
|
+
params = {:logEvents => 'true'}
|
|
226
|
+
perform_command( MobyCommand::ConfigureCommand.new( "configureEventLogging", params, event_list ) )
|
|
227
|
+
|
|
228
|
+
rescue Exception => e
|
|
229
|
+
|
|
230
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed to enable event logging. With event_list \"#{event_list};log_events"
|
|
231
|
+
Kernel::raise e
|
|
232
|
+
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Event logging enabled. With event_list \"#{event_list};log_events"
|
|
236
|
+
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# == description
|
|
240
|
+
# Stop logging events.
|
|
241
|
+
#
|
|
242
|
+
# == returns
|
|
243
|
+
# NilClass
|
|
244
|
+
# description: -
|
|
245
|
+
# example: -
|
|
246
|
+
#
|
|
247
|
+
def stop_event_logging
|
|
248
|
+
begin
|
|
249
|
+
|
|
250
|
+
params = {:logEvents => 'false'}
|
|
251
|
+
perform_command( MobyCommand::ConfigureCommand.new( "configureEventLogging", params) )
|
|
252
|
+
|
|
253
|
+
rescue Exception => e
|
|
254
|
+
|
|
255
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed to stop event logging.;stop_event_logging"
|
|
256
|
+
Kernel::raise e
|
|
257
|
+
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Event logging stopped.;stop_event_logging"
|
|
261
|
+
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
private
|
|
265
|
+
|
|
266
|
+
# Configure the logger for qttasserver and plugins
|
|
267
|
+
# Parameters are to be passed as a hash with one or more
|
|
268
|
+
# of the following values:
|
|
269
|
+
# :logLevel => :DEBUG (or :FATAL, :ERROR, :INFO or :WARNING. DEBUG will log the most)
|
|
270
|
+
# :logToQDebug => true/false
|
|
271
|
+
# :logFolder => '/tmp/logs/'
|
|
272
|
+
# :logQDebug => true/false
|
|
273
|
+
# :logSize => 10000
|
|
274
|
+
# :logEnabled => true/false
|
|
275
|
+
def configure_logger( params_hash = nil)
|
|
276
|
+
|
|
277
|
+
begin
|
|
278
|
+
raise ArgumentError.new( "No parameters given." ) unless params_hash
|
|
279
|
+
|
|
280
|
+
log_level = params_hash[:logLevel]
|
|
281
|
+
|
|
282
|
+
if log_level
|
|
283
|
+
raise ArgumentError.new( "Invalid log level." ) unless @@_valid_levels.include?(log_level)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
perform_command(MobyCommand::ConfigureCommand.new( "configureLogger", params_hash ))
|
|
287
|
+
|
|
288
|
+
rescue Exception => e
|
|
289
|
+
|
|
290
|
+
MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed to configure logger. With params \"#{params_hash.to_s};configure_logger"
|
|
291
|
+
Kernel::raise e
|
|
292
|
+
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
MobyUtil::Logger.instance.log "behaviour" , "PASS;Succesfully configured logger. With params \"#{params_hash.to_s};configure_logger"
|
|
296
|
+
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def perform_command(command)
|
|
300
|
+
|
|
301
|
+
if self.class == MobyBase::SUT
|
|
302
|
+
execute_command( command )
|
|
303
|
+
else
|
|
304
|
+
command.application_id = get_application_id
|
|
305
|
+
@sut.execute_command( command )
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# enable hooking for performance measurement & debug logging
|
|
311
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
312
|
+
|
|
313
|
+
end # ConfigureBehaviour
|
|
314
|
+
|
|
315
|
+
end # QT
|
|
316
|
+
|
|
317
|
+
end # MobyBehaviour
|