io.selendroid.android
Class AndroidTouchScreen

java.lang.Object
  extended by io.selendroid.android.AndroidTouchScreen
All Implemented Interfaces:
TouchScreen

public class AndroidTouchScreen
extends Object
implements TouchScreen

Implements touch capabilities of a device.


Constructor Summary
AndroidTouchScreen(ServerInstrumentation instrumentation, MotionSender motions)
           
 
Method Summary
 void doubleTap(Coordinates where)
          Allows the execution of double tapon the screen, analogous to double click using a Mouse.
 void down(int x, int y)
          Allows the execution of the gesture 'down' on the screen.
 void flick(Coordinates where, int xOffset, int yOffset, int speed)
          Allows the execution of flick gestures starting in a location's element.
 void flick(int speedX, int speedY)
          Sends a flick gesture to the current view.
 float getBrightness()
           
 void longPress(Coordinates where)
          Allows the execution of long press gestures.
 void move(int x, int y)
          Allows the execution of the gesture 'move' on the screen.
 void performMultiPointerGesture(android.view.MotionEvent.PointerCoords[]... touches)
          Performs a multi-touch gesture Takes a series of touch coordinates for at least 2 pointers.
 void performTwoPointerGesture(Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, int steps)
          Generates a two-pointer gesture with arbitrary starting and ending points.
 void scroll(Coordinates where, int xOffset, int yOffset)
          Creates a scroll gesture that starts on a particular screen location.
 void scroll(int xOffset, int yOffset)
          Allows the view to be scrolled by an x and y offset.
 void setBrightness(float brightness)
          Set the screen brightness, with a setting of 0 meaning that the screen should be turned off.
 void singleTap(Coordinates where)
          Allows the execution of single tap on the screen, analogous to click using a Mouse.
 void up(int x, int y)
          Allows the execution of the gesture 'up' on the screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidTouchScreen

public AndroidTouchScreen(ServerInstrumentation instrumentation,
                          MotionSender motions)
Method Detail

singleTap

public void singleTap(Coordinates where)
Description copied from interface: TouchScreen
Allows the execution of single tap on the screen, analogous to click using a Mouse.

Specified by:
singleTap in interface TouchScreen
Parameters:
where - The location on the screen. Typically a WebElement

down

public void down(int x,
                 int y)
Description copied from interface: TouchScreen
Allows the execution of the gesture 'down' on the screen. It is typically the first of a sequence of touch gestures.

Specified by:
down in interface TouchScreen
Parameters:
x - The x coordinate relative to the viewport
y - The y coordinate relative to the viewport

up

public void up(int x,
               int y)
Description copied from interface: TouchScreen
Allows the execution of the gesture 'up' on the screen. It is typically the last of a sequence of touch gestures.

Specified by:
up in interface TouchScreen
Parameters:
x - The x coordinate relative to the viewport
y - The y coordinate relative to the viewport

move

public void move(int x,
                 int y)
Description copied from interface: TouchScreen
Allows the execution of the gesture 'move' on the screen.

Specified by:
move in interface TouchScreen
Parameters:
x - The x coordinate relative to the viewport
y - The y coordinate relative to the viewport

scroll

public void scroll(Coordinates where,
                   int xOffset,
                   int yOffset)
Description copied from interface: TouchScreen
Creates a scroll gesture that starts on a particular screen location.

Specified by:
scroll in interface TouchScreen
Parameters:
where - the location where the scroll starts, usually a WebElement.
xOffset - The x offset to scroll
yOffset - The y offset to scroll

doubleTap

public void doubleTap(Coordinates where)
Description copied from interface: TouchScreen
Allows the execution of double tapon the screen, analogous to double click using a Mouse.

Specified by:
doubleTap in interface TouchScreen
Parameters:
where - The coordinates of the element to double tap

longPress

public void longPress(Coordinates where)
Description copied from interface: TouchScreen
Allows the execution of long press gestures.

Specified by:
longPress in interface TouchScreen
Parameters:
where - The coordinate of the element to long press

scroll

public void scroll(int xOffset,
                   int yOffset)
Description copied from interface: TouchScreen
Allows the view to be scrolled by an x and y offset.

Specified by:
scroll in interface TouchScreen
Parameters:
xOffset - The horizontal offset relative to the viewport
yOffset - The vertical offset relative to the viewport

flick

public void flick(int speedX,
                  int speedY)
Description copied from interface: TouchScreen
Sends a flick gesture to the current view.

Specified by:
flick in interface TouchScreen
Parameters:
speedX - The horizontal speed in pixels/second
speedY - The vertical speed in pixels/second

flick

public void flick(Coordinates where,
                  int xOffset,
                  int yOffset,
                  int speed)
Description copied from interface: TouchScreen
Allows the execution of flick gestures starting in a location's element.

Specified by:
flick in interface TouchScreen
Parameters:
where - The coordinate of the element to flick on
xOffset - The x offset relative to the viewport
yOffset - The y offset relative to the viewport

getBrightness

public float getBrightness()
Specified by:
getBrightness in interface TouchScreen
Returns:
The current screen brightness as a float between 0 and 1. If the screen is off, 0.0 will be returned.

setBrightness

public void setBrightness(float brightness)
Description copied from interface: TouchScreen
Set the screen brightness, with a setting of 0 meaning that the screen should be turned off.

Specified by:
setBrightness in interface TouchScreen
Parameters:
brightness - The screen brightness to use.

performTwoPointerGesture

public void performTwoPointerGesture(Point startPoint1,
                                     Point startPoint2,
                                     Point endPoint1,
                                     Point endPoint2,
                                     int steps)
Generates a two-pointer gesture with arbitrary starting and ending points.

Parameters:
startPoint1 - start point of pointer 1
startPoint2 - start point of pointer 2
endPoint1 - end point of pointer 1
endPoint2 - end point of pointer 2
steps - the number of steps for the gesture. Steps are injected about 5 milliseconds apart, so 100 steps may take around 0.5 seconds to complete.

performMultiPointerGesture

public void performMultiPointerGesture(android.view.MotionEvent.PointerCoords[]... touches)
Performs a multi-touch gesture Takes a series of touch coordinates for at least 2 pointers. Each pointer must have all of its touch steps defined in an array of MotionEvent.PointerCoords. By having the ability to specify the touch points along the path of a pointer, the caller is able to specify complex gestures like circles, irregular shapes etc, where each pointer may take a different path. To create a single point on a pointer's touch path PointerCoords p = new PointerCoords(); p.x = stepX; p.y = stepY; p.pressure = 1; p.size = 1;

Parameters:
touches - each array of MotionEvent.PointerCoords constitute a single pointer's touch path. Multiple MotionEvent.PointerCoords arrays constitute multiple pointers, each with its own path. Each MotionEvent.PointerCoords in an array constitute a point on a pointer's path.


Copyright © 2014. All rights reserved.