I just wrote a custom View class, which, among other things, allows the developer to easily set borders (e.g. setBorderWidth
, setBorderColor
, setBorderWidthLeft
, etc.). I did this by overriding onMeasure
/ onDraw
, and I want to check that View is drawing these borders correctly.
Ideally, I want something at a higher level than unit test: basically I want to ensure that if I set the boundaries, they are drawn as expected; if I donβt install them, they are not drawn; if I change them, new borders will be drawn, and old ones will no longer be visible. This allows me to know that my opinion works at a high level.
Things I reviewed:
- Taking a look in isolation with Robolectric and calling onDraw manually using the Canvas layout (doesn't check for invalidity though)
- Creating a test example of Activity and somehow saving a screenshot of Activity and analyzing it programmatically.
None of them seem big to me, but I tend to 2). Any other ideas?
source share