testability-driver-qt-sut-plugin 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +11 -8
  2. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +3 -3
  3. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +76 -74
  4. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/find.rb +2 -0
  5. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +10 -4
  6. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +49 -42
  7. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/infologger.rb +0 -9
  8. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/locale_db.rb +5 -0
  9. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/record.rb +11 -1
  10. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +441 -324
  11. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +32 -11
  12. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/treewidgetitemcolumn.rb +54 -34
  13. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/view_item.rb +26 -26
  14. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/webkit.rb +61 -21
  15. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +528 -344
  16. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +16 -138
  17. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +3 -67
  18. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +4 -18
  19. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/plugin.rb +1 -1
  20. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +166 -149
  21. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +80 -75
  22. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +93 -0
  23. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +161 -0
  24. data/xml/behaviour/qt.xml +26 -26
  25. data/xml/template/qt.xml +9 -7
  26. metadata +7 -6
  27. data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/commands/fixture.rb +0 -45
@@ -45,7 +45,7 @@ module MobyBehaviour
45
45
  # Application
46
46
  #
47
47
  module Application
48
-
48
+ # == nodoc
49
49
  # == description
50
50
  # Drag from the start coordinates to the end coordinates.
51
51
  #
@@ -131,11 +131,11 @@ module MobyBehaviour
131
131
  end
132
132
 
133
133
  # == description
134
- # Verify was the popup on the screen or not. The method uses matti verify internally for the verification.
134
+ # Verify was the popup on the screen or not. The method uses TDriver verify internally for the verification.
135
135
  # If the popup was shown then the entire application ui state is returned as a test object.
136
136
  # More detailed verification can be done for the object (e.g. the content of the popup, labels etc...).
137
137
  # \n
138
- # Note: If the popup does not close the verification will fail. Detection is based on grabbing the ui state just before the popup closes.
138
+ # [b]NOTE:[/b] If the popup does not close the verification will fail. Detection is based on grabbing the ui state just before the popup closes.
139
139
  #
140
140
  # == arguments
141
141
  # class_name
@@ -161,7 +161,9 @@ module MobyBehaviour
161
161
  end
162
162
 
163
163
  # == description
164
- # Bring the application to foreground. Note! Currently this works only for Symbian OS target!
164
+ # Bring the application to foreground.\n
165
+ # \n
166
+ # [b]NOTE:[/b] Currently this works only for Symbian OS target!
165
167
  #
166
168
  # == returns
167
169
  # NilClass
@@ -170,8 +172,8 @@ module MobyBehaviour
170
172
  #
171
173
  #
172
174
  def bring_to_foreground
173
- @sut.execute_command(MobyCommand::Application.new(:BringToForeground, nil, self.uid, self.sut))
174
- end
175
+ @sut.execute_command(MobyCommand::Application.new(:BringToForeground, nil, self.uid, self.sut))
176
+ end
175
177
 
176
178
  # == description
177
179
  # Taps the given objects at the same time (multitouch).
@@ -259,8 +261,9 @@ module MobyBehaviour
259
261
  end
260
262
 
261
263
  # == description
262
- # Performs the given operations at the same time (when possible).
263
- # Note that only ui behaviours can be used here (e.g. taps, gestures).
264
+ # Performs the given operations at the same time (when possible).\n
265
+ # \n
266
+ # [b]NOTE:[/b] Only UI behaviours can be used here (e.g. taps, gestures).
264
267
  #
265
268
  # == arguments
266
269
  # &block
@@ -138,7 +138,7 @@ module MobyBehaviour
138
138
  #
139
139
  # == arguments
140
140
  # to_qdebug
141
- # boolean
141
+ # Boolean
142
142
  # description:
143
143
  # True to logs message to qDebug instead of a file.
144
144
  # example: true
@@ -157,7 +157,7 @@ module MobyBehaviour
157
157
  #
158
158
  # == arguments
159
159
  # include
160
- # boolean
160
+ # Boolean
161
161
  # description:
162
162
  # True to log qDebug messages and false to not
163
163
  # example: true
@@ -177,7 +177,7 @@ module MobyBehaviour
177
177
  #
178
178
  # == arguments
179
179
  # size
180
- # integer
180
+ # Fixnum
181
181
  # description:
182
182
  # The new log file size
183
183
  # example: 500000
@@ -42,24 +42,24 @@ module MobyBehaviour
42
42
  # == objects
43
43
  # *;application
44
44
  #
