testability-driver-qt-sut-plugin 1.2.1 → 1.3.0

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.
Files changed (30) hide show
  1. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +16 -6
  2. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +86 -12
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +1 -1
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +5 -3
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +15 -0
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +110 -76
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +125 -69
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +28 -19
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +143 -24
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +25 -10
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/agent.rb +54 -0
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +1 -0
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +32 -39
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +8 -19
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +35 -22
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +31 -29
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +23 -32
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +44 -61
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +22 -23
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +39 -28
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/version.rb +14 -24
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +39 -42
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +93 -120
  24. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +95 -75
  25. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +6 -8
  26. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +1 -1
  27. data/xml/behaviour/qt.xml +6 -0
  28. data/xml/keymap/win.xml +174 -0
  29. data/xml/template/qt.xml +128 -117
  30. metadata +60 -75
@@ -47,6 +47,13 @@ module MobyBehaviour
47
47
  #
48
48
  module Application
49
49
 
50
+
51
+ @@__multitouch_operation = false
52
+
53
+ def multitouch_ongoing?
54
+ @@__multitouch_operation
55
+ end
56
+
50
57
  # == description
51
58
  # Start to track a popup that may appear on the screen. Tracking is done based on the class name of the
52
59
  # widget implementing popup functionality. Base class name can also be used in case framework level
@@ -217,17 +224,20 @@ module MobyBehaviour
217
224
  #
218
225
  #
219
226
  def multi_touch(&block)
220
-
221
- multitouch_operation( &block )
222
-
227
+ begin
228
+ @@__multitouch_operation = true
229
+ multitouch_operation( &block )
230
+ ensure
231
+ @@__multitouch_operation = false
232
+ end
223
233
  end
224
234
 
225
235
  # == description
226
236
  # Resizes the application window so that width becomes height and vice versa.
227
237
  #
228
238
  # == arguments
229
- # Symbol
230
- # direction
239
+ # direction
240
+ # Symbol
231
241
  # description: For future support
232
242
  #
233
243
  # == returns
@@ -242,7 +252,7 @@ module MobyBehaviour
242
252
  end
243
253
 
244
254
  private
245
-
255
+
246
256
  def multitouch_operation( &block )
247
257
 
248
258
  # make sure the situation is ok before freeze
@@ -52,33 +52,67 @@ module MobyBehaviour
52
52
  @@_direction_map = { :Up => '0', :Down => '180', :Left => '270', :Right => '90' }
53
53
  @@_pinch_directions = { :Horizontal => '90', :Vertical => '0'}
54
54
  @@_rotate_direction = [ :Clockwise, :CounterClockwise ]
55
+ @@_events_enabled = false
55
56
 
56
57
  # == nodoc
57
58
  # should this method be private?
58
59
  def command_params( command = MobyCommand::WidgetCommand.new )
59
60
 
60
- if attribute( 'objectType' ) == 'Graphics' and attribute( 'visibleOnScreen' ) == 'false' and self.creation_attributes[:visibleOnScreen] != 'false'
61
+ if attribute( 'objectType' ) == 'Graphics' and attribute( 'visibleOnScreen' ) == 'false' and @creation_attributes[ :visibleOnScreen ] != 'false'
62
+
61
63
  begin
62
- self.creation_attributes.merge!({'visibleOnScreen' => 'true'})
63
- self.parent.child(self.creation_attributes)
64
+
65
+ #try to make the item visible if so wanted
66
+ fixture( 'qt', 'ensureVisible' ) if sut_parameters[ :ensure_visible, false ].true?
67
+ fixture( 'qt', 'ensureQmlVisible') if sut_parameters[ :ensure_qml_visible, false ].true?
68
+
69
+ @creation_attributes.merge!( 'visibleOnScreen' => 'true' )
70
+
71
+ @parent.child( @creation_attributes )
72
+
64
73
  rescue
65
- Kernel::raise MobyBase::TestObjectNotVisibleError
74
+
75
+ raise MobyBase::TestObjectNotVisibleError
76
+
66
77
  end
78
+
67
79
  end
68
80
 
69
- command.set_event_type(sut_parameters[ :event_type, "0" ])
81
+ _object_type = attribute( 'objectType' ).intern
70
82
 
71
83
  #for components with object visible on screen but not actual widgets or graphicsitems
72
- if attribute( 'objectType' ) == 'Embedded'
73
- command.application_id( get_application_id )
74
- command.set_object_id( parent.id )
75
- command.object_type( parent.attribute( 'objectType' ).intern )
84
+ if _object_type == :Embedded
85
+
86
+ _object_type = @parent.attribute( 'objectType' ).intern
87
+
88
+ _object_id = @parent.id
89
+
76
90
  else
77
- command.application_id( get_application_id )
78
- command.set_object_id( @id )
79
- command.object_type( attribute( 'objectType' ).intern )
91
+
92
+ _object_id = @id
93
+
80
94
  end
