Reputation: 41
I create an additional method:
public boolean exampleEdTxt1(){
try{
solo.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw);
return true;
}
catch(AssertionError e){
return false;
}
}
But, when test is runing, code
assertTrue(exampleEdTxt1());
always returns success and code
assertFalse(exampleEdTxt1());
always returns fail.
How to check from Robotium that my png is present on the screen?
Upvotes: 1
Views: 1073
Reputation: 41
For
Boolean isVisible2 = (Boolean) solo.getCurrentActivity().getResources().getDrawable(R.drawable.image).isVisible();
code
assertTrue(isVisible2);
always returns success (Even if there is no drawable on the screen) and code
assertFalse(isVisible2);
always returns fail.
Upvotes: 0
Reputation: 99
try using .isShown()
solo.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw).isShown();
this assert i used to check if my image is displayed:
assertEquals(true, solo.getCurrentActivity().findViewById(R.id.getting_started_image_1).isShown());
hope it helps
Here i check for imageView
Boolean isVisible = (Boolean) solo.getCurrentActivity().findViewById(R.id.imageView1).isShown();
assertTrue(isVisible);
Here is to check for drawable (image)
Boolean isVisible2 = (Boolean) solo.getCurrentActivity().getResources().getDrawable(R.drawable.image).isVisible();
assertTrue(isVisible2);
imageView from the xml i used:
<ImageView
android:id="@+id/imageView1"
android:layout_width="186dp"
android:layout_height="90dp"
android:src="@drawable/image" />
Upvotes: 1