45
- module Events
46
-
47
- include MobyBehaviour::QT::Behaviour
48
-
49
- # == description
50
- # Enable event listening. You can specify which events you want to listen for by including the names of
51
- # those events separated by comma or integers if using user events. Use ALL if you want to listen for all
52
- # events but be aware that there will be a lot of events.
53
- # \n
54
- # The events listened need to be sent the object to which the enabling is done for e.g. sut.button.enable_events('ALL')
55
- # would listen to all events sent to the button. When disabling or getting the events the operation must be done to the same object.
56
- #
45
+ module Events
46
+
47
+ include MobyBehaviour::QT::Behaviour
48
+
49
+ # == description
50
+ # Enable event listening. You can specify which events you want to listen for by including the names of
51
+ # those events separated by comma or integers if using user events. Use ALL if you want to listen for all
52
+ # events but be aware that there will be a lot of events.
53
+ # \n
54
+ # The events listened need to be sent the object to which the enabling is done for e.g. sut.button.enable_events('ALL')
55
+ # would listen to all events sent to the button. When disabling or getting the events the operation must be done to the same object.
56
+ #
57
57
  # == arguments
58
58
  # filter_array
59
59
  # Array
60
60
  # description: Array of the event named to listen
61
61
  # example: ["Timer","MouseButtonPress","45677","67889"]
62
- #
62
+ #
63
63
  # == returns
64
64
  # NilClass
65
65
  # description: -
@@ -69,31 +69,31 @@ 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)
73
73
 
74
- begin
75
- command = plugin_command #in qt_behaviour
76
- command.command_name( 'EnableEvents' )
77
- params_str = ''
78
- filter_array.each {|value| params_str << value << ','} if filter_array
79
- command.command_params( 'EventsToListen' => params_str)
80
- command.service( 'collectEvents' )
81
- @sut.execute_command( command)
74
+ begin
75
+ command = plugin_command #in qt_behaviour
76
+ command.command_name( 'EnableEvents' )
77
+ params_str = ''
78
+ filter_array.each {|value| params_str << value << ','} if filter_array
79
+ command.command_params( 'EventsToListen' => params_str)
80
+ command.service( 'collectEvents' )
81
+ @sut.execute_command( command)
82
82
 
83
- rescue Exception => e
83
+ rescue Exception => e
84
84
 
85
- MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed enable_events with refresh \"#{filter_array.to_s}\".;#{ identity };enable_events;"
86
- Kernel::raise e
85
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed enable_events with refresh \"#{filter_array.to_s}\".;#{ identity };enable_events;"
86
+ Kernel::raise e
87
87
 
88
- end
88
+ end
89
89
 
90
- MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation enable_events executed successfully with refresh \"#{ filter_array.to_s }\".;#{ identity };enable_events;"
91
- nil
92
- end
90
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation enable_events executed successfully with refresh \"#{ filter_array.to_s }\".;#{ identity };enable_events;"
91
+ nil
92
+ end
93
93
 
94
- # == description
95
- # Disables event listening on the target
96
- #
94
+ # == description
95
+ # Disables event listening on the target
96
+ #
97
97
  # == returns
98
98
  # NilClass
99
99
  # description: -
@@ -103,62 +103,64 @@ module MobyBehaviour
103
103
  # Exception
104
104
  # description: In case of an error
105
105
  #
106
- def disable_events()
107
-
108
- begin
109
- command = plugin_command #in qt_behaviour
110
- command.command_name( 'DisableEvents' )
111
- command.service( 'collectEvents' )
112
- @sut.execute_command( command)
113
- rescue Exception => e
114
- MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed disable_events.;#{ identity };disable_events;"
115
- Kernel::raise e
116
- end
117
-
118
- MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation disable_events executed successfully.;#{ identity };disable_events;"
119
- nil
120
- end
121
-
122
- # == description
123
- # Gets event list occured since the enabling of events
124
- # \n
125
- # The format of the xml string is the same as with the ui state.
126
- #
106
+ def disable_events()
107
+
108
+ begin
109
+ command = plugin_command #in qt_behaviour
110
+ command.command_name( 'DisableEvents' )
111
+ command.service( 'collectEvents' )
112
+ @sut.execute_command( command)
113
+ rescue Exception => e
114
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed disable_events.;#{ identity };disable_events;"
115
+ Kernel::raise e
116
+ end
117
+
118
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation disable_events executed successfully.;#{ identity };disable_events;"
119
+ nil
120
+
121
+ end
122
+
123
+ # == description
124
+ # Gets event list occured since the enabling of events. The format of the XML string is the same as with the UI state.
125
+ #
127
126
  # == returns
128
127
  # String
129
- # description: Xml listing containing the details of the events logger since enable_events
130
- # example: -
128
+ # description: Xml listing containing the details of the events logger since enable_events
129
+ # example: -
131
130
  #