81
95
 
96
+ command.application_id( get_application_id )
97
+
98
+ command.set_object_id( _object_id )
99
+
100
+ command.object_type( _object_type )
101
+
102
+ command.set_event_type( sut_parameters[ :event_type, "0" ] )
103
+
104
+ # set app id as vkb if the attribute exists as the command needs to go to the vkb app
105
+ begin
106
+
107
+ # raises exception if value not found
108
+ value = attribute( 'vkb_app_id' )
109
+
110
+ command.application_id( value )
111
+
112
+ rescue MobyBase::AttributeNotFoundError
113
+
114
+ end
115
+
82
116
  command
83
117
 
84
118
  end
@@ -96,6 +130,7 @@ module MobyBehaviour
96
130
  command
97
131
  end
98
132
 
133
+ # TODO: document me
99
134
  def do_sleep(time)
100
135
 
101
136
  time = time.to_f * 1.3
@@ -107,6 +142,7 @@ module MobyBehaviour
107
142
 
108
143
  end
109
144
 
145
+ # TODO: document me
110
146
  def center_x
111
147
 
112
148
  #x = attribute( 'x_absolute' ).to_i
@@ -118,6 +154,7 @@ module MobyBehaviour
118
154
 
119
155
  end
120
156
 
157
+ # TODO: document me
121
158
  def center_y
122
159
 
123
160
  #y = attribute( 'y_absolute' ).to_i
@@ -129,6 +166,43 @@ module MobyBehaviour
129
166
 
130
167
  end
131
168
 
169
+ # TODO: document me
170
+ def param_set_configured?( params, key )
171
+
172
+ if params.kind_of?(Hash) && params.has_key?(key)
173
+
174
+ #( params[ key ].nil? ? sut_parameters[ key, 'false' ] : params[ key ].to_s ).to_s == "true"
175
+
176
+ ( params[ key ] || sut_parameters[ key, false ] ).true?
177
+
178
+ else
179
+
180
+ #sut_parameters[ key, 'false' ].true?
181
+
182
+ sut_parameters[ key, false ].true?
183
+
184
+ end
185
+ end
186
+
187
+ # TODO: document me
188
+ def execute_behavior( params, command )
189
+
190
+ if !get_application.multitouch_ongoing? && !@@_events_enabled && param_set_configured?( params, :ensure_event )
191
+
192
+ ensure_event(:retry_timeout => 5, :retry_interval => 0.5) {
193
+
194
+ @sut.execute_command( command )
195
+
196
+ }
197
+
198
+ else
199
+
200
+ @sut.execute_command( command )
201
+
202
+ end
203
+
204
+ end
205
+
132
206
  # enable hooking for performance measurement & debug logging
133
207
  TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
134
208
 
@@ -50,7 +50,7 @@ module MobyBehaviour
50
50
 
51
51
  # == description
52
52
  # Enabled the logging on the target for the given application or sut (qttasserver).
53
- # Logs are written to the target in (\logs\testability)
53
+ # Logs are written to the target in (/logs/testability)
54
54
  #
55
55
  # == returns
56
56
  # NilClass
@@ -69,17 +69,18 @@ module MobyBehaviour
69
69
  # Exception
70
70
  # description: In case of an error
71
71
  #
72
- def enable_events(filter_array = nil)
72
+ def enable_events(filter_array = nil, params = {})
73
73
 
74
74
  begin
75
75
  command = plugin_command #in qt_behaviour
76
76
  command.command_name( 'EnableEvents' )
77
77
  params_str = ''
78
78
  filter_array.each {|value| params_str << value << ','} if filter_array
79
- command.command_params( 'EventsToListen' => params_str)
79
+ params['EventsToListen'] = params_str
80
+ command.command_params( params )
80
81
  command.service( 'collectEvents' )
81
82
  @sut.execute_command( command)
82
-
83
+ @@_events_enabled = true
83
84
  rescue Exception => e
84
85
 
85
86
  $logger.behaviour "FAIL;Failed enable_events with refresh \"#{filter_array.to_s}\".;#{ identity };enable_events;"
@@ -110,6 +111,7 @@ module MobyBehaviour
110
111
  command.command_name( 'DisableEvents' )
111
112
  command.service( 'collectEvents' )
112
113
  @sut.execute_command( command)
114
+ @@_events_enabled = false
113
115
  rescue Exception => e
114
116
  $logger.behaviour "FAIL;Failed disable_events.;#{ identity };disable_events;"
115
117
  Kernel::raise e
@@ -311,6 +311,7 @@ module MobyBehaviour
311
311
  end
312
312
 
313
313
  def read_file(source_file)
314
+ =begin
314
315
  file_data=''
315
316
  if File.file?(source_file)
316
317
  open_file = File.open(source_file, 'r')
