unit testing - test location provider in android instrumentation test project -


i have application, uses locationmanager. therefore i'm writing instrumentation test. i've found similar answer, won't work me.

public class locationsensortest extends androidtestcase {   /*package*/ locationmanager lm;   private locationsensor sensor;    @override   protected void setup() throws exception {     super.setup();     sensor = new locationsensor(getcontext());     lm = (locationmanager) getcontext().getsystemservice(context.location_service);     lm.addtestprovider("test", false, false, false, false, false, false, false, criteria.power_low, criteria.accuracy_fine);     lm.settestproviderenabled("test", true);   }    public void testhasanyactivelocationprovider() {     asserttrue(sensor.hasanyactivelocationprovider());   } } 

the test fails during "addtestprovider" securityexception "android.permission.access_mock_location" missing. point instrumentation test androidmanifest.xml has uses permission, application test not.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.app.android.tests" android:versioncode="1" android:versionname="1.0">   <application>     <uses-library android:name="android.test.runner" />     <uses-permission android:name="android.permission.access_mock_location" />   </application>   <instrumentation android:name="android.test.instrumentationtestrunner" android:targetpackage="de.app.android" android:label="requester app tests" />   <uses-sdk android:minsdkversion="4" /> </manifest>  

has idea how solve this?

<uses-permission android:name="android.permission.access_mock_location" /> 

should outside of <application></application>


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -