In an Android test, how to check that a View is shown?
Posted
by
Jan Zankowski
on Stack Overflow
See other posts from Stack Overflow
or by Jan Zankowski
Published on 2011-02-07T15:03:12Z
Indexed on
2011/03/04
15:25 UTC
Read the original article
Hit count: 274
Hello,
I'm writing a UI test case (using ActivityUnitTestCase) and would like to check if at a given time a View subclass is visible to the user. I've found the View#isShown() method, which claims to do exactly this - checking the visibility field of this element and all its parents - but somehow it always returns "false" for all the elements. I'll be grateful for some help. If it makes it easier, I can paste some code.
Also, I found ViewAsserts#assertOnScreen(View origin, View view) but it doesn't seem to do the right thing either - always returns true. Am I perhaps calling it wrong: assertOnScreen(viewImTesting.getRootView(), viewImTesting)?
Thanks, Jan
© Stack Overflow or respective owner