title: How to unit test location provider by Robolectric?
body: <p>There are a lot of good docs regard unit testing location such as <a href="http://ckarthik17-tech.blogspot.com/2013/04/android-robolectric-unit-testing.html" rel="nofollow">Android - Robolectric - Unit testing request location updates (LocationManager)</a> but unfortunately didn't find anything regard location provider. Since I'm new to Robolectric I still have no clear insight how it works. Any idea would be appreciated.</p>
  
  <p>Following code is a method I have in my activity. I display a cardView if this method returns false otherwise it is invisible. So I actually want to test visibility of this view but before this I need to mock location provider to return what I want. This is the thing that I'm looking for in first step. Thanks</p>
  
  <pre><code>private boolean isLocationEnabled()
      {
          int locationMode = 0;
          String locationProviders;
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT)
          {
              try
              {
                  locationMode = Settings.Secure.getInt(this.getContentResolver(), Settings.Secure.LOCATION_MODE);
  
              }
              catch (Settings.SettingNotFoundException e)
              {
                  Logger.logException(e);
              }
              return locationMode != Settings.Secure.LOCATION_MODE_OFF;
          }
          else
          {
              locationProviders = Settings.Secure.getString(this.getContentResolver(),
                      Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
              return !TextUtils.isEmpty(locationProviders);
          }
      }
  </code></pre>