Robotium setProgressBar - onStopTrackingTouch 未触发

Robotium setProgressBar - onStopTrackingTouch is not fired

我在 robotium 中编写测试以测试我的应用程序流程时遇到问题。在我的主屏幕(片段)上,我有一个搜索栏,它正在用 onStopTrackingTouch(Seekbar sb) 方法计算一些数据。此数据用于打开包含更多详细信息的新片段。通过使用 robotium setProgressBar(),它似乎在正确的位置设置了进度,但未调用此方法,因此我无法继续下一个片段。有什么方法可以模拟正确的用户行为,从而触发此方法吗?

英语不是我的母语,所以请原谅我的任何错误。 :)

请考虑使用Reflection,直接调用setProgress方法。 请查看创意详情here.

我在我的案例中做了一些变通,因为反射没有解决我的问题(或者我可能不知道如何实施解决方案)。只需在视图上简单拖动即可:

 SeekBar seekBar = (SeekBar) solo.getView(R.id.distanceBar);
            int[] seekBarLocation = new int[2];
            seekBar.getLocationOnScreen(seekBarLocation);
            final float xStart = seekBarLocation[0];
            final float yStart = seekBarLocation[1]+seekBar.getHeight()/2;
            final float xEnd= xStart+seekBar.getWidth()/2;
            final float yEnd = yStart;
            solo.drag(xStart, xEnd,yStart,yEnd,50);