sangmingming / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Please add support for validating images #197

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I don't have a concrete proposal for how this would be implemented, but 
ideally, I could reference a drawable and verify that it matches the displayed 
drawable.  

There's discussion here on some techniques:

https://groups.google.com/d/topic/robotium-developers/m43FrtHZ-IA/discussion

Original issue reported on code.google.com by glenview...@gmail.com on 16 Dec 2011 at 6:10

GoogleCodeExporter commented 9 years ago
I think you can do that by the below code. I have not tried the code but it 
should work. 

getInstrumentation().getTargetContext().getResources().getDrawable(id) and 
check that you do not get an exception back. 

Original comment by renasr...@gmail.com on 7 Jan 2012 at 6:42

GoogleCodeExporter commented 9 years ago
Thanks, I'll give it a shot!

Original comment by glenview...@gmail.com on 7 Jan 2012 at 1:48

GoogleCodeExporter commented 9 years ago
In a particular game and the buttons in game have different drawables. In 
testing I want to test that this particular button has that specific drawable.
For example,
in my source code, 
customerButton.setBackgroundResource(R.drawable.customer_button_background);
noncustomerButton.setBackgroundResource(R.drawable.noncustomer_button_background
);

Now in my test case, I want to do something like this
assertTrue(robotiumSolo.getCurrentActivity.getResources.getDrawable(R.drawable.n
oncustomer_button_background).equals(robotiumSolo.getCurrentActivity.getNoncusto
merButton().getBackground())

But this always return false.
This is not robotium problem, because equals method in Drawable may not be 
implemeneted the way we want.

But several forums suggest that use getBackground().getConstantState() and 
compare they should be equal, but they are still not.

So is there a way to achieve this using robotium.

Original comment by shrik...@gmail.com on 1 Dec 2014 at 12:34