Pruebas de Android, ¿cómo simular multitouch (zoom in / out) utilizando instrumentos?

Simplemente puedo simular toques individuales – toque, deslice, mantenga, etc en mis pruebas, pero completamente atascado con la simulación de multi toque HTС Desire con Android 2.2.

¿Podría por favor aconsejar, ¿cómo puedo reproducir la cadena de eventos para probar multi-toques?

Creo que necesito usar algún tipo complicado de MotionEvent como MASK o algo como esto, pero no tengo idea de cómo hacerlo.

He encontrado aquí un volcado de eventos de zoom reproducido: http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-3-understanding-touch- Eventos / 1775? Tag = mantle_skin; contenido

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] 

Aquí está mi problema:

  1. Evento ACTION_POINTER_DOWN (pid 1) [# 0 (pid 0) = 153.230; # 1 (pid 1) = 380.538]
  2. Evento ACTION_MOVE [# 0 ** (pid 0) = 153,231 **; # 1 ** (pid 1) = 380,538 **]

¿Cómo puedo generar eventos con 4 coordenadas (pid 0 x0 y0 y pid 1 x1 y1)?

Parece que necesito encontrar la forma de usar el siguiente evento:

Int static, int int, pointerIds, PointerCoords [] pointerCoords, int metaState, float xPrecision, float yPrecision, int deviceId, int edgeFlags, fuente int, int flags)

Gracias a Dan por su respuesta, he intentado esta lógica, pero todavía me encuentro con problemas para agregar coordenadas:

 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 << MotionEvent.ACTION_POINTER_INDEX_SHIFT) + MotionEvent.ACTION_POINTER_DOWN, 138, 189, 0); inst.sendPointerSync(event); event = MotionEvent.obtain(downTime, eventTime, (pointerToMove << 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); 

Estas secuencias de eventos se capturan en mi stub de prueba y se descargan como:

 (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] 

Aquí puede ver, que (2 * 256) + MotionEvent.ACTION_MOVE no cambia el ID del puntero para el evento 🙁 Y pointerToMove << MotionEvent.ACTION_POINTER_INDEX_SHIFT enfoque no está funcionando para ACTION_POINTER_DOWN, puede ser que no estoy autorizado a utilizar tales Manera de POINTER_DOWN?

Mi problema es que no puedo generar 2 pares de coords para el puntero 0 y el puntero 1:

 (14368): event ACTION_POINTER_DOWN(pid 1)[#0(pid 0)=138,189] 

Aquí puedes ver, que usando tu lógica he añadido pid1 al evento, pero todavía no tiene coordenadas, porque x e y estaba asociado con pid 0 ..

Gracias de antemano.

Yahor

Aún no tienen ideas de cómo implementarlo, ¿alguna vez alguien envió un evento multitáctil?

Creo que sólo tiene que indicar el índice de puntero en el parámetro 'acción' pasado a MotionEvent.obtain. Específicamente, los 8 bits superiores de la acción son el índice del puntero y los 8 bits inferiores son la acción (por ejemplo, MotionEvent.ACTION_MOVE). Por lo tanto, si desea mover el segundo puntero esto debería funcionar:

 int pointerToMove = 1; // pointer IDs are zero-based event = MotionEvent.obtain(downTime, eventTime, (pointerToMove << MotionEvent.ACTION_POINTER_INDEX_SHIFT) + MotionEvent.ACTION_MOVE, x0, y0, 0); inst.sendPointerSync(event); 

Decano

Supongo que esto puede ayudarte.

  • Pruebas para las masas con un solo teléfono y un emulador
  • Configuración de Deckard para Gradle. Error con la prueba Robolectric
  • Com.android.builder.testing.ConnectedDevice> hasTests FALLA
  • MonkeyRunner: manera fácil de determinar las coordenadas para MonkeyDevice touch comando?
  • Cómo obtener el texto visible de la contraseña EditText (después de PasswordTransformation - puntos)?
  • Android prueba de acceso al archivo json
  • Excluir el dispositivo de prueba del registro de Firebase Analytics
  • Prueba de uso de la batería
  • No hay error aún Android Studio dice que "no se encontraron pruebas"
  • Diferencia entre InstrumentationTestCase y AndroidTestCase
  • Tarea de integración de prueba independiente en gradle con android
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.