@@ -319,6 +320,20 @@ module MobyBehaviour
319
320
  end
320
321
  end
321
322
  return file_data.to_s
323
+ =end
324
+
325
+ begin
326
+
327
+ # return file content as string
328
+ File.open( source_file, 'rb:binary' ).read
329
+
330
+ rescue
331
+
332
+ # return empty string in case of exception raised
333
+ ''
334
+
335
+ end
336
+
322
337
  end
323
338
 
324
339
 
@@ -42,33 +42,32 @@ module MobyBehaviour
42
42
  # == objects
43
43
  # sut;*
44
44
  #
45
- module Fixture
46
-
47
- include MobyBehaviour::QT::Behaviour
45
+ module Fixture
48
46
 
47
+ include MobyBehaviour::QT::Behaviour
49
48
 
50
49
  # == description
51
50
  # 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
- #
51
+ # inside the application process or the qttasserver process (if used for sut).
52
+ # The fixture will get a pointer to the object to which this call is made to.
53
+ #
55
54
  #
56
55
  # == arguments
57
56
  # fixture_name
58
57
  # String
59
- # description: Name of the fixture. Fixture mapping is in the tdriverparameters.xml file.
58
+ # description: Name of the fixture. Fixture mapping is in the tdriver_parameters.xml file.
60
59
  # example: tasfixture
61
- #
62
- # fixture_method
63
- # String
60
+ #
61
+ # fixture_method
62
+ # String
64
63
  # description: Name of the action to be executed in the fixture.
65
64
  # example: callApi
66
- #
67
- # parameters_hash
68
- # Hash
65
+ #
66
+ # parameters_hash
67
+ # Hash
69
68
  # description: Optional hash of pareters passed on to the fixture.
70
69
  # example: {:name => 'John'}
71
- #
70
+ #
72
71
  # == returns
73
72
  # QString
74
73
  # description: The value returned but the fixture.
@@ -78,60 +77,73 @@ module MobyBehaviour
78
77
  # ArgumentError
79
78
  # description: In case the given parameters are not valid.
80
79
  #
81
- def fixture( fixture_name, fixture_method, parameters_hash = {} )
80
+ def fixture( fixture_name, fixture_method, parameters_hash = {} )
81
+
82
+ # verify that arguments were given in correct format
83
+ fixture_name.check_type String, 'wrong argument type $1 for fixture name (expected $2)'
84
+
85
+ fixture_method.check_type String, 'wrong argument type $1 for fixture method name (expected $2)'
86
+
87
+ parameters_hash.check_type Hash, 'wrong argument type $1 for fixture parameters (expected $2)'
88
+
89
+ result = nil
82
90
 
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 )
91
+ begin
85
92
 
86
- ret = nil
93
+ # default parameters
94
+ params = { :name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => false }
87
95
 
88
- begin
89
- params = {:name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => false}
90
- #for sut send the fixture command to qttasserver (appid nil)
91
- if self.class == MobyBase::SUT
92
- params.merge!( {:application_id => nil, :object_id => @id, :object_type => :Application} )
93
- ret = execute_command( MobyCommand::Fixture.new( params ) )
94
- else
95
- params.merge!( {:application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).intern} )
96
- ret = @sut.execute_command( MobyCommand::Fixture.new( params ) )
97
- end
98
- rescue Exception => e
96
+ # for sut send the fixture command to qttasserver (appid nil)
97
+ if sut?
99
98
 
100
- $logger.behaviour "FAIL;Failed when calling fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
99
+ params.merge!( :application_id => nil, :object_id => @id, :object_type => :Application )
101
100
 
102
- Kernel::raise MobyBase::BehaviourError.new("Fixture", "Failed to execute fixture name #{fixture_name} method #{fixture_method}")
103
- end
101
+ else
104
102
 
105
- $logger.behaviour "PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
103
+ params.merge!( :application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).to_sym )
106
104
 
107
- ret
105
+ end
108
106
 
109
- end
107
+ result = @sut.execute_command( MobyCommand::Fixture.new( params ) )
108
+
109
+ rescue
110
+
111
+ $logger.behaviour "FAIL;Failed when calling fixture with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
112
+
113
+ raise MobyBase::BehaviourError.new( "Fixture", "Failed to execute fixture name #{ fixture_name.inspect } method #{ fixture_method.inspect }" )
114
+
115
+ end
116
+
117
+ $logger.behaviour "PASS;The fixture command was executed successfully with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
118
+
119
+ result
120
+
121
+ end
110
122
 
111
123
  # == description
112
124
  # Sends a fixture call to the target. The fixture will be executed either
113
- # inside the application process or the qttasserver process (if used for sut).
114
- # The fixture will get a pointer to the object to which this call is made to.
115
- # This version of the fixture call is asynchronous. This means that no return value
116
- # is returned.
117
- #
125
+ # inside the application process or the qttasserver process (if used for sut).
126
+ # The fixture will get a pointer to the object to which this call is made to.
127
+ # This version of the fixture call is asynchronous. This means that no return value
128
+ # is returned.
129
+ #
118
130
  #
119
131
  # == arguments
120
132
  # fixture_name
121
133
  # String
122
- # description: Name of the fixture. Fixture mapping is in the tdriverparameters.xml file.
134
+ # description: Name of the fixture. Fixture mapping is in the tdriver_parameters.xml file
123
135
  # example: tasfixture
124
- #
125
- # fixture_method
126
- # String
127
- # description: Name of the action to be executed in the fixture.
136
+ #
137
+ # fixture_method
138
+ # String
139
+ # description: Name of the action to be executed in the fixture
128
140
  # example: callApi
129
- #
130
- # parameters_hash
131
- # Hash
132
- # description: Optional hash of pareters passed on to the fixture.
141
+ #
142
+ # parameters_hash
143
+ # Hash
144
+ # description: Optional hash of parameters passed on to the fixture
133
145
  # example: {:name => 'John'}
134
- #
146
+ #
135
147
  # == returns
136
148
  # NilClass
137
149
  # description: -
@@ -141,40 +153,62 @@ module MobyBehaviour
141
153
  # ArgumentError
142
154
  # description: In case the given parameters are not valid.
143
155
  #
144
- def async_fixture( fixture_name, fixture_method, parameters_hash = {} )
156
+ def async_fixture( fixture_name, fixture_method, parameters_hash = {} )
157
+
158
+ # verify that arguments were given in correct format
159
+ fixture_name.check_type String, 'wrong argument type $1 for fixture name (expected $2)'
160
+
161
+ fixture_method.check_type String, 'wrong argument type $1 for fixture method name (expected $2)'
162
+
163
+ parameters_hash.check_type Hash, 'wrong argument type $1 for fixture parameters (expected $2)'
164
+
165
+ result = nil
166
+
167
+ begin
168
+
169
+ # default parameters
170
+ params = { :name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => true }
171
+
172
+ # for sut send the fixture command to qttasserver (appid nil)
173
+ if sut?
174
+
175
+ params.merge!( :application_id => nil, :object_id => @id, :object_type => :Application )
176
+
177
+ else
178
+
179
+ params.merge!( :application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).to_sym )
180
+
181
+ end
182
+
183
+ result = @sut.execute_command( MobyCommand::Fixture.new( params ) )
184
+
185
+ rescue
186
+
187
+ $logger.behaviour "FAIL;Failed when calling async_fixture with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
188
+
189
+ raise MobyBase::BehaviourError.new("Fixture", "Failed to execute async_fixture name #{ fixture_name.inspect } method #{ fixture_method.inspect }")
145
190
 
146
- 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 )
147
- 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 )
191
+ end
148
192
 
149
- ret = nil
193
+ $logger.behaviour "PASS;The fixture command was executed successfully with name #{ fixture_name.inspect } method #{ fixture_method.inspect } parameters #{ parameters_hash.inspect }.;#{ @id.to_s };sut;{};fixture;"
150
194
 
151
- begin
152
- params = {:name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => true}
153
- #for sut send the fixture command to qttasserver (appid nil)
154
- if self.class == MobyBase::SUT
155
- params.merge!( {:application_id => nil, :object_id => @id, :object_type => :Application} )
156
- ret = execute_command( MobyCommand::Fixture.new( params ) )
157
- else
158
- params.merge!( {:application_id => get_application_id, :object_id => @id, :object_type => attribute( 'objectType' ).intern} )
159
- ret = @sut.execute_command( MobyCommand::Fixture.new( params ) )
160
- end
161
- rescue Exception => e
195
+ result
162
196
 
163
- $logger.behaviour "FAIL;Failed when calling async_fixture with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
197
+ end
164
198
 
165
- Kernel::raise MobyBase::BehaviourError.new("Fixture", "Failed to execute async_fixture name #{fixture_name} method #{fixture_method}")
166
- end
199
+ # == nodoc
200
+ def fixtures
167
201
 
168
- $logger.behaviour "PASS;The fixture command was executed successfully with name #{fixture_name} method #{fixture_method} parameters #{parameters_hash.inspect}.;#{id.to_s};sut;{};fixture;"
202
+ # pass call to fixtures service object
203
+ TDriver::FixtureService.new( :target => self )
169
204
 
170
- ret
205
+ end
171
206
 
172
- end
207
+ # enable hooking for performance measurement & debug logging
208
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
173
209
 
174
- # enable hooking for performance measurement & debug logging
175
- TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
210
+ end # Fixture
176
211
 
177
- end
212
+ end # QT
178
213
 
179
- end
180
- end
214
+ end # MobyBehaviour