title: How to debug Android activity/view events
body: <p>I am trying to write unit tests for my Android application. The particular test I'm having trouble with is just to make sure that when the user taps somewhere on my MapView, the application drops a marker where the user tapped. But everything I try leaves me with some kind of error message. Does anybody know how to write something like this?</p>
  
  <p>Here's what I've tried so far:</p>
  
  <pre><code>public class MyMapActivityTest extends ActivityInstrumentationTestCase2&lt;MyMapActivity&gt; {
  
  public MyMapActivityTest() {
      super("com.example.blah", MyMapActivity.class);
  }
  
  public void testPreconditions() {
      assertNotNull(getActivity().findViewById(com.example.blah.R.id.mapview));
  }
  
  // This method gives me the following error message: java.lang.SecurityException: Injecting to another application requires INJECT_EVENT permission
  public void testTap1() {
      final MyMapActivity m = getActivity();
      final MapView mapView = (MapView) m.findViewById(com.example.blah.R.id.mapview);
  
      getInstrumentation().waitForIdleSync();
      getInstrumentation().sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 1, 0, 0));
  
      assertTrue(true);    // this doesn't execute
  
  }
  
  // junit.framework.AssertionFailedError: Click can not be completed! Something is in the way e.g. the keyboard
  public void testTap2() {
      final MyMapActivity m = getActivity();
      final MapView mapView = (MapView) m.findViewById(com.example.blah.R.id.mapview);
  
      // Robotium
      Solo solo = new Solo(getInstrumentation(), m);
      solo.clickOnScreen(1,1);
  
      assertTrue(true);    // this doesn't execute
  }
  
  
  // This method gives me the following error message: java.lang.SecurityException: Injecting to another application requires INJECT_EVENT permission
  public void testTap3() {
      final MyMapActivity m = getActivity();
      final MapView mapView = (MapView) m.findViewById(com.example.blah.R.id.mapview);
  
      TouchUtils.tapView(this, mapView);
  
      assertTrue(true);    // this doesn't execute
  }
  </code></pre>
  
  <p>}</p>