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.
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/application.rb +16 -6
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/behaviour.rb +86 -12
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/configure_behaviour.rb +1 -1
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/events.rb +5 -3
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb +15 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/fixture.rb +110 -76
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb +125 -69
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/sut.rb +28 -19
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb +143 -24
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/widget.rb +25 -10
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/agent.rb +54 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb +1 -0
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/configure_command.rb +32 -39
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/find_object.rb +8 -19
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/fixture.rb +35 -22
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/group.rb +31 -29
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/infologger_command.rb +23 -32
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/key_sequence.rb +44 -61
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/screen_capture.rb +22 -23
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/tap.rb +39 -28
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/version.rb +14 -24
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/widget.rb +39 -42
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/adapter.rb +93 -120
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb +95 -75
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/find_object_generator.rb +6 -8
- data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/message_composer.rb +1 -1
- data/xml/behaviour/qt.xml +6 -0
- data/xml/keymap/win.xml +174 -0
- data/xml/template/qt.xml +128 -117
- metadata +60 -75
@@ -517,7 +517,7 @@ module MobyBehaviour
|
|
517
517
|
#
|
518
518
|
# duration
|
519
519
|
# Numeric
|
520
|
-
# description: Duration of the gesture in seconds. The value may be an
|
520
|
+
# description: Duration of the gesture in seconds. The value may be an integer or a fractional value as a floating point number.
|
521
521
|
# example: 1
|
522
522
|
#
|
523
523
|
# mouse_details
|
@@ -540,59 +540,87 @@ module MobyBehaviour
|
|
540
540
|
# == exceptions
|
541
541
|
# ArgumentError
|
542
542
|
# description: One of the arguments is not valid
|
543
|
-
def gesture_points( points, duration, mouse_details = {
|
543
|
+
def gesture_points( points, duration, mouse_details = {}, optional_params = {} )
|
544
544
|
|
545
545
|
begin
|
546
546
|
|
547
|
-
|
548
|
-
|
549
|
-
else
|
550
|
-
use_tap_screen = optional_params[:use_tap_screen].to_s
|
551
|
-
end
|
547
|
+
# verify that "duration" argument type is correct
|
548
|
+
duration.check_type [ Fixnum, Float ], 'wrong argument type $1 for duration value (expected $2)'
|
552
549
|
|
553
|
-
|
550
|
+
# verify that "points" argument type is correct
|
551
|
+
points.check_type Array, 'wrong argument type $1 for gesture points array (expected $2)'
|
552
|
+
|
553
|
+
# verify that "mouse_details" argument type is correct
|
554
|
+
mouse_details.check_type Hash, 'wrong argument type $1 for mouse details hash (expected $2)'
|
554
555
|
|
555
|
-
|
556
|
-
|
557
|
-
mouse_details[:button] = :Left unless mouse_details.has_value?(:button)
|
558
|
-
mouse_details[:isDrag] = true unless mouse_details.has_value?(:isDrag)
|
556
|
+
# verify that "optional_params" argument type is correct
|
557
|
+
optional_params.check_type Hash, 'wrong argument type $1 for optional parameters hash (expected $2)'
|
559
558
|
|
560
|
-
|
559
|
+
# set default values unless given by caller
|
560
|
+
mouse_details.default_values(
|
561
|
+
|
562
|
+
:press => true,
|
563
|
+
:release => true,
|
564
|
+
:button => :Left,
|
565
|
+
:isDrag => true
|
566
|
+
|
567
|
+
)
|
561
568
|
|
562
|
-
|
563
|
-
|
564
|
-
|
569
|
+
# verify that given button is valid
|
570
|
+
mouse_details[ :button ].validate @@_valid_buttons, 'unsupported button $3 for gesture points (expected $2)'
|
571
|
+
|
572
|
+
# initialize command parameters class
|
573
|
+
command = command_params # in qt_behaviour
|
574
|
+
|
575
|
+
# set command name
|
576
|
+
command.command_name( 'MouseGesturePoints' )
|
577
|
+
|
578
|
+
# set command parameters
|
579
|
+
command.command_params(
|
565
580
|
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
581
|
+
{
|
582
|
+
|
583
|
+
'mouseMove' => true,
|
584
|
+
'button' => @@_buttons_map[ mouse_details[ :button ] ],
|
585
|
+
'press' => mouse_details[ :press ].true?,
|
586
|
+
'release' => mouse_details[ :release ].true?,
|
587
|
+
'isDrag' => mouse_details[ :isDrag ].true?,
|
588
|
+
'speed' => ( duration.to_f * 1000 ).to_i,
|
589
|
+
'useTapScreen' => ( optional_params.delete( :use_tap_screen ) || sut_parameters[ :use_tap_screen, false ] ).true?
|
572
590
|
|
573
|
-
|
574
|
-
millis = millis*1000
|
575
|
-
speed = millis.to_i
|
576
|
-
params['speed'] = speed.to_s
|
577
|
-
command.command_params(params)
|
578
|
-
point_string = ""
|
579
|
-
points.each { |point| point_string << point["x"].to_s << "," << point["y"].to_s << "," << (point["interval"]*1000).to_i.to_s << ";"}
|
580
|
-
command.command_value(point_string)
|
591
|
+
}.merge!( optional_params )
|
581
592
|
|
582
|
-
|
593
|
+
)
|
594
|
+
|
595
|
+
# collect points as string
|
596
|
+
command.command_value(
|
597
|
+
|
598
|
+
points.inject(""){ | result, point |
|
599
|
+
|
600
|
+
result << "#{ point['x'].to_s },#{ point['y'].to_s },#{ (point['interval']*1000).to_i.to_s };"
|
601
|
+
|
602
|
+
}
|
603
|
+
|
604
|
+
)
|
605
|
+
|
606
|
+
# execute the command
|
607
|
+
execute_behavior(optional_params, command)
|
583
608
|
|
584
|
-
|
609
|
+
# wait until duration is exceeded
|
610
|
+
do_sleep duration.to_f
|
585
611
|
|
586
|
-
rescue
|
612
|
+
rescue
|
587
613
|
|
588
|
-
$logger.behaviour "FAIL;Failed
|
589
|
-
|
614
|
+
$logger.behaviour "FAIL;Failed gesture_points with points #{ points.inspect }, duration #{ duration.inspect }, mouse_details #{ mouse_details.inspect }.;#{ identity };gesture_points;"
|
615
|
+
|
616
|
+
raise
|
590
617
|
|
591
618
|
end
|
592
619
|
|
593
|
-
$logger.behaviour "PASS;Operation
|
620
|
+
$logger.behaviour "PASS;Operation gesture_points executed successfully with points #{ points.inspect }, duration #{ duration.inspect }, mouse_details #{ mouse_details.inspect }.;#{ identity };gesture_points;"
|
594
621
|
|
595
622
|
self
|
623
|
+
|
596
624
|
end
|
597
625
|
|
598
626
|
# == description
|
@@ -855,8 +883,7 @@ module MobyBehaviour
|
|
855
883
|
self
|
856
884
|
|
857
885
|
end
|
858
|
-
|
859
|
-
|
886
|
+
|
860
887
|
# == nodoc
|
861
888
|
# utility function for getting the x coordinate of the center of the object, should this be private method?
|
862
889
|
def object_center_x
|
@@ -876,62 +903,89 @@ module MobyBehaviour
|
|
876
903
|
# to the sut.
|
877
904
|
# gesture_type: :MouseGesture, :MouseGestureTo, :MouseGestureToCoordinates
|
878
905
|
# params = {:direction => :Up, duration => 2, :distance =>100, :isDrag =>false, :isMove =>false }
|
879
|
-
def do_gesture(params)
|
906
|
+
def do_gesture( params )
|
880
907
|
|
881
|
-
validate_gesture_params!(params)
|
908
|
+
validate_gesture_params!( params )
|
882
909
|
|
883
|
-
|
910
|
+
object_type = attribute('objectType')
|
911
|
+
|
912
|
+
if object_type == 'Embedded' or object_type == 'Web'
|
884
913
|
params['obj_x'] = center_x
|
885
914
|
params['obj_y'] = center_y
|
886
915
|
params['useCoordinates'] = 'true'
|
887
916
|
end
|
888
917
|
|
889
918
|
command = command_params #in qt_behaviour
|
890
|
-
|
919
|
+
|
920
|
+
command.command_name( params[:gesture_type].to_s )
|
921
|
+
|
891
922
|
command.command_params( params )
|
892
|
-
|
923
|
+
|
924
|
+
execute_behavior(params, command)
|
925
|
+
|
893
926
|
end
|
894
927
|
|
895
|
-
def validate_gesture_params!(params)
|
928
|
+
def validate_gesture_params!( params )
|
929
|
+
|
896
930
|
#direction
|
897
931
|
if params[:gesture_type] == :MouseGesture or params[:gesture_type] == :MouseGestureFromCoordinates
|
932
|
+
|
898
933
|
if params[:direction].kind_of?(Integer)
|
899
|
-
|
934
|
+
|
935
|
+
raise ArgumentError.new( "Invalid direction." ) unless 0 <= params[:direction] and params[:direction] <= 360
|
936
|
+
|
900
937
|
else
|
901
|
-
|
902
|
-
|
938
|
+
|
939
|
+
raise ArgumentError.new( "Invalid direction." ) unless @@_valid_directions.include?(params[:direction])
|
940
|
+
|
941
|
+
params[:direction] = @@_direction_map[params[:direction]]
|
942
|
+
|
903
943
|
end
|
944
|
+
|
904
945
|
#distance
|
905
946
|
params[:distance] = params[:distance].to_i unless params[:distance].kind_of?(Integer)
|
947
|
+
|
906
948
|
raise ArgumentError.new( "Distance must be an integer and greater than zero." ) unless params[:distance] > 0
|
907
|
-
|
908
|
-
raise ArgumentError.new("X and Y must be integers.") unless params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
|
949
|
+
|
909
950
|
elsif params[:gesture_type] == :MouseGestureTo
|
910
|
-
|
951
|
+
|
952
|
+
raise ArgumentError.new("targetId and targetType must be defined.") unless params.has_key?(:targetId) and params.has_key?(:targetType)
|
953
|
+
|
911
954
|
end
|
912
955
|
|
956
|
+
if params[:gesture_type] == :MouseGestureToCoordinates or params[:gesture_type] == :MouseGestureFromCoordinates
|
957
|
+
|
958
|
+
raise ArgumentError.new("X and Y must be integers.") unless params[:x].kind_of?(Integer) and params[:y].kind_of?(Integer)
|
959
|
+
|
960
|
+
end
|
961
|
+
|
913
962
|
#duration/speed
|
914
|
-
params[:speed] = params[:speed].to_f unless params[:speed].kind_of?(Numeric)
|
963
|
+
params[:speed] = params[:speed].to_f unless params[:speed].kind_of?( Numeric )
|
964
|
+
|
915
965
|
raise ArgumentError.new( "Duration must be a number and greated than zero, was:" + params[:speed].to_s) unless params[:speed] > 0
|
916
|
-
|
917
|
-
|
918
|
-
params[:speed] = duration_secs.to_i
|
966
|
+
|
967
|
+
params[:speed] = ( params[ :speed ].to_f * 1000 ).to_i
|
919
968
|
|
920
969
|
#mouseMove true always
|
921
970
|
params[:mouseMove] = true
|
922
971
|
|
923
972
|
params[:button] = :Left unless params[:button]
|
973
|
+
|
924
974
|
raise ArgumentError.new( "Invalid button." ) unless @@_valid_buttons.include?(params[:button])
|
975
|
+
|
925
976
|
params[:button] = @@_buttons_map[params[:button]]
|
926
977
|
|
927
978
|
if params[:isMove] == true
|
979
|
+
|
928
980
|
params[:press] = 'false'
|
981
|
+
|
929
982
|
params[:release] = 'false'
|
983
|
+
|
930
984
|
end
|
931
985
|
|
932
986
|
end
|
933
987
|
|
934
|
-
def do_sleep(time)
|
988
|
+
def do_sleep( time )
|
935
989
|
|
936
990
|
if sut_parameters[ :sleep_disabled, nil ] != true
|
937
991
|
|
@@ -945,32 +999,34 @@ module MobyBehaviour
|
|
945
999
|
|
946
1000
|
else
|
947
1001
|
|
948
|
-
# store the biggest value which will
|
1002
|
+
# store the biggest value which will be used in multitouch situations to sleep
|
949
1003
|
sut_parameters[ :skipped_sleep_time ] = time if time > sut_parameters[ :skipped_sleep_time, 0 ]
|
950
1004
|
|
951
1005
|
end
|
952
1006
|
|
953
1007
|
end
|
954
1008
|
|
955
|
-
def calculate_speed(distance, speed)
|
1009
|
+
def calculate_speed( distance, speed )
|
956
1010
|
|
957
|
-
distance
|
958
|
-
speed = speed.to_f
|
959
|
-
duration = distance/speed
|
960
|
-
duration
|
1011
|
+
distance.to_f / speed.to_f
|
961
1012
|
|
962
1013
|
end
|
963
1014
|
|
964
|
-
def distance_to_point(x, y)
|
1015
|
+
def distance_to_point( x, y )
|
1016
|
+
|
1017
|
+
dist_x = x.to_i - center_x.to_i
|
1018
|
+
|
1019
|
+
dist_y = y.to_i - center_y.to_i
|
1020
|
+
|
1021
|
+
unless dist_y == 0 && dist_x == 0
|
965
1022
|
|
966
|
-
|
967
|
-
y = y.to_i
|
968
|
-
dist_x = x - center_x.to_i
|
969
|
-
dist_y = y - center_y.to_i
|
1023
|
+
Math.hypot( dist_x, dist_y )
|
970
1024
|
|
971
|
-
|
972
|
-
|
973
|
-
|
1025
|
+
else
|
1026
|
+
|
1027
|
+
0
|
1028
|
+
|
1029
|
+
end
|
974
1030
|
|
975
1031
|
end
|
976
1032
|
|
@@ -323,10 +323,12 @@ module MobyBehaviour
|
|
323
323
|
|
324
324
|
if param[ :kill ].nil?
|
325
325
|
|
326
|
-
data = {}
|
327
326
|
|
328
327
|
object_xml_data, unused_rule = @test_object_adapter.get_objects( MobyUtil::XML.parse_string( xml_source ), { :type => 'Response' }, true )
|
329
328
|
|
329
|
+
=begin
|
330
|
+
data = {}
|
331
|
+
|
330
332
|
object_xml_data.collect{ | element |
|
331
333
|
|
332
334
|
data.merge!(
|
@@ -336,13 +338,17 @@ module MobyBehaviour
|
|
336
338
|
)
|
337
339
|
|
338
340
|
}
|
341
|
+
=end
|
342
|
+
object_xml_data.inject( {} ){ | result, element |
|
343
|
+
|
344
|
+
result.merge!( @test_object_adapter.test_object_attributes( element ) )
|
339
345
|
|
340
|
-
|
346
|
+
}
|
341
347
|
|
342
348
|
else
|
343
349
|
|
344
350
|
# Killed processes have no relevant data.
|
345
|
-
|
351
|
+
{
|
346
352
|
:status => "KILLED",
|
347
353
|
:output => xml_source
|
348
354
|
}
|
@@ -356,9 +362,9 @@ module MobyBehaviour
|
|
356
362
|
# launches application in symbian device based on UID and return launched application if succesfull.
|
357
363
|
#
|
358
364
|
# == arguments
|
359
|
-
#
|
365
|
+
# target_application_hash
|
360
366
|
# Hash
|
361
|
-
# description: Hash defining
|
367
|
+
# description: Hash defining expected attributes of the application
|
362
368
|
# example: { :UID => '' }
|
363
369
|
#
|
364
370
|
# == returns
|
@@ -370,30 +376,33 @@ module MobyBehaviour
|
|
370
376
|
# TypeError
|
371
377
|
# description: Wrong argument type %s for attributes (expected Hash)
|
372
378
|
#
|
373
|
-
def launch_with_uid(
|
379
|
+
def launch_with_uid( target_application_hash = {} )
|
374
380
|
|
375
381
|
begin
|
376
382
|
|
377
|
-
|
378
|
-
|
379
|
-
|
383
|
+
target_application_hash.check_type Hash, 'wrong argument type $1 for application attributes (expected: $2)'
|
384
|
+
|
385
|
+
the_uid = "failed with uid:" + target_application_hash[ :UID ].to_s
|
386
|
+
|
387
|
+
fullname = @sut.fixture( "launch", "launch_with_uid", target_application_hash )
|
380
388
|
|
381
|
-
if
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
shortname = full_shortname.rpartition('.')[0]
|
386
|
-
|
389
|
+
raise fullname if fullname == the_uid
|
390
|
+
|
391
|
+
full_shortname = fullname.rpartition( '\\' )[ -1 ]
|
392
|
+
|
393
|
+
shortname = full_shortname.rpartition( '.' )[ 0 ]
|
394
|
+
|
395
|
+
app_child = @sut.application( :name => shortname )
|
387
396
|
|
388
|
-
rescue
|
397
|
+
rescue
|
389
398
|
|
390
|
-
$logger.behaviour "FAIL;Failed to find application.;#{id.to_s};sut;{};application
|
399
|
+
$logger.behaviour "FAIL;Failed to find application.;#{ id.to_s };sut;{};application;#{ target_application_hash.inspect }"
|
391
400
|
|
392
401
|
raise
|
393
402
|
|
394
403
|
end
|
395
404
|
|
396
|
-
$logger.behaviour "PASS;Application found.;#{id.to_s};sut;{};application
|
405
|
+
$logger.behaviour "PASS;Application found.;#{ id.to_s };sut;{};application;#{ target_application_hash.inspect }"
|
397
406
|
|
398
407
|
app_child
|
399
408
|
|
@@ -655,7 +664,7 @@ module MobyBehaviour
|
|
655
664
|
# [b]NOTE:[/b] Currently only supported on Symbian platform.
|
656
665
|
#
|
657
666
|
# == arguments
|
658
|
-
#
|
667
|
+
# cpu_load
|
659
668
|
# Integer
|
660
669
|
# description: Requested CPU load in percentage.
|
661
670
|
# example: 50
|
data/lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/synchronization.rb
CHANGED
@@ -48,8 +48,15 @@ module MobyBehaviour
|
|
48
48
|
|
49
49
|
class SignalNotEmittedException < RuntimeError
|
50
50
|
|
51
|
+
end
|
52
|
+
|
53
|
+
class EventNotReceivedException < RuntimeError
|
54
|
+
|
51
55
|
end
|
52
56
|
|
57
|
+
class EventsEnabledException < RuntimeError
|
58
|
+
end
|
59
|
+
|
53
60
|
# == description
|
54
61
|
# Synchronizes script execution to a signal. Test script execution is stopped until the expected signal is emitted or the timeout occurs.
|
55
62
|
# If no signals of the given type are found before the timeout an error is raised.\n
|
@@ -65,7 +72,11 @@ module MobyBehaviour
|
|
65
72
|
# String
|
66
73
|
# description: Name of the signal that is to be emitted.
|
67
74
|
# example: "clicked()"
|
68
|
-
#
|
75
|
+
#
|
76
|
+
# params
|
77
|
+
# Hash
|
78
|
+
# description: Optional parameters for wait for signal
|
79
|
+
# example: "{:retry_timeout => 10, :retry_interval => 0.1}"
|
69
80
|
# &block
|
70
81
|
# Proc
|
71
82
|
# description: Optional code block to be executed while listening signals
|
@@ -83,47 +94,155 @@ module MobyBehaviour
|
|
83
94
|
# ArgumentError
|
84
95
|
# description: signal_name was not a valid String or signal_timeout was not a non negative Integer
|
85
96
|
#
|
86
|
-
def wait_for_signal( signal_timeout, signal_name, &block )
|
97
|
+
def wait_for_signal( signal_timeout, signal_name, params = nil, &block )
|
98
|
+
|
99
|
+
signal_timeout.check_type Integer, 'wrong argument type $1 for signal timeout (expected $2)'
|
100
|
+
#raise ArgumentError.new("The timeout argument was of wrong type: expected 'Integer' was '%s'" % signal_timeout.class ) unless signal_timeout.kind_of?( Integer )
|
87
101
|
|
88
|
-
|
102
|
+
signal_timeout.not_negative 'signal timeout value $1 cannot be negative'
|
103
|
+
#raise ArgumentError.new("The timeout argument had a value of '%s', it must be a non negative Integer.'" % signal_timeout ) unless signal_timeout >= 0
|
89
104
|
|
90
|
-
Kernel::raise ArgumentError.new("The timeout argument had a value of '%s', it must be a non negative Integer.'" % signal_timeout ) unless signal_timeout >= 0
|
91
105
|
|
92
|
-
|
106
|
+
signal_name.check_type String, 'wrong argument type $1 for signal name (expected $2)'
|
107
|
+
#raise ArgumentError.new("The signal name argument was of wrong type: expected 'String' was '%s'" % signal_name.class ) unless signal_name.kind_of?( String )
|
108
|
+
|
109
|
+
signal_name.not_empty 'signal name cannot be empty'
|
110
|
+
#raise ArgumentError.new("The signal name argument must not be an empty String.") unless !signal_name.empty?
|
111
|
+
|
112
|
+
params.check_type [ Hash, NilClass ], 'wrong argument type $1 for signal parameters (expected $2)'
|
93
113
|
|
94
|
-
Kernel::raise ArgumentError.new("The signal name argument must not be an empty String.") unless !signal_name.empty?
|
95
|
-
|
96
114
|
# enable signal listening
|
97
115
|
self.fixture( 'signal', 'enable_signal', :signal => signal_name )
|
98
116
|
|
99
|
-
# execute code block if any given
|
100
|
-
|
117
|
+
# execute code block if any given
|
118
|
+
begin
|
119
|
+
|
120
|
+
if params.kind_of?( Hash ) && params.has_key?( :retry_timeout )
|
121
|
+
|
122
|
+
MobyUtil::Retryable.until( :timeout => params[:retry_timeout], :interval => params[:retry_interval], :exception => SignalNotEmittedException) {
|
123
|
+
|
124
|
+
do_wait_signal(signal_timeout, signal_name, &block)
|
125
|
+
|
126
|
+
}
|
127
|
+
|
128
|
+
else
|
129
|
+
|
130
|
+
do_wait_signal(signal_timeout, signal_name, &block)
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
ensure
|
135
|
+
|
136
|
+
self.fixture( "signal", "remove_signals" )
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
nil
|
141
|
+
|
142
|
+
end # wait_for_signal
|
143
|
+
|
144
|
+
# == description
|
145
|
+
# Ensure that an event is fired into the target element
|
146
|
+
#
|
147
|
+
# [b]NOTE:[/b] Limitations:
|
148
|
+
# enable_events can not be enabled. multitouch operations are not supported.
|
149
|
+
#
|
150
|
+
# == arguments
|
151
|
+
# params
|
152
|
+
# Hash
|
153
|
+
# description: Arguments hash, see below
|
154
|
+
# example: Optional paramaters, see table params below.
|
155
|
+
#
|
156
|
+
#
|
157
|
+
# &block
|
158
|
+
# Proc
|
159
|
+
# description: Code block that triggers the event
|
160
|
+
# example: @app.Button.tap
|
161
|
+
#
|
162
|
+
# == tables
|
163
|
+
# params
|
164
|
+
# title: Hash argument params
|
165
|
+
# description: Valid keys for argument tap_params as hash
|
166
|
+
# |Key|Description|Type|Example|Default|
|
167
|
+
# |:retry_interval|Time between retries if the event is not received|Float|2|1|
|
168
|
+
# |:retry_timeout|Timeout for retry cycle|Integer|5|30|
|
169
|
+
# |:sleep_time|Sleep time before fetching events from client|Foat|0.4|0.2|
|
170
|
+
#
|
171
|
+
# == returns
|
172
|
+
# NilClass
|
173
|
+
# description: -
|
174
|
+
# example: -
|
175
|
+
#
|
176
|
+
# == exceptions
|
177
|
+
# EventsEnabledException
|
178
|
+
# description: enable_events is enabled. Event monitoring can not be enabled at the same time
|
179
|
+
#
|
180
|
+
# EventNotReceivedException
|
181
|
+
# description: Target object did not received any events defined
|
182
|
+
#
|
183
|
+
def ensure_event(params = nil, &block)
|
184
|
+
|
185
|
+
raise EventsEnabledException.new("enable_events is used - ensure_events can not be Used at the same time.") if @@_events_enabled
|
186
|
+
raise ArgumentError.new("Must be called to TestObject" ) unless self.kind_of? MobyBase::TestObject
|
187
|
+
|
188
|
+
retry_timeout = (params.nil? || params[:retry_timeout].nil?) ? 30 : params[:retry_timeout]
|
189
|
+
retry_interval = (params.nil? || params[:retry_interval].nil?) ? 1 : params[:retry_interval]
|
190
|
+
sleep_time = (params.nil? || params[:sleep_time].nil?) ? 0.2 : params[:sleep_time]
|
191
|
+
|
192
|
+
events = ['MouseButtonPress,TouchBegin,GraphicsSceneMousePress,KeyPress']
|
193
|
+
if params && params[:events]
|
194
|
+
events = params[:events]
|
195
|
+
end
|
196
|
+
app = self.get_application
|
197
|
+
begin
|
198
|
+
app.enable_events(events, {"track_id" => self.id.to_s})
|
199
|
+
|
200
|
+
MobyUtil::Retryable.until(:timeout => retry_timeout,:interval => retry_interval, :exception => EventNotReceivedException) {
|
201
|
+
block.call if block_given?
|
202
|
+
sleep sleep_time
|
203
|
+
ev = app.get_events
|
204
|
+
begin
|
205
|
+
@sut.state_object(ev).events.attribute('trackedFound')
|
206
|
+
rescue MobyBase::AttributeNotFoundError
|
207
|
+
$stderr.puts "Warning: Operation not received by object #{self.id} : #{self.name}. Retrying"
|
208
|
+
raise EventNotReceivedException.new("No event received during call")
|
209
|
+
end
|
210
|
+
}
|
211
|
+
ensure
|
212
|
+
app.disable_events
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
private
|
217
|
+
|
218
|
+
def do_wait_signal(signal_timeout, signal_name, &block)
|
101
219
|
|
102
220
|
timeout_deadline = ( Time.now + signal_timeout )
|
103
221
|
|
104
222
|
signal_found = false
|
105
|
-
|
223
|
+
|
224
|
+
block.call if block_given?
|
225
|
+
|
106
226
|
while( Time.now < timeout_deadline && !signal_found )
|
107
227
|
|
108
228
|
begin
|
229
|
+
|
230
|
+
result = self.fixture( 'signal', 'get_signal' )
|
231
|
+
|
232
|
+
signals_xml = MobyUtil::XML.parse_string( result )
|
233
|
+
|
234
|
+
_signal_found_xml, unused_rule = @test_object_adapter.get_objects( signals_xml, { :type => 'QtSignal', :name => signal_name }, true )
|
109
235
|
|
110
|
-
|
111
|
-
|
112
|
-
signal_found = true unless _signal_found_xml.empty?
|
113
|
-
|
236
|
+
signal_found = true unless _signal_found_xml.empty?
|
237
|
+
|
114
238
|
end # begin
|
115
|
-
|
239
|
+
|
116
240
|
end # while
|
117
|
-
|
118
|
-
# disable signal listening
|
119
|
-
self.fixture( "signal", "remove_signals" )
|
120
|
-
|
121
|
-
Kernel::raise SignalNotEmittedException.new("The signal %s was not emitted within %s seconds." % [ signal_name, signal_timeout ] ) unless signal_found
|
122
|
-
|
123
|
-
nil
|
124
241
|
|
125
|
-
|
126
|
-
|
242
|
+
raise SignalNotEmittedException, "The signal #{ signal_name } was not emitted within #{ signal_timeout } seconds." unless signal_found
|
243
|
+
|
244
|
+
end
|
245
|
+
|
127
246
|
# enable hooking for performance measurement & debug logging
|
128
247
|
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
129
248
|
|