相关疑难解决方法(0)

如何为Android测试生成缩放/捏合手势

我正在尝试生成用于测试的缩放/捏合手势,我尝试使用Android API MotionEvent.obtain(),但发现很难实现缩放/捏合事件.

我从MotionEvent.obtain引用了API .你能告诉我正确的方法吗?

这是我的实现:

//for zoom, we need four points coordinations: start0, start1, end0, end1

Instrumentation inst;

// action down event
MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, 1, prop_start0, pointerCoords_start0, 0,  0, 0, 0, 0, 0, 0, 0 );
inst.sendPointerSync(event);

// action pointer 2 down event
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_POINTER_2_DOWN, 2, properties_start0_1, pointerCoords_start0_1, 0, 0, 0, 0, 0, 0, 0, 0);
inst.sendPointerSync(event);

// action move events
duration = 1000; //1000 ms
event_interval = 10;//time interval …
Run Code Online (Sandbox Code Playgroud)

testing android zoom gesture

20
推荐指数
3
解决办法
1万
查看次数

标签 统计

android ×1

gesture ×1

testing ×1

zoom ×1