Pinch gestures

584 views
Skip to first unread message

Manasa Muchchatti

unread,
Jan 21, 2013, 7:48:16 AM1/21/13
to robotium-...@googlegroups.com
Hi,

I need to automate Solo to do pinch(Two finger gesture) in my test cases for some scenarios. Can anyone know how to simulate it.?

Thanks

Yahor Paulavets

unread,
Jan 21, 2013, 8:49:39 AM1/21/13
to robotium-...@googlegroups.com
Hello,

I think currently it is not possible.

Please share information, if you find the way.

Best regards,
Yahor


--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/robotium-developers/-/tmZgU-PW5yUJ.
To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.

Sagar Biradar

unread,
Jan 22, 2013, 6:19:11 AM1/22/13
to robotium-...@googlegroups.com
Hi,

I need to do a three finger tap on the device screen to perform some functionality on my android application. Can i simulate this with Robotium?

On Tue, Jan 22, 2013 at 2:29 PM, Joris Janssen <janss...@gmail.com> wrote:
Hi,

I've managed to do so using the code below. Of course you need to determine the start points and measure of pinching that suits your own app:
private void moveZoomTilt() {
long downTime = SystemClock.uptimeMillis();
// event time MUST be retrieved only by this way!
long eventTime = SystemClock.uptimeMillis();
Instrumentation inst = getInstrumentation();

View view = solo.getView(R.id.crop_window);

Rect viewRect = new Rect();
view.getGlobalVisibleRect(viewRect);

//set Overall coords and properties of gestures
PointerCoords[] pointCoords = new PointerCoords[2];
pointCoords[0] = new PointerCoords();
pointCoords[0].pressure = 1;
pointCoords[0].size = 1;
pointCoords[1] = new PointerCoords();
pointCoords[1].pressure = 1;
pointCoords[1].size = 1;
PointerProperties[] props = new PointerProperties[2];
props[0] = new PointerProperties();
props[0].id = 0;
props[0].toolType = MotionEvent.TOOL_TYPE_FINGER;
props[1] = new PointerProperties();
props[1].id = 1;
props[1].toolType = MotionEvent.TOOL_TYPE_FINGER;
//Pinch

// Set start point of fingers. Both in the vertical middle, the first on 1/3 of the horizantal scale, the second on 2/3
float finger2XStart = viewRect.left + (viewRect.width() / 3);
float finger2YStart = viewRect.top + (viewRect.height() / 2);
float finger3XStart = viewRect.left + ((viewRect.width() / 3)*2);
float finger3YStart = viewRect.top + (viewRect.height() / 2);

// finger tracks
float[] tracking2X = { -15, -30, -45, -30, -15, 0, 15, 30, 45, 30, 15, 0, -15, -30 };
float[] tracking2Y = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
float[] tracking3X = { 15, 30, 45, 30, 15, 0, -15, -30, -45, -30, -15, 0, 15, 30 };
float[] tracking3Y = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
// set Start Coordinates 
pointCoords[0].x = finger2XStart;   
pointCoords[0].y = finger2YStart; 
pointCoords[1].x = finger3XStart;   
pointCoords[1].y = finger3YStart; 

try {
// first finger down
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, 1, props, pointCoords, 0, 0, 1, 1, 0, 0, 0, 0);
inst.sendPointerSync(event);
// second finger down
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_POINTER_2_DOWN, 2, props, pointCoords, 0, 0, 1, 1, 0, 0, 0, 0);
inst.sendPointerSync(event);

// move fingers (in j steps)
for(int j = 0; j < tracking2X.length; j++) {
eventTime = SystemClock.uptimeMillis() + 50;
pointCoords[0].x = finger2XStart + tracking2X[j];
pointCoords[0].y = finger2YStart + tracking2Y[j];
pointCoords[1].x = finger3XStart + tracking3X[j];
pointCoords[1].y = finger3YStart + tracking3Y[j];

event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, 2, props, pointCoords, 0, 0, 1, 1, 0, 0, 0, 0);
inst.sendPointerSync(event);
}

eventTime = SystemClock.uptimeMillis();

// second finger up
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_POINTER_2_UP, 2, props, pointCoords, 0, 0, 1, 1, 0, 0, 0, 0);
inst.sendPointerSync(event);
// first finger up
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, 1, props, pointCoords, 0, 0, 1, 1, 0, 0, 0, 0);
inst.sendPointerSync(event);
} catch (Exception exception) {
Log.e("pinchError", exception.getMessage());
}

--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.

To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.



--
Thanks and Regards,
Sagar.Biradar

