Module: MobyBehaviour::QT::Gesture
- Includes:
- Behaviour
- Defined in:
- lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb
Overview
description
Gesture behaviour methods are used to do different gestures with UI objects. Various methods exist for different speeds, targets and other options.
behaviour
QtGesture
requires
testability-driver-qt-sut-plugin
input_type
*
sut_type
QT
sut_version
*
objects
*
Instance Method Summary collapse
-
#drag(direction, distance, button = :Left, optional_params = {}) ⇒ Object
description Drag the object for the given distance.
-
#drag_to(x, y, button = :Left, optional_params = {}) ⇒ Object
description Drag the object to the given coordinates.
-
#drag_to_object(target_object, button = :Left, optional_params = {}) ⇒ Object
description Drag the object to the center of another object.
-
#flick(direction, button = :Left, optional_params = {}) ⇒ Object
description Flick the screen at the location of the object (touch the object and do a flick gesture).
-
#flick_to(x, y, button = :Left, optional_params = {}) ⇒ Object
description Flick the screen at the location of the object (touch the object and do a flick gesture), ending the flick at the specified coordinates.
-
#gesture(direction, speed, distance, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description Perform a gesture with the object.
-
#gesture_from(x, y, speed, distance, direction, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description Perform a gesture with the object, starting the gesture at the specified point inside it.
-
#gesture_points(points, duration, mouse_details = {}, optional_params = {}) ⇒ Object
description Perform a gesture following a track of points.
-
#gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description Perform a gesture with the object, ending the gesture at the specified point.
-
#gesture_to_object(target_object, duration, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description Perform a gesture with the object, ending the gesture at the center of another object.
-
#move(direction, distance, button = :Left, optional_params = {}) ⇒ Object
description Perform a pointer move starting at the object.
-
#object_center_x ⇒ Object
nodoc utility function for getting the x coordinate of the center of the object, should this be private method?.
-
#object_center_y ⇒ Object
nodoc utility function for getting the y coordinate of the center of the object, should this be private method?.
Methods included from Behaviour
Instance Method Details
#drag(direction, distance, button = :Left, optional_params = {}) ⇒ Object
description
Drag the object for the given distance.
By default a drag is a slow gesture.
arguments
direction
Symbol
description: Direction of the drag. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
example: :Left
Integer
description: Direction of the drag as degrees with 0 being up and 90 right.
example: 270
distance
Integer
description: Number of pixels that the object is to be dragged.
example: 100
button
Symbol
description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
example: :Right
default: :Left
optional_params
Hash
description: The only optional argument supported by drag is :use_tap_screen.
example: { :use_tap_screen => 'true' }
default: { :use_tap_screen => 'false' }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 665 def drag(direction, distance, = :Left, optional_params = {}) begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[:use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:useTapScreen] = use_tap_screen speed = calculate_speed( distance, sut_parameters[ :gesture_drag_speed ] ) params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => true, :button => } params.merge!(optional_params) do_gesture(params) do_sleep( speed ) rescue Exception => e $logger.behaviour "FAIL;Failed drag with direction \"#{direction}\", distance \"#{distance}\", button \"#{.to_s}\".;#{identity};drag;" raise e end $logger.behaviour "PASS;Operation drag executed successfully with direction \"#{direction}\", distance \"#{distance}\", button \"#{.to_s}\".;#{identity};drag;" self end |
#drag_to(x, y, button = :Left, optional_params = {}) ⇒ Object
description
Drag the object to the given coordinates. By default a drag is a slow gesture.
arguments
x
Integer
description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
example: 300
y
Integer
description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
example: 300
button
Symbol
description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
example: :Right
default: :Left
optional_params
Hash
description: The only optional argument supported by drag_to is :use_tap_screen.
example: { :use_tap_screen => 'true' }
default: { :use_tap_screen => 'false' }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 731 def drag_to( x, y, = :Left, optional_params= {} ) begin optional_params.merge!({ :isDrag => true, :button=>}) distance = distance_to_point(x,y) speed = calculate_speed(distance, sut_parameters[:gesture_drag_speed]) gesture_to(x, y, speed, optional_params ) rescue Exception => e $logger.behaviour "FAIL;Failed drag_to with x \"#{x}\", y \"#{y}\", button \"#{.to_s}\".;#{identity};drag;" raise e end $logger.behaviour "PASS;Operation drag_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{.to_s}\".;#{identity};drag;" self end |
#drag_to_object(target_object, button = :Left, optional_params = {}) ⇒ Object
description
Drag the object to the center of another object. By default a drag is a slow gesture.
arguments
target_object
TestObject
description: The object that this object should be dragged to.
example: @app.Node
button
Symbol
description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
example: :Right
default: :Left
optional_params
Hash
description: The only optional argument supported by drag_to_object is :use_tap_screen.
example: { :use_tap_screen => 'true' }
default: { :use_tap_screen => 'false' }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 780 def drag_to_object(target_object, = :Left, optional_params = {}) begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[:use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:useTapScreen] = use_tap_screen distance = distance_to_point(target_object.object_center_x, target_object.object_center_y) #no drag needed, maybe even attempting to drag to it self return if distance == 0 speed = calculate_speed(distance, sut_parameters[:gesture_drag_speed]) params = {:gesture_type => :MouseGestureTo, :speed => speed, :isDrag => true, :button => } params[:targetId] = target_object.id params[:targetType] = target_object.attribute('objectType') params.merge!(optional_params) do_gesture(params) do_sleep(speed) rescue Exception => e $logger.behaviour "FAIL;Failed drag_to_object with button \"#{.to_s}\".;#{identity};drag;" raise e end $logger.behaviour "PASS;Operation drag_to_object executed successfully with button \"#{.to_s}\".;#{identity};drag;" self end |
#flick(direction, button = :Left, optional_params = {}) ⇒ Object
description
Flick the screen at the location of the object (touch the object and do a flick gesture). Speed and distance of the flick are defined in the tdriver_parameters under the sut used. By default a flick is a fast gesture. For custom values see the gesture method.
arguments
direction
Symbol
description: Direction of the flick. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
example: :Left
Integer
description: Direction of the flick as degrees with 0 being up and 90 right.
example: 270
button
Symbol
description: The mouse button pressed while the drag is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
example: :Middle
default: :Left
optional_params
Hash
description: The only optional argument supported by flick is :use_tap_screen.
example: { :use_tap_screen => 'true' }
default: { :use_tap_screen => 'false' }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 84 def flick( direction, = :Left, optional_params = {} ) begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[ :use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:useTapScreen] = use_tap_screen speed = calculate_speed(sut_parameters[:gesture_flick_distance], sut_parameters[:gesture_flick_speed]) distance = sut_parameters[:gesture_flick_distance].to_i params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => , :useTapScreen => use_tap_screen} params.merge!(optional_params) do_gesture(params) do_sleep(speed) rescue Exception => e $logger.behaviour "FAIL;Failed flick with direction \"#{direction}\", button \"#{.to_s}\".;#{identity};flick;" raise e end $logger.behaviour "PASS;Operation flick executed successfully with direction \"#{direction}\", button \"#{.to_s}\".;#{identity};flick;" self end |
#flick_to(x, y, button = :Left, optional_params = {}) ⇒ Object
description
Flick the screen at the location of the object (touch the object and do a flick gesture), ending the flick at the specified coordinates. Speed and distance of the flick are defined in the tdriver_parameters under the sut used. By default a flick is a fast gesture. For custom values see the gesture_to method.
arguments
x
Integer
description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
example: 300
y
Integer
description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
example: 300
button
Symbol
description: The mouse button pressed while the flick is executed can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
example: :Middle
default: :Left
optional_params
Hash
description: The only optional argument supported by flick_to is :use_tap_screen.
example: { :use_tap_screen => 'true' }
default: { :use_tap_screen => 'false' }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 154 def flick_to( x, y, = :Left, optional_params = {}) begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[:use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:useTapScreen] = use_tap_screen speed = calculate_speed( sut_parameters[ :gesture_flick_distance ], sut_parameters[ :gesture_flick_speed ] ) do_gesture( { :gesture_type => :MouseGestureToCoordinates, :x => x, :y => y, :speed => speed, :isDrag => false, :button => , :useTapScreen => use_tap_screen } ) do_sleep(speed) rescue Exception => e $logger.behaviour "FAIL;Failed flick_to with x \"#{x}\", y \"#{y}\", button \"#{.to_s}\".;#{identity};drag;" raise e end $logger.behaviour "PASS;Operation flick_to executed successfully with x \"#{x}\", y \"#{y}\", button \"#{.to_s}\".;#{identity};drag;" self end |
#gesture(direction, speed, distance, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description
Perform a gesture with the object
arguments
direction
Symbol
description: Direction of the gesture. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
example: :Left
Integer
description: Direction of the gesture as degrees with 0 being up and 90 right.
example: 270
speed
Numeric
description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
example: 1
distance
Integer
description: Number of pixels that the object is to be moved in the gesture.
example: 100
optional_params
Hash
description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
example: { :button => :Right }
default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
tables
directions_table
title: Direction symbols table
|Symbol|
|:Left|
|:Right|
|:Up|
|:Down|
buttons_table
title: Mouse button symbols table
|Symbol|Description|
|:Left|Simulate left mouse button|
|:Middle|Simulate middle mouse button|
|:Right|Simulate right mouse button|
|:NoButton|Do not simulate any mouse button|
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 250 def gesture( direction, speed, distance, optional_params = {:button => :Left, :isDrag => false}) begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[ :use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:useTapScreen] = use_tap_screen optional_params['x_off'] = sut_parameters[:tap_x_offset , '0' ], optional_params['y_off'] = sut_parameters[:tap_y_offset , '0' ] #do_gesture(direction, speed, distance, isDrag, button) params = { :gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance } params.merge!(optional_params) do_gesture(params) do_sleep(speed) rescue Exception => e $logger.behaviour "FAIL;Failed gesture with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;" raise e end $logger.behaviour "PASS;Operation gesture executed successfully with direction \"#{direction}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;" self end |
#gesture_from(x, y, speed, distance, direction, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description
Perform a gesture with the object, starting the gesture at the specified point inside it.
arguments
x
Integer
description: X coordinate of the start point. The coordinate is relative to the object top left corner.
example: 20
y
Integer
description: Y coordinate of the start point. The coordinate is relative to the object top left corner.
example: 15
speed
Numeric
description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
example: 1
direction
Symbol
description: Direction of the gesture. Please see this table for valid direction symbols.
example: :Left
Integer
description: Direction of the gesture as degrees with 0 being up and 90 right.
example: 270
distance
Integer
description: Number of pixels that the object is to be moved in the gesture.
example: 100
optional_params
Hash
description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
example: { :button => :Right }
default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid, or the initial point is outside the target object.
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 409 def gesture_from(x, y, speed, distance, direction, optional_params = {:button => :Left, :isDrag => false}) begin raise ArgumentError.new( "Coordinate x:#{x} x_abs:#{x} outside object." ) unless ( x <= attribute( 'width' ).to_i and x >= 0 ) raise ArgumentError.new( "Coordinate y:#{y} y_abs:#{y} outside object." ) unless ( y <= attribute( 'height' ).to_i and y >= 0 ) x_absolute = attribute('x_absolute').to_i + x.to_i y_absolute = attribute('y_absolute').to_i + y.to_i params = {:gesture_type => :MouseGestureFromCoordinates, :x => x_absolute, :y => y_absolute, :speed => speed, :distance => distance, :direction => direction} params.merge!(optional_params) do_gesture(params) do_sleep(speed) rescue Exception => e $logger.behaviour "FAIL;Failed gesture_from with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\", button \".;#{identity};gesture;" raise e end $logger.behaviour "PASS;Operation gesture_from executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", distance \"#{distance.to_s}\".;#{identity};gesture;" self end |
#gesture_points(points, duration, mouse_details = {}, optional_params = {}) ⇒ Object
description
Perform a gesture following a track of points.
arguments
points
Array
description: Each element of this Array defines a point of the gesture as a Hash. Three keys with Integer values are defined for a point: the coordinate as "x" and "y" keys and "interval" as seconds (Note that this is likely a very short time, i.e. fraction of a second).
example: [{"x" => 200,"y" => 100, "interval" => 0.15},{"x" => 200,"y" => 110, "interval" => 0.30}]
duration
Numeric
description: Duration of the gesture in seconds. The value may be an integer or a fractional value as a floating point number.
example: 1
mouse_details
Hash
description: Mouse usage details can be defined by setting the :press, :release and :isDrag keys to true or false. Valid values for the :button key are described in [link="#buttons_table"]the buttons table[/link].
example: { :press => true, :release => true, :button => :Right, :isDrag => false}
default: { :press => true, :release => true, :button => :Left, :isDrag => true}
optional_params
Hash
description: This method only supports the :use_tap_screen optional parameter.
example: { :use_tap_screen => true }
default: { :use_tap_screen => false }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 543 def gesture_points( points, duration, mouse_details = {}, optional_params = {} ) begin # verify that "duration" argument type is correct duration.check_type [ Fixnum, Float ], 'wrong argument type $1 for duration value (expected $2)' # verify that "points" argument type is correct points.check_type Array, 'wrong argument type $1 for gesture points array (expected $2)' # verify that "mouse_details" argument type is correct mouse_details.check_type Hash, 'wrong argument type $1 for mouse details hash (expected $2)' # verify that "optional_params" argument type is correct optional_params.check_type Hash, 'wrong argument type $1 for optional parameters hash (expected $2)' # set default values unless given by caller mouse_details.default_values( :press => true, :release => true, :button => :Left, :isDrag => true ) # verify that given button is valid mouse_details[ :button ].validate @@_valid_buttons, 'unsupported button $3 for gesture points (expected $2)' # initialize command parameters class command = command_params # in qt_behaviour # set command name command.command_name( 'MouseGesturePoints' ) # set command parameters command.command_params( { 'mouseMove' => true, 'button' => @@_buttons_map[ mouse_details[ :button ] ], 'press' => mouse_details[ :press ].true?, 'release' => mouse_details[ :release ].true?, 'isDrag' => mouse_details[ :isDrag ].true?, 'speed' => ( duration.to_f * 1000 ).to_i, 'useTapScreen' => ( optional_params.delete( :use_tap_screen ) || sut_parameters[ :use_tap_screen, false ] ).true? }.merge!( optional_params ) ) # collect points as string command.command_value( points.inject(""){ | result, point | result << "#{ point['x'].to_s },#{ point['y'].to_s },#{ (point['interval']*1000).to_i.to_s };" } ) # execute the command execute_behavior(optional_params, command) # wait until duration is exceeded do_sleep duration.to_f rescue $logger.behaviour "FAIL;Failed gesture_points with points #{ points.inspect }, duration #{ duration.inspect }, mouse_details #{ mouse_details.inspect }.;#{ identity };gesture_points;" raise end $logger.behaviour "PASS;Operation gesture_points executed successfully with points #{ points.inspect }, duration #{ duration.inspect }, mouse_details #{ mouse_details.inspect }.;#{ identity };gesture_points;" self end |
#gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description
Perform a gesture with the object, ending the gesture at the specified point.
arguments
x
Integer
description: X coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
example: 300
y
Integer
description: Y coordinate of the target point. The coordinate is an absolute screen coordinate, relative to the display top left corner.
example: 300
speed
Numeric
description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
example: 1
optional_params
Hash
description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
example: { :button => :Right }
default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 319 def gesture_to(x, y, speed, optional_params = {:button => :Left, :isDrag => false}) begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[ :use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:useTapScreen] = use_tap_screen params = {:gesture_type => :MouseGestureToCoordinates, :speed => speed} if attribute('objectType') == 'Web' elemens_xml_data, unused_rule = @test_object_adapter.get_objects( @sut.xml_data, { :id => attribute('webFrame')}, true ) object_xml_data = elemens_xml_data[0] object_attributes = @test_object_adapter.test_object_attributes(object_xml_data, ['x_absolute', 'y_absolute']) frame_x_absolute = object_attributes['x_absolute'].to_i frame_y_absolute = object_attributes['y_absolute'].to_i new_params = {:x=>(frame_x_absolute + x.to_i + (attribute('width' ).to_i/2)), :y=>(frame_y_absolute + y.to_i + (attribute('height').to_i/2))} params.merge!(new_params) else new_params = {:x=>x, :y=>y} params.merge!(new_params) end params.merge!(optional_params) do_gesture(params) do_sleep(speed) rescue Exception => e $logger.behaviour "FAIL;Failed gesture_to with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\", button \".;#{identity};gesture;" raise e end $logger.behaviour "PASS;Operation gesture_to executed successfully with x \"#{x}\", y \"#{y}\", speed \"#{speed.to_s}\".;#{identity};gesture;" self end |
#gesture_to_object(target_object, duration, optional_params = {:button => :Left, :isDrag => false}) ⇒ Object
description
Perform a gesture with the object, ending the gesture at the center of another object.
arguments
target_object
TestObject
description: The object where the gesture should end.
example: @app.Node
duration
Numeric
description: Duration of the gesture in seconds. The value may be an interger or a fractional value as a floating point number.
example: 1
optional_params
Hash
description: This method supports :use_tap_screen, :isDrag and :button optional arguments. The first two can be either true or false, for :button values please see [link="#buttons_table"]the buttons table[/link].
example: { :button => :Right }
default: { :use_tap_screen => 'false', :isDrag => false, :button => :Left }
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 461 def gesture_to_object(target_object, duration, optional_params = {:button => :Left, :isDrag => false}) if attribute('objectType') == 'Web' elemens_xml_data, unused_rule = @test_object_adapter.get_objects( @sut.xml_data, { :id => attribute('webFrame')}, true ) object_xml_data = elemens_xml_data[0] object_attributes = @test_object_adapter.test_object_attributes(object_xml_data, ['x', 'y']) frame_x = object_attributes['x'].to_i frame_y = object_attributes['y'].to_i puts "x " + frame_x.to_s + " y " + frame_y.to_s gesture_to(target_object.attribute('x').to_i + (target_object.attribute('width' ).to_i/2) - (attribute('width' ).to_i/2 ) - frame_x, target_object.attribute('y').to_i + (target_object.attribute('height').to_i/2) - (attribute('height').to_i/2 ) - frame_y, duration, optional_params) nil return end begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[ :use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:useTapScreen] = use_tap_screen params = {:gesture_type => :MouseGestureTo, :speed => duration} params[:targetId] = target_object.id params[:targetType] = target_object.attribute('objectType') params.merge!(optional_params) do_gesture(params) do_sleep(duration) rescue Exception => e $logger.behaviour "FAIL;Failed gesture_to_object with button.;#{identity};drag;" raise e end $logger.behaviour "PASS;Operation gesture_to_object executed successfully with button.;#{identity};drag;" self end |
#move(direction, distance, button = :Left, optional_params = {}) ⇒ Object
description
Perform a pointer move starting at the object
arguments
direction
Symbol
description: Direction of the move. Please see [link="#directions_table"]the directions table[/link] for valid direction symbols.
example: :Left
Integer
description: Direction of the move as degrees with 0 being up and 90 right.
example: 270
distance
Integer
description: Number of pixels to be moved.
example: 100
button
Symbol
description: The mouse button used with the move can be defined. Please see [link="#buttons_table"]the buttons table[/link] for valid button symbols.
example: :Right
default: :Left
optional_params
Hash
description: The only optional argument supported by drag_to_object is :use_tap_screen.
example: {:use_tap_screen => 'true'}
default: {:use_tap_screen => 'false'}
returns
NilClass
description: Always returns nil
example: nil
exceptions
ArgumentError
description: One of the arguments is not valid
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 855 def move(direction, distance, = :Left, optional_params = {}) begin if optional_params[:use_tap_screen].nil? use_tap_screen = sut_parameters[:use_tap_screen, 'false'] else use_tap_screen = optional_params[:use_tap_screen].to_s end optional_params[:use_tap_screen].to_s optional_params[:useTapScreen] = use_tap_screen speed = calculate_speed( distance, sut_parameters[ :gesture_drag_speed ] ) params = {:gesture_type => :MouseGesture, :direction => direction, :speed => speed, :distance => distance, :isDrag => false, :button => , :isMove => true} params.merge!(optional_params) do_gesture(params) do_sleep( speed ) rescue Exception => e $logger.behaviour "FAIL;Failed move with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;" raise e end $logger.behaviour "PASS;Operation move executed successfully with direction \"#{direction}\", distance \"#{distance}\",.;#{identity};move;" self end |
#object_center_x ⇒ Object
nodoc
utility function for getting the x coordinate of the center of the object, should this be private method?
889 890 891 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 889 def object_center_x center_x end |
#object_center_y ⇒ Object
nodoc
utility function for getting the y coordinate of the center of the object, should this be private method?
895 896 897 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/gesture.rb', line 895 def object_center_y center_y end |