132
131
  # == exceptions
133
132
  # Exception
134
133
  # description: In case of an error
135
134
  #
136
- def get_events()
137
- ret = nil
138
-
139
- begin
135
+ def get_events()
136
+
137
+ ret = nil
140
138
 
141
- command = plugin_command(true) #in qt_behaviour
142
- command.command_name( 'GetEvents' )
143
- command.service( 'collectEvents' )
144
- ret = @sut.execute_command( command)
145
- # TODO: how to parse the output?
139
+ begin
146
140
 
147
- rescue Exception => e
141
+ command = plugin_command(true) #in qt_behaviour
142
+ command.command_name( 'GetEvents' )
143
+ command.service( 'collectEvents' )
144
+ ret = @sut.execute_command( command)
145
+ # TODO: how to parse the output?
148
146
 
149
- MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed get_events.;#{ identity };get_events;"
150
- Kernel::raise e
147
+ rescue Exception => e
151
148
 
152
- end
149
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed get_events.;#{ identity };get_events;"
150
+ Kernel::raise e
151
+
152
+ end
153
153
 
154
- MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation get_events executed successfully.;#{ identity };get_events;"
155
- return ret
156
- end
154
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation get_events executed successfully.;#{ identity };get_events;"
155
+
156
+ ret
157
+
158
+ end
157
159
 
158
- # enable hooking for performance measurement & debug logging
159
- MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
160
+ # enable hooking for performance measurement & debug logging
161
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
160
162
 
161
- end # EventsBehaviour
163
+ end # EventsBehaviour
162
164
 
163
165
  end
164
166
 
@@ -48,6 +48,8 @@ module MobyBehaviour
48
48
  module Find
49
49
  include MobyBehaviour::QT::Behaviour
50
50
 
51
+ # == nodoc
52
+ # TODO: fix this
51
53
  def find_and_center (find_hash = {})
52
54
  begin
53
55
  search_result = find(find_hash)
@@ -86,11 +86,14 @@ module MobyBehaviour
86
86
  ret = nil
87
87
 
88
88
  begin
89
+ params = {:name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => false}
89
90
  #for sut send the fixture command to qttasserver (appid nil)
90
91
  if self.class == MobyBase::SUT
91
- ret = self.execute_command( MobyCommand::Fixture.new( nil, self.id, :Application, fixture_name, fixture_method, parameters_hash ) )
92
+ params.merge!( {:application_id => nil, :object_id => self.id, :object_type => :Application} )
93
+ ret = self.execute_command( MobyCommand::Fixture.new( params ) )
92
94
  else
93
- ret = @sut.execute_command( MobyCommand::Fixture.new( get_application_id, self.id, self.attribute( 'objectType' ).intern, fixture_name, fixture_method, parameters_hash ) )
95
+ params.merge!( {:application_id => get_application_id, :object_id => self.id, :object_type => self.attribute( 'objectType' ).intern} )
96
+ ret = @sut.execute_command( MobyCommand::Fixture.new( params ) )
94
97
  end
95
98
  rescue Exception => e
96
99
 
@@ -148,11 +151,14 @@ module MobyBehaviour
148
151
  ret = nil
149
152
 
150
153
  begin
154
+ params = {:name => fixture_name, :command_name => fixture_method, :parameters => parameters_hash, :async => true}
151
155
  #for sut send the fixture command to qttasserver (appid nil)
152
156
  if self.class == MobyBase::SUT
153
- ret = self.execute_command( MobyCommand::Fixture.new( nil, self.id, :Application, fixture_name, fixture_method, parameters_hash, true ) )
157
+ params.merge!( {:application_id => nil, :object_id => self.id, :object_type => :Application} )
158
+ ret = self.execute_command( MobyCommand::Fixture.new( params ) )
154
159
  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 ) )
160
+ params.merge!( {:application_id => get_application_id, :object_id => self.id, :object_type => self.attribute( 'objectType' ).intern} )
161
+ ret = @sut.execute_command( MobyCommand::Fixture.new( params ) )
156
162
  end
157
163
  rescue Exception => e
158
164
 
@@ -287,27 +287,38 @@ module MobyBehaviour
287
287
  # description: One of the arguments is not valid
288
288
  def gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false})
289
289
 
290
- begin
290
+ begin
291
291
  # change the format for api consitency
292
292
  use_tap_screen = optional_params[:use_tap_screen].nil? ? MobyUtil::Parameter[ @sut.id][ :use_tap_screen, 'false'] :
293
293
  optional_params[:use_tap_screen].to_s
