0

I'm using robotium 3.1 and I'd like to wait for a view to disappear, is there some way I can do that easily? My current way involves a ugly busy-loop with sleeps that makes no one happy.

To clarify what I'd like to happen:
waitForView(<View>) //The view appears
//The view is visible for a few seconds
waitForViewNotThere(<View>) //waits until the view has disappeared

The view that appears doesn't contain any text or such either. Any input is very much appreciated.

Ragshi
  • 48
  • 5

3 Answers3

5

This is how:

final TextView helloWorldText = solo.getText("Hello world!");

    solo.waitForCondition(new Condition() {
        @Override
        public boolean isSatisfied() {
            return helloWorldText.getVisibility() == View.INVISIBLE;
        }
    }, 10000);
Steven Mark Ford
  • 3,372
  • 21
  • 32
1

Whatever you do you are probably going to have some sort of sleep in the loop. (If you look at robotiums source it also uses sleeps). You can keep them to a minimum by using the waitforidlesync method on instrumentation that waits for the Ui thread to become idle.

Paul Harris
  • 5,769
  • 1
  • 25
  • 41
0

if you want to wait for a view to disappear, use solo.waitForDialogToClose(long timeout).
Parameters : timeout - the amount of time in milliseconds to wait.
returns : true if the Dialog is closed before the timeout and false if it is not closed.

kamal_prd
  • 543
  • 4
  • 16