Yahor Paulavets

unread,
Jan 22, 2013, 5:49:49 AM1/22/13
to robotium-...@googlegroups.com
Thanks for sharing!

Best regards,
Yahor

--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.

Manasa Muchchatti

unread,
Jan 22, 2013, 7:01:21 AM1/22/13
to robotium-...@googlegroups.com
what is R.id.crop_window here?

On Tue, Jan 22, 2013 at 2:29 PM, Joris Janssen <janss...@gmail.com> wrote:
R.id.crop_window




--
Thanks and Regards,
Manasa I M

Manasa Muchchatti

unread,
Feb 5, 2013, 5:06:49 AM2/5/13
to robotium-...@googlegroups.com
Hi Jores,

I tried to implement the above code, my view after this stmnt View view = solo.getView(R.id.crop_window); is null.. so it didnt do anything.


On Tue, Jan 22, 2013 at 7:31 PM, Joris Janssen <janss...@gmail.com> wrote:
I use that to first get the ID and secondly the bounds of my view (named "crop_window"). I only use it to get the location of where i should start my pinch gesture. You can decide any way you want where you want to start your "fingers" for your pinch gesture, and use these points in the finger2XStart (etc.) variables.

Op dinsdag 22 januari 2013 13:01:21 UTC+1 schreef Manasa Muchchatti het volgende:

--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.

To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.

Manasa Muchchatti

unread,
Feb 6, 2013, 4:47:08 AM2/6/13
to robotium-...@googlegroups.com
I tried to run the above code as it is with my apps rsc id, app got crashed.  Here is the error i saw in logcat:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.avatarrom.bazooka/com.avatarrom.bazooka.Launcher}: android.view.InflateException: Binary XML file line #50: Error inflating class com.avatarrom.bazooka.Workspace
E/ACRA    ( 6526):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
E/ACRA    ( 6526):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
E/ACRA    ( 6526):     at android.app.ActivityThread.access$600(ActivityThread.java:132)
E/ACRA    ( 6526):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
E/ACRA    ( 6526):     at android.os.Handler.dispatchMessage(Handler.java:99)
E/ACRA    ( 6526):     at android.os.Looper.loop(Looper.java:137)
E/ACRA    ( 6526):     at android.app.ActivityThread.main(ActivityThread.java:4575)
E/ACRA    ( 6526):     at java.lang.reflect.Method.invokeNative(Native Method)
E/ACRA    ( 6526):     at java.lang.reflect.Method.invoke(Method.java:511)
E/ACRA    ( 6526):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
E/ACRA    ( 6526):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
E/ACRA    ( 6526):     at dalvik.system.NativeStart.main(Native Method)
E/ACRA    ( 6526): Caused by: android.view.InflateException: Binary XML file line #50: Error inflating class com.avatarrom.bazooka.Workspace
E/ACRA    ( 6526):     at android.view.LayoutInflater.createView(LayoutInflater.java:606)
E/ACRA    ( 6526):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
E/ACRA    ( 6526):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/ACRA    ( 6526):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/ACRA    ( 6526):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/ACRA    ( 6526):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/ACRA    ( 6526):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
E/ACRA    ( 6526):     at android.app.Activity.setContentView(Activity.java:1835)
E/ACRA    ( 6526):     at com.avatarrom.bazooka.Launcher.onCreate(Launcher.java:454)
E/ACRA    ( 6526):     at android.app.Activity.performCreate(Activity.java:4465)
E/ACRA    ( 6526):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/ACRA    ( 6526):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
E/ACRA    ( 6526):     ... 11 more
E/ACRA    ( 6526): Caused by: java.lang.reflect.InvocationTargetException
E/ACRA    ( 6526):     at java.lang.reflect.Constructor.constructNative(Native Method)
E/ACRA    ( 6526):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/ACRA    ( 6526):     at android.view.LayoutInflater.createView(LayoutInflater.java:586)
E/ACRA    ( 6526):     ... 22 more
E/ACRA    ( 6526): Caused by: java.lang.NoSuchMethodError: com.avatarrom.bazooka.Workspace.getImportantForAccessibility
E/ACRA    ( 6526):     at com.avatarrom.bazooka.Workspace.<init>(Workspace.java:431)
E/ACRA    ( 6526):     at com.avatarrom.bazooka.Workspace.<init>(Workspace.java:346)
E/ACRA    ( 6526):     ... 25 more



When i browsed for 'Error inflating class' i found out that this error occurs when the view size is big.. So any idea...
Reply all
Reply to author
Forward
0 new messages