Flutter集成测试中Draggable<Student>组件拖拽自动化实现问题
Flutter集成测试:Draggable组件拖拽自动化测试失败
在Flutter集成测试场景下,尝试对Draggable<Student>类型组件实现拖拽自动化测试,先后试过以下三种方式,但始终无法将元素拖拽至目标容器:
- 组合使用
longPress()与drag()方法 - 基于Offset的
drag()方法 TestGesture的moveTo()方法
测试代码如下:
//await _tester.longPress(_finder); //await _tester.drag(_finder, offset); final Offset firstLocation = _tester.getCenter(_finder); await _tester.longPress(_finder); final TestGesture gesture = await _tester.startGesture(firstLocation, pointer: 5); await _tester.pump(); final Offset secondLocation = _tester.getCenter(dropLocation); await gesture.moveTo(secondLocation);
相关截图说明:
- 组件定位器截图:展示类型为
Draggable<Student>的Widget定位信息 - 功能UI截图:呈现拖拽功能的实际界面效果
- 函数调用代码片段截图:显示相关函数调用的代码片段
内容的提问来源于stack exchange,提问作者Mayur
相关产品推荐
相关产品推荐

