Skip to content

Commit

Permalink
Refactored some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Nov 11, 2019
1 parent 17bf6d1 commit 6e18b2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class, false, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 6e18b2f

Please sign in to comment.