本文介绍了如何模拟用户交互(QUOT; FROMUSER =真QUOT;)在一个Robotium测试的搜索栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code区分使用)传递给onProgressChanged(FROMUSER参数搜索栏用户和code相互作用方式:

My code distinguishes user and code interactions with the SeekBar using fromUser parameter passed to onProgressChanged() method:

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean fromUser) {

            if (fromUser) {
                // execute only if it was user interaction with the SeekBar
                ...
            }
        }

当我想测试我的搜索栏与robotium我不能够的搜索栏模拟用户交互

When I'm trying to test my SeekBar with robotium I'm not able to "mock user interaction with the SeekBar":

 solo.setProgressBar(mSeekBar, newValue);

onProgressChanged()回调与FROMUSER执行==假的。

onProgressChanged() callback is executed with fromUser == false.

是否有可能在同一时间写Robotium测试设置搜索栏的进步和嘲笑用户交互(FROMUSER == true)而?

Is it possible to write Robotium test that sets SeekBar's progress and mocks user interaction (fromUser == true) at the same time?

谢谢!

推荐答案

您不能达到与方法setProgressBar,因为它使用 setProgress 从<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.3_r1/android/widget/ProgressBar.java#545\"相对=nofollow> ProgressBar.setProgress 所以FROMUSER设置为false默认情况下。

You cannot achieve that with method setProgressBar, because it uses setProgress from ProgressBar.setProgress so there is fromUser set to false by default.


  1. 解决方案是使用点击屏幕上 - 但实际上你不知道到底在点(进度%)你打,如果你打进度条上所有

  1. solution is to use click on screen - but you actually don't know exactly in which point (% of progress) you hit, if you hit on progress bar at all.

解决方案是使用反射 - 使用setProgress方法,额外的参数(FROMUSER),所以它会使用受保护的方法。我可以在情况下,你必须与它的问题的实施,帮助。

solution is to use reflection - use setProgress method with extra parameter (fromUser), so it will use the protected method. I can help in implementation of that in case you have problems with it.

解决方案是要求robotium团队实施从第2个点法。

solution is to ask robotium team to implement method from 2nd point.

这篇关于如何模拟用户交互(QUOT; FROMUSER =真QUOT;)在一个Robotium测试的搜索栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 10:24