title: Attempting to check Settings.System.canWrite(context) result
body: <p>I'm using <strong>Robolectric 3.5</strong> and the latest from <strong>Android Studio 3.0</strong>, and I'm attempting a piece of code, which needs to verify <code>Settings.System.canWrite(Context context)</code> was called and also do something with the <code>true</code>/<code>false</code> result. </p>
  
  <p>I've been checking around, and I cannot figure out how to set up this scenario with Robolectric. </p>
  
  <p>How do you approach it?</p>
  
  <p>//the settings write verifier class...</p>
  
  <pre><code>...
  public SettingsWriteVerifier(ctxt){
     context = ctxt;
  }
  public boolean canWrite() {
      return Settings.System.canWrite(context);
  }
  </code></pre>
  
  <p>// the test</p>
  
  <pre><code>...
  private Context context;
  
  @Before
  public void Setup() throws Exception {
      context = RuntimeEnvironment.application.getApplicationContext();
  }
  
  @Test
  @Config(sdk = Build.VERSION_CODES.N)
  public void AndIsTrue() throws Exception {
      SettingsWriteVerifier s = new SettingsWriteVerifier(context);
      assertEquals(s.canWrite(), true);
  }
  </code></pre>
  
  <p>it blows up with the following:</p>
  
  <pre><code>java.lang.NullPointerException
  at android.provider.Settings$System.canWrite(Settings.java:4055)
  at SettingsWriteVerifierTests.AndCanWrite.AndIsTrue(AndCanWrite.java:41)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:523)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:226)
  at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:108)
  at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:35)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:62)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
  
  
  Process finished with exit code -1
  </code></pre>
  
  <p>There doesn't seem to be any way to set up the canWrite method result, but honestly, I'm still really new to this.</p>
  
  <p>Thanks,
  Kelly</p>