Project

General

Profile

Actions

action #39335

closed

drag and drop support in testapi

Added by apachelogger over 5 years ago. Updated about 2 years ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
Feature requests
Target version:
Start date:
2018-08-08
Due date:
% Done:

0%

Estimated time:

Description

It'd be super awesome if the testapi had a function to do drag and drop. This is useful for, well, testing drag and drop. For example in a file manager, or across two applications to check mimetype validation, or to move sliders within an application.

For highest convenience this may actually need additional meaning of needle areas: ideally you'd want to be able to drag and drop from the click area to another area (possibly the second to last in the list of areas?). Additionally, the api should probably allow moving by a pixel delta in any direction.

e.g.

mouse_drag_and_drop(needle=>'foobar', x_offset=>-50)

would assert the needle, mouse down in the click area, move the mouse 50 pixels to the left and release it.

with two areas:

mouse_drag_and_drop(needle=>'foobar')

would match the needle, mose down in the click area, move to the second-to-last area's match and release it.

or without any needles:

mouse_drag_and_drop(x=>500, y=>300, y_offset=>50)

would start the click at the defined coordinates and move down 50 pixels for the release.

For prosperity here's a simple working sample implementation of drag and drop

# cheeky way of getting the click area and calculating the center(
# i.e. click point)
my $needle = assert_screen 'calamares-installer-disk-alongside-adjust';
my $area = $needle->{area}->[-1];
my $x = int($area->{x} + $area->{w} / 2);
my $y = int($area->{y} + $area->{h} / 2);

mouse_set($x, $y);
# mouse down
query_isotovideo('backend_mouse_button', {button => 'left', bstate => 1});
# move to the left
mouse_set($x - 150, $y);
# mouse up
query_isotovideo('backend_mouse_button', {button => 'left', bstate => 0});
# move it away again, lest it screws up needles via hover focus
mouse_hide;
Actions

Also available in: Atom PDF