294
294
  optional_params[:useTapScreen] = use_tap_screen
295
295
 
296
-
297
- params = {:gesture_type => :MouseGestureToCoordinates, :x => x, :y => y, :speed => speed}
296
+ params = {:gesture_type => :MouseGestureToCoordinates, :speed => speed}
297
+ if attribute('objectType') == 'Web'
298
+ frame_x_absolute = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='x_absolute']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
299
+ frame_y_absolute = (@sut.xml_data.xpath( "//object[@id='%s']/attributes/attribute[@name ='y_absolute']/value/text()" % self.attribute('webFrame') )[0]).to_s.to_i
300
+ new_params = {:x=>(frame_x_absolute + x.to_i + (attribute('width' ).to_i/2)),
301
+ :y=>(frame_y_absolute + y.to_i + (attribute('height').to_i/2))}
302
+ params.merge!(new_params)
303
+ else
304
+ new_params = {:x=>x, :y=>y}
305
+ params.merge!(new_params)
306
+ end
307
+
308
+
298
309
  params.merge!(optional_params)
299
- do_gesture(params)
300
- do_sleep(speed)
310
+ do_gesture(params)
311
+ do_sleep(speed)
301
312
 
302
- rescue Exception => e
313
+ rescue Exception => e
303
314
 
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
315
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed gesture_to with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", button \".;#{identity};gesture;"
316
+ Kernel::raise e
317
+ end
307
318
 
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
319
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation gesture_to executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\".;#{identity};gesture;"
320
+ nil
321
+ end
311
322
 
312
323
  # == description
313
324
  # Perform a gesture with the object, starting the gesture at the specified point inside it.
@@ -409,6 +420,13 @@ module MobyBehaviour
409
420
  # ArgumentError
410
421
  # description: One of the arguments is not valid
411
422
  def gesture_to_object(target_object, duration, optional_params = {:button => :Left, :isDrag => false})
423
+ if attribute('objectType') == 'Web'
424
+ gesture_to(target_object.attribute('x').to_i + (target_object.attribute('width' ).to_i/2) - (attribute('width' ).to_i/2),
425
+ target_object.attribute('y').to_i + (target_object.attribute('height').to_i/2) - (attribute('height').to_i/2),
426
+ duration, optional_params)
427
+ nil
428
+ return
429
+ end
412
430
 
413
431
  begin
414
432
  # change the format for api consitency
@@ -422,8 +440,8 @@ module MobyBehaviour
422
440
  params[:targetId] = target_object.id
423
441
  params[:targetType] = target_object.attribute('objectType')
424
442
  params.merge!(optional_params)
425
- do_gesture(params)
426
- do_sleep(duration)
443
+ do_gesture(params)
444
+ do_sleep(duration)
427
445
 
428
446
  rescue Exception => e
429
447
 
@@ -626,33 +644,22 @@ module MobyBehaviour
626
644
  # description: One of the arguments is not valid
627
645
  def drag_to( x, y, button = :Left, optional_params= {} )
628
646
 
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
647
+ begin
648
+ optional_params.merge!({ :isDrag => true , :button=>button})
649
+ distance = distance_to_point(x,y)
650
+ speed = calculate_speed(distance, @sut.parameter[:gesture_drag_speed])
651
+ gesture_to(x, y, speed, optional_params )
633
652
 
653
+ rescue Exception => e
654
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed drag_to with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
655
+ Kernel::raise e
656
+ end
634
657
 
635
- distance = distance_to_point(x,y)
636
- return if distance == 0
658
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Operation drag_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};drag;"
637
659
 
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
660
+ nil
648
661
 
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
662
+ end
656
663
 
657
664
  # == description
658
665
  # Drag the object to the center of another object.
@@ -744,8 +751,8 @@ module MobyBehaviour
744
751
  # optional_params
745
752
  # Hash
746
753
  # 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' }
754
+ # example: {:use_tap_screen => 'true'}
755
+ # default: {:use_tap_screen => 'false'}
749
756
  #
750
757
  # == returns
751
758
  # NilClass
@@ -807,9 +814,9 @@ module MobyBehaviour
807
814
  def do_gesture(params)
808
815
  validate_gesture_params!(params)
809
816
 
810
- if attribute('objectType') == 'Embedded'
811
- params['x'] = center_x
812
- params['y'] = center_y
817
+ if attribute('objectType') == 'Embedded' or attribute('objectType') == 'Web'
818
+ params['obj_x'] = center_x
819
+ params['obj_y'] = center_y
813
820
  params['useCoordinates'] = 'true'
814
821
  end
815
822