### Question:
LinkSpan extends ClickableSpan { @Override public void onClick(View view) { if (dispatchClick(view)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { view.cancelPendingInputEvents(); } } else { Log.w(TAG, "Dropping click event. No listener attached."); } } LinkSpan(String id); @Override void onClick(View view); @Override void updateDrawState(TextPaint drawState); String getId();  }### Answer:
@Test public void testOnClick() { final TestContext context = new TestContext(application); final TextView textView = new TextView(context); final LinkSpan linkSpan = new LinkSpan("test_id"); linkSpan.onClick(textView); assertSame("Clicked LinkSpan should be passed to setup", linkSpan, context.clickedSpan); }
@Test public void testNonImplementingContext() { final TextView textView = new TextView(application); final LinkSpan linkSpan = new LinkSpan("test_id"); linkSpan.onClick(textView); }
@Test public void testWrappedListener() { final TestContext context = new TestContext(application); final Context wrapperContext = new ContextWrapper(context); final TextView textView = new TextView(wrapperContext); final LinkSpan linkSpan = new LinkSpan("test_id"); linkSpan.onClick(textView); assertSame("Clicked LinkSpan should be passed to setup", linkSpan, context.clickedSpan); }