title: What is a good way to test the onMeasure/onLayout/onDraw methods of a custom View?
body: <p>I just wrote a custom View class that, among other things, allows a developer to easily set borders (e.g. <code>setBorderWidth</code>, <code>setBorderColor</code>, <code>setBorderWidthLeft</code>, etc.). I did this by overriding <code>onMeasure</code>/<code>onDraw</code> and I want to test that the View properly draws these borders.</p>
  
  <p>Ideally, I want something at a higher level than a unit test: basically I want to enforce that if I set borders, they are drawn as expected; if I don't set them they aren't drawn; if I change them, the new borders are drawn and the old ones are no longer visible. This allows me to know that my view is working at a high level.</p>
  
  <p>Things I've considered:</p>
  
  <ol>
  <li>Taking the view in isolation with Robolectric and calling onDraw manually with a mock Canvas (doesn't test invalidation though)</li>
  <li>Making an Activity test case and somehow saving a screenshot of the Activity and analyzing it programmatically.</li>
  </ol>
  
  <p>Neither of these seem great to me, but I'm leaning towards 2). Any other ideas?</p>