title: How to mock getApplicationContext
body: <p>I have an application that stores app context information. The app context information  is shared between activities in MyApp class which extends Application class.</p>
  
  <p>I am writing a unit test for my activity, and I want to check that when user clicks a button in the activity, an application state will change. Something like this:</p>
  
  <pre><code>@Override
  public void onClick(View pView) {
      ((MyApp)getApplicationContext()).setNewState();
  }   
  </code></pre>
  
  <p>The problem is that I don't know how to mock that application context. I am using <em>ActivityUnitTestCase</em> as a test case base. When I call <em>setApplication</em>, it changes the value of <em>mApplication</em> member of <em>Activity</em> class, but not application context. I've tried <em>setActivityContext</em> also, but it seems wrong (it is not app context but activity context) and it fires assert inside <em>startActivity</em>).</p>
  
  <p>So the question is - how to mock <em>getApplicationContext()</em>?</p>