Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid testing, how to simulate multitouch (zoom in/out) using instruments?
    primarykey
    data
    text
    <p>I can simply simulate single touches - tap, swipe, hold etc in my tests, but completely stuck with simulating multi touch on HTС Desire with Android 2.2.</p> <p>Could you please advise, how can I reproduce events chain to test multi-touches?</p> <p>I think I need to use some tricky kind of MotionEvent like MASK or something like this, but have no idea how do this.</p> <p>I have found here a dump of events of reproduced zooming: <a href="http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-3-understanding-touch-events/1775?tag=mantle_skin;content" rel="noreferrer">http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-3-understanding-touch-events/1775?tag=mantle_skin;content</a></p> <pre><code> 1. event ACTION_DOWN[#0(pid 0)=135,179] 2. event ACTION_MOVE[#0(pid 0)=135,184] 3. event ACTION_MOVE[#0(pid 0)=144,205] 4. event ACTION_MOVE[#0(pid 0)=152,227] 5. event ACTION_POINTER_DOWN(pid 1)[#0(pid 0)=153,230;#1(pid 1)=380,538] 6. event ACTION_MOVE[#0(pid 0)=153,231;#1(pid 1)=380,538] 7. event ACTION_MOVE[#0(pid 0)=155,236;#1(pid 1)=364,512] 8. event ACTION_MOVE[#0(pid 0)=157,240;#1(pid 1)=350,498] 9. event ACTION_MOVE[#0(pid 0)=158,245;#1(pid 1)=343,494] 10. event ACTION_POINTER_UP(pid 0)[#0(pid 0)=158,247;#1(pid 1)=336,484] 11. event ACTION_MOVE[#0(pid 1)=334,481] 12. event ACTION_MOVE[#0(pid 1)=328,472] 13. event ACTION_UP[#0(pid 1)=327,471] </code></pre> <p>Here is my issue:</p> <ol start="5"> <li>event ACTION_POINTER_DOWN(pid 1)[#0(pid 0)=153,230;#1(pid 1)=380,538]</li> <li>event ACTION_MOVE[#0**(pid 0)=153,231**;#1**(pid 1)=380,538**]</li> </ol> <p>How can I generate events with 4 coordinates (pid 0 x0 y0 and pid 1 x1 y1)?</p> <p>Looks like I need to find the way how to use following event:</p> <p>public static MotionEvent obtain (long downTime, long eventTime, int action, int pointers, int[] pointerIds, PointerCoords[] pointerCoords, int metaState, float xPrecision, float yPrecision, int deviceId, int edgeFlags, int source, int flags)</p> <p>Thanks to Dan for reply, I have tried this logic, but still encountering problems to add coordinates:</p> <pre><code>MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, 135, 179, 0); inst.sendPointerSync(event); // eventTime+=100; event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, 135, 184, 0); inst.sendPointerSync(event); // eventTime+=100; int pointerToMove = 1; // pointer IDs are zero-based event = MotionEvent.obtain(downTime, eventTime, (pointerToMove &lt;&lt; MotionEvent.ACTION_POINTER_INDEX_SHIFT) + MotionEvent.ACTION_POINTER_DOWN, 138, 189, 0); inst.sendPointerSync(event); event = MotionEvent.obtain(downTime, eventTime, (pointerToMove &lt;&lt; MotionEvent.ACTION_POINTER_INDEX_SHIFT) + MotionEvent.ACTION_MOVE, 158, 220, 0); inst.sendPointerSync(event); // eventTime+=100; event = MotionEvent.obtain(downTime, eventTime, (2 * 256) + MotionEvent.ACTION_MOVE, 138, 180, 0); inst.sendPointerSync(event); // eventTime+=100; event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, 135, 184, 0); </code></pre> <p>These events sequence are caught in my test stub and dumped like:</p> <pre><code>(14368): event ACTION_DOWN[#0(pid 0)=135,179] (14368): event ACTION_MOVE[#0(pid 0)=135,184] (14368): event ACTION_POINTER_DOWN(pid 1)[#0(pid 0)=138,189] (14368): event ACTION_MOVE[#0(pid 0)=158,220] (14368): event ACTION_MOVE[#0(pid 0)=138,180] (14368): event ACTION_MOVE[#0(pid 0)=135,184] </code></pre> <p>Here you can see, that (2 * 256) + MotionEvent.ACTION_MOVE doesn't change the pointer ID for event :( And pointerToMove &lt;&lt; MotionEvent.ACTION_POINTER_INDEX_SHIFT approach is not working for ACTION_POINTER_DOWN, may be I'm not allowed to use such way for POINTER_DOWN?</p> <p>My issue is that I can't generate 2 pair of coords for Pointer 0 and Pointer 1:</p> <pre><code>(14368): event ACTION_POINTER_DOWN(pid 1)[#0(pid 0)=138,189] </code></pre> <p>Here you can see, that using your logic I have added pid1 to the event, but it is still has no coordinates, cause x and y was associated with pid 0..</p> <p>Thank you in advance.</p> <p>Yahor</p> <p>Still have no ideas how to implement it, did somebody ever send a multitouch event?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload