Note that there are some explanatory texts on larger screens.

plurals
  1. POTouchUtils.clickView() does not work on SlidingDrawer Button in unit tests
    text
    copied!<p>I am trying to implemment automated tests for my app.</p> <p>I have sliding drawer in view which opens when touched, inside is a button. What I want to do is to touch sliding drawer to open it, touch button inside and close sliding drawer touching it again.</p> <p>Here is piece of code of my tests (<i>ActivityInstrumentationTestCase2</i>)</p> <pre><code>ToggleButton insideBtn = (ToggleButton) mActivity.findViewById(R.id.sliding_btn); Button drawerBtn = (Button) mActivity.findViewById(R.id.drawer_btn); TouchUtils.tapView(this,drawerBtn); TouchUtils.tapView(this, insideBtn); TouchUtils.tapView(this, drawerBtn); ...some assertion ... </code></pre> <p>I have found that this code is sometimes working, sometimes not. The problem is that drawer is not opening after touch causing that <i>insideBtn</i> cannot be touched.</p> <p>So I tried this code:</p> <pre><code>ToggleButton insideBtn = (ToggleButton) mActivity.findViewById(R.id.sliding_btn); Button drawerBtn = (Button) mActivity.findViewById(R.id.drawer_btn); SlidingDrawer drawer = (SlidingDrawer) mActivity.findViewById(R.id.drawer); while(!drawer.isOpened()) { TouchUtils.tapView(this,drawerBtn); } TouchUtils.tapView(this, insideBtn); TouchUtils.tapView(this, drawerBtn); ...some assertion ... </code></pre> <p>But the result is that sometimes when test is working it works at first time so loop is not needed. But when it is not working loop is working till infinity - none touch cause drawer to be opened.</p> <p>Do you have any ideas how to write this test to work reliably?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload