Search code examples
androidandroid-custom-viewandroid-testing

Android - Test if custom view is drawing correctly?


I made a custom view which overrides onDraw method. Is there any way to test this method ?

The only way that comes to my mind is to try to mock the canvas and then compare pixel by pixel with the expected result. Has anybody done this before ?


Solution

  • I think this article explain what are you asking for: https://facebook.github.io/screenshot-tests-for-android/

    In summary, yes it has been done, in the above article you have some hints to how do it.