diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseAndroidTestCase.java b/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseAndroidTestCase.java index 26ca8a8924..9efd2d41bf 100644 --- a/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseAndroidTestCase.java +++ b/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseAndroidTestCase.java @@ -19,13 +19,16 @@ import static org.junit.Assert.assertFalse; +import android.Manifest; import android.content.Context; import android.content.SharedPreferences; import android.support.test.InstrumentationRegistry; +import android.support.test.rule.GrantPermissionRule; import it.feio.android.omninotes.db.DbHelper; import it.feio.android.omninotes.utils.Constants; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Rule; public class BaseAndroidTestCase { @@ -37,6 +40,13 @@ public class BaseAndroidTestCase { protected static Context testContext; protected static SharedPreferences prefs; + @Rule + public GrantPermissionRule permissionRule = GrantPermissionRule.grant( + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.RECORD_AUDIO + ); @BeforeClass public static void setUpBeforeClass () { diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseEspressoTest.java b/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseEspressoTest.java index 77005e478f..d8ba96db4e 100644 --- a/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseEspressoTest.java +++ b/omniNotes/src/androidTest/java/it/feio/android/omninotes/BaseEspressoTest.java @@ -48,14 +48,6 @@ public class BaseEspressoTest extends BaseAndroidTestCase { - @Rule - public GrantPermissionRule permissionRule = GrantPermissionRule.grant( - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.RECORD_AUDIO - ); - @Rule public ActivityTestRule activityRule = new ActivityTestRule<>(MainActivity.class, false, false); diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/GeocodeHelperTest.java b/omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/GeocodeHelperTest.java index 6f0ea8bde9..068f94320f 100644 --- a/omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/GeocodeHelperTest.java +++ b/omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/GeocodeHelperTest.java @@ -17,27 +17,23 @@ package it.feio.android.omninotes.utils; -import android.support.test.filters.Suppress; import android.support.test.runner.AndroidJUnit4; import it.feio.android.omninotes.BaseAndroidTestCase; import it.feio.android.omninotes.OmniNotes; import java.io.IOException; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -@Ignore("Unreliable Genymotion emulator results") @RunWith(AndroidJUnit4.class) public class GeocodeHelperTest extends BaseAndroidTestCase { @Test - @Suppress public void testGetAddressFromCoordinates () throws IOException { if (ConnectionManager.internetAvailable(OmniNotes.getAppContext())) { - Double LAT = 43.799328; - Double LON = 11.171552; + double LAT = 43.799328; + double LON = 11.171552; String address = GeocodeHelper.getAddressFromCoordinates(OmniNotes.getAppContext(), LAT, LON); Assert.assertTrue(address.length() > 0); }