aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.settings/edu.umd.cs.findbugs.core.prefs133
-rw-r--r--tests/src/cgeo/geocaching/CgeoApplicationTest.java (renamed from tests/src/cgeo/geocaching/cgeoApplicationTest.java)32
-rw-r--r--tests/src/cgeo/geocaching/GeocacheTest.java2
-rw-r--r--tests/src/cgeo/geocaching/HtmlPerformanceTest.java3
-rw-r--r--tests/src/cgeo/geocaching/PersonalNoteTest.java4
-rw-r--r--tests/src/cgeo/geocaching/SearchResultTest.java2
-rw-r--r--tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java6
-rw-r--r--tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java33
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java4
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java8
-rw-r--r--tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java7
-rw-r--r--tests/src/cgeo/geocaching/export/ExportTest.java3
-rw-r--r--tests/src/cgeo/geocaching/files/GPXImporterTest.java23
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java4
-rw-r--r--tests/src/cgeo/geocaching/filter/TerrainFilterTest.java2
-rw-r--r--tests/src/cgeo/geocaching/settings/TestSettings.java4
-rw-r--r--tests/src/cgeo/geocaching/test/CgeoTestsActivity.java13
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java4
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2CJPF.java4
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2JVEH.java4
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC3XX5J.java10
21 files changed, 238 insertions, 67 deletions
diff --git a/tests/.settings/edu.umd.cs.findbugs.core.prefs b/tests/.settings/edu.umd.cs.findbugs.core.prefs
new file mode 100644
index 0000000..a16868e
--- /dev/null
+++ b/tests/.settings/edu.umd.cs.findbugs.core.prefs
@@ -0,0 +1,133 @@
+#FindBugs User Preferences
+#Sun Dec 08 19:08:28 CET 2013
+cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud
+detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
+detectorAtomicityProblem=AtomicityProblem|true
+detectorBadAppletConstructor=BadAppletConstructor|false
+detectorBadResultSetAccess=BadResultSetAccess|true
+detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
+detectorBadUseOfReturnValue=BadUseOfReturnValue|true
+detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
+detectorBooleanReturnNull=BooleanReturnNull|true
+detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
+detectorCheckExpectedWarnings=CheckExpectedWarnings|false
+detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
+detectorCheckTypeQualifiers=CheckTypeQualifiers|true
+detectorCloneIdiom=CloneIdiom|true
+detectorComparatorIdiom=ComparatorIdiom|true
+detectorConfusedInheritance=ConfusedInheritance|true
+detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
+detectorCrossSiteScripting=CrossSiteScripting|true
+detectorDefaultEncodingDetector=DefaultEncodingDetector|true
+detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
+detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
+detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
+detectorDontUseEnum=DontUseEnum|true
+detectorDroppedException=DroppedException|true
+detectorDumbMethodInvocations=DumbMethodInvocations|true
+detectorDumbMethods=DumbMethods|true
+detectorDuplicateBranches=DuplicateBranches|true
+detectorEmptyZipFileEntry=EmptyZipFileEntry|true
+detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
+detectorExplicitSerialization=ExplicitSerialization|true
+detectorFinalizerNullsFields=FinalizerNullsFields|true
+detectorFindBadCast2=FindBadCast2|true
+detectorFindBadForLoop=FindBadForLoop|true
+detectorFindCircularDependencies=FindCircularDependencies|false
+detectorFindDeadLocalStores=FindDeadLocalStores|true
+detectorFindDoubleCheck=FindDoubleCheck|true
+detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
+detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
+detectorFindFinalizeInvocations=FindFinalizeInvocations|true
+detectorFindFloatEquality=FindFloatEquality|true
+detectorFindHEmismatch=FindHEmismatch|true
+detectorFindInconsistentSync2=FindInconsistentSync2|true
+detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
+detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
+detectorFindMaskedFields=FindMaskedFields|true
+detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
+detectorFindNakedNotify=FindNakedNotify|true
+detectorFindNonShortCircuit=FindNonShortCircuit|true
+detectorFindNullDeref=FindNullDeref|true
+detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
+detectorFindOpenStream=FindOpenStream|true
+detectorFindPuzzlers=FindPuzzlers|true
+detectorFindRefComparison=FindRefComparison|true
+detectorFindReturnRef=FindReturnRef|true
+detectorFindRunInvocations=FindRunInvocations|true
+detectorFindSelfComparison=FindSelfComparison|true
+detectorFindSelfComparison2=FindSelfComparison2|true
+detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
+detectorFindSpinLoop=FindSpinLoop|true
+detectorFindSqlInjection=FindSqlInjection|true
+detectorFindTwoLockWait=FindTwoLockWait|true
+detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
+detectorFindUnconditionalWait=FindUnconditionalWait|true
+detectorFindUninitializedGet=FindUninitializedGet|true
+detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
+detectorFindUnreleasedLock=FindUnreleasedLock|true
+detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
+detectorFindUnsyncGet=FindUnsyncGet|true
+detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
+detectorFindUselessControlFlow=FindUselessControlFlow|true
+detectorFormatStringChecker=FormatStringChecker|true
+detectorHugeSharedStringConstants=HugeSharedStringConstants|true
+detectorIDivResultCastToDouble=IDivResultCastToDouble|true
+detectorIncompatMask=IncompatMask|true
+detectorInconsistentAnnotations=InconsistentAnnotations|true
+detectorInefficientMemberAccess=InefficientMemberAccess|false
+detectorInefficientToArray=InefficientToArray|true
+detectorInfiniteLoop=InfiniteLoop|true
+detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
+detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
+detectorInitializationChain=InitializationChain|true
+detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
+detectorInstantiateStaticClass=InstantiateStaticClass|true
+detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
+detectorInvalidJUnitTest=InvalidJUnitTest|true
+detectorIteratorIdioms=IteratorIdioms|true
+detectorLazyInit=LazyInit|true
+detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
+detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
+detectorMethodReturnCheck=MethodReturnCheck|true
+detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
+detectorMutableLock=MutableLock|true
+detectorMutableStaticFields=MutableStaticFields|true
+detectorNaming=Naming|true
+detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
+detectorNumberConstructor=NumberConstructor|true
+detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
+detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
+detectorPublicSemaphores=PublicSemaphores|false
+detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
+detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
+detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
+detectorRedundantInterfaces=RedundantInterfaces|true
+detectorRepeatedConditionals=RepeatedConditionals|true
+detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
+detectorSerializableIdiom=SerializableIdiom|true
+detectorStartInConstructor=StartInConstructor|true
+detectorStaticCalendarDetector=StaticCalendarDetector|true
+detectorStringConcatenation=StringConcatenation|true
+detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
+detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
+detectorSwitchFallthrough=SwitchFallthrough|true
+detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
+detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
+detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
+detectorURLProblems=URLProblems|true
+detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
+detectorUnnecessaryMath=UnnecessaryMath|true
+detectorUnreadFields=UnreadFields|true
+detectorUselessSubclassMethod=UselessSubclassMethod|true
+detectorVarArgsProblems=VarArgsProblems|true
+detectorVolatileUsage=VolatileUsage|true
+detectorWaitInLoop=WaitInLoop|true
+detectorWrongMapIterator=WrongMapIterator|true
+detectorXMLFactoryBypass=XMLFactoryBypass|true
+detector_threshold=3
+effort=max
+excludefilter0=../main/project/findbugs/exclusions.xml|true
+filter_settings=Low|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|20
+filter_settings_neg=NOISE,I18N|
+run_at_full_build=true
diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
index f218518..f772be6 100644
--- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
@@ -2,8 +2,9 @@ package cgeo.geocaching;
import cgeo.CGeoTestCase;
import cgeo.geocaching.connector.ConnectorFactory;
+import cgeo.geocaching.connector.gc.GCLogin;
import cgeo.geocaching.connector.gc.GCParser;
-import cgeo.geocaching.connector.gc.Login;
+import cgeo.geocaching.connector.gc.MapTokens;
import cgeo.geocaching.connector.gc.Tile;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy;
@@ -40,7 +41,9 @@ import junit.framework.Assert;
* application and/or context.
*/
-public class cgeoApplicationTest extends CGeoTestCase {
+public class CgeoApplicationTest extends CGeoTestCase {
+
+ private static final MapTokens INVALID_TOKEN = null;
/**
* The name 'test preconditions' is a convention to signal that if this test
@@ -51,7 +54,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
@SuppressWarnings("static-method")
@SmallTest
public void testPreconditions() {
- assertEquals(StatusCode.NO_ERROR, Login.login());
+ assertEquals(StatusCode.NO_ERROR, GCLogin.getInstance().login());
}
/**
@@ -69,6 +72,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
@MediumTest
public static void testSearchTrackable() {
final Trackable tb = GCParser.searchTrackable("TB2J1VZ", null, null);
+ assertNotNull(tb);
// fix data
assertEquals("aefffb86-099f-444f-b132-605436163aa8", tb.getGuid());
assertEquals("TB2J1VZ", tb.getGeocode());
@@ -134,7 +138,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
* @param runnable
*/
private static void withMockedLoginDo(final Runnable runnable) {
- final ImmutablePair<String, String> login = Settings.getGcLogin();
+ final ImmutablePair<String, String> login = Settings.getGcCredentials();
final String memberStatus = Settings.getMemberStatus();
try {
@@ -143,7 +147,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
// restore user and password
TestSettings.setLogin(login.left, login.right);
Settings.setMemberStatus(memberStatus);
- Login.login();
+ GCLogin.getInstance().login();
}
}
@@ -268,7 +272,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
public void run() {
final SearchResult search = GCParser.searchByUsername("blafoo", CacheType.WEBCAM, false, null);
assertNotNull(search);
- assertEquals(4, search.getTotal());
+ assertEquals(4, search.getTotalCountGC());
assertTrue(search.getGeocodes().contains("GCP0A9"));
}
});
@@ -295,7 +299,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
final GC2CJPF mockedCache = new GC2CJPF();
deleteCacheFromDB(mockedCache.getGeocode());
- final String[] tokens = Login.getMapTokens();
+ final MapTokens tokens = GCLogin.getMapTokens();
final Viewport viewport = new Viewport(mockedCache, 0.003, 0.003);
// check coords for DETAILED
@@ -344,8 +348,6 @@ public class cgeoApplicationTest extends CGeoTestCase {
try {
- final String[] tokens = null; // without a valid token we are "logged off"
-
// non premium cache
MockedCache cache = new GC2CJPF();
deleteCacheFromDBAndLogout(cache.getGeocode());
@@ -353,7 +355,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
Settings.setCacheType(CacheType.ALL);
Viewport viewport = new Viewport(cache, 0.003, 0.003);
- SearchResult search = ConnectorFactory.searchByViewport(viewport, tokens);
+ SearchResult search = ConnectorFactory.searchByViewport(viewport, INVALID_TOKEN);
assertNotNull(search);
assertTrue(search.getGeocodes().contains(cache.getGeocode()));
@@ -370,7 +372,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
deleteCacheFromDBAndLogout(cache.getGeocode());
viewport = new Viewport(cache, 0.003, 0.003);
- search = ConnectorFactory.searchByViewport(viewport, tokens);
+ search = ConnectorFactory.searchByViewport(viewport, INVALID_TOKEN);
assertNotNull(search);
// depending on the chosen strategy the cache is part of the search or not
@@ -392,7 +394,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
String oldUser = mockedCache.getMockedDataUser();
try {
mockedCache.setMockedDataUser(Settings.getUsername());
- Geocache parsedCache = cgeoApplicationTest.testSearchByGeocode(mockedCache.getGeocode());
+ Geocache parsedCache = CgeoApplicationTest.testSearchByGeocode(mockedCache.getGeocode());
if (null != parsedCache) {
Compare.assertCompareCaches(mockedCache, parsedCache, true);
}
@@ -406,10 +408,10 @@ public class cgeoApplicationTest extends CGeoTestCase {
* Caches that are good test cases
*/
public static void testSearchByGeocodeSpecialties() {
- final Geocache GCV2R9 = cgeoApplicationTest.testSearchByGeocode("GCV2R9");
+ final Geocache GCV2R9 = CgeoApplicationTest.testSearchByGeocode("GCV2R9");
Assert.assertEquals("California, United States", GCV2R9.getLocation());
- final Geocache GC1ZXEZ = cgeoApplicationTest.testSearchByGeocode("GC1ZXEZ");
+ final Geocache GC1ZXEZ = CgeoApplicationTest.testSearchByGeocode("GC1ZXEZ");
Assert.assertEquals("Ms.Marple/Mr.Stringer", GC1ZXEZ.getOwnerUserId());
}
@@ -417,7 +419,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
private static void deleteCacheFromDBAndLogout(String geocode) {
deleteCacheFromDB(geocode);
- Login.logout();
+ GCLogin.getInstance().logout();
// Modify login data to avoid an automatic login again
TestSettings.setLogin("c:geo", "c:geo");
Settings.setMemberStatus("Basic member");
diff --git a/tests/src/cgeo/geocaching/GeocacheTest.java b/tests/src/cgeo/geocaching/GeocacheTest.java
index 5d9a31c..cdca9b7 100644
--- a/tests/src/cgeo/geocaching/GeocacheTest.java
+++ b/tests/src/cgeo/geocaching/GeocacheTest.java
@@ -245,6 +245,8 @@ public class GeocacheTest extends CGeoTestCase {
assertTime("text 14:20.", 14, 20);
assertTime("<b>14:20</b>", 14, 20);
assertTime("<u><em>Uhrzeit:</em></u> 17-20 " + timeHours + "</span></strong>", 17, 00);
+ assertTime("von 11 bis 13 " + timeHours, 11, 00);
+ assertTime("from 11 to 13 " + timeHours, 11, 00);
}
private static void assertTime(final String description, final int hours, final int minutes) {
diff --git a/tests/src/cgeo/geocaching/HtmlPerformanceTest.java b/tests/src/cgeo/geocaching/HtmlPerformanceTest.java
index b08b06e..695cd4a 100644
--- a/tests/src/cgeo/geocaching/HtmlPerformanceTest.java
+++ b/tests/src/cgeo/geocaching/HtmlPerformanceTest.java
@@ -2,6 +2,8 @@ package cgeo.geocaching;
import cgeo.geocaching.utils.Log;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
import org.apache.commons.lang3.StringEscapeUtils;
import android.os.SystemClock;
@@ -51,6 +53,7 @@ public class HtmlPerformanceTest extends AndroidTestCase {
});
}
+ @SuppressFBWarnings("DM_GC")
private static long measure(String label, Runnable runnable) {
System.gc();
final long start = SystemClock.elapsedRealtime();
diff --git a/tests/src/cgeo/geocaching/PersonalNoteTest.java b/tests/src/cgeo/geocaching/PersonalNoteTest.java
index 38085d5..74e1bab 100644
--- a/tests/src/cgeo/geocaching/PersonalNoteTest.java
+++ b/tests/src/cgeo/geocaching/PersonalNoteTest.java
@@ -36,10 +36,10 @@ public class PersonalNoteTest extends TestCase {
Geocache exceedingCache = new Geocache();
exceedingCache.setListId(StoredList.STANDARD_LIST_ID); // stored
- exceedingCache.setPersonalNote(testString.toString());
+ exceedingCache.setPersonalNote(testString);
PersonalNote otherNote = new PersonalNote(exceedingCache);
PersonalNote result = parsedNote.mergeWith(otherNote);
- assertPersonalNote(result, null, testString.toString());
+ assertPersonalNote(result, null, testString);
}
public static void testParseCgeoOnly() {
diff --git a/tests/src/cgeo/geocaching/SearchResultTest.java b/tests/src/cgeo/geocaching/SearchResultTest.java
index 9bce5a5..3f9f07f 100644
--- a/tests/src/cgeo/geocaching/SearchResultTest.java
+++ b/tests/src/cgeo/geocaching/SearchResultTest.java
@@ -13,7 +13,7 @@ public class SearchResultTest extends AndroidTestCase {
geocodes.add("GC23456");
final SearchResult searchResult = new SearchResult(geocodes);
assertEquals(2, searchResult.getCount());
- assertEquals(2, searchResult.getTotal());
+ assertEquals(2, searchResult.getTotalCountGC());
assertTrue(searchResult.getGeocodes().contains("GC12345"));
}
diff --git a/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java b/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java
index ca396e1..e41e316 100644
--- a/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java
+++ b/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java
@@ -5,12 +5,14 @@ import cgeo.geocaching.connector.oc.OCConnector;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
import cgeo.geocaching.test.mock.GC1ZXX2;
+import java.util.Collection;
+
public class ConnectorFactoryTest extends AbstractResourceInstrumentationTestCase {
public static void testGetConnectors() {
- final IConnector[] connectors = ConnectorFactory.getConnectors();
+ final Collection<IConnector> connectors = ConnectorFactory.getConnectors();
assertNotNull(connectors);
- assertTrue(connectors.length > 0); // unknown connector must exist
+ assertFalse(connectors.isEmpty()); // unknown connector must exist
}
public static void testCanHandle() {
diff --git a/tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java b/tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java
new file mode 100644
index 0000000..4b9ae37
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/ec/ECConnectorTest.java
@@ -0,0 +1,33 @@
+package cgeo.geocaching.connector.ec;
+
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LogType;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class ECConnectorTest extends TestCase {
+
+ public static void testCanHandle() throws Exception {
+ assertTrue(ECConnector.getInstance().canHandle("EC380"));
+ assertFalse(ECConnector.getInstance().canHandle("GC380"));
+ assertFalse("faked EC codes must be handled during the import, otherwise GCECxxxx codes belong to 2 connectors", ECConnector.getInstance().canHandle("GCEC380"));
+ }
+
+ public static void testGetPossibleLogTypes() throws Exception {
+ final List<LogType> possibleLogTypes = ECConnector.getInstance().getPossibleLogTypes(createCache());
+ assertNotNull(possibleLogTypes);
+ assertFalse(possibleLogTypes.isEmpty());
+ assertTrue(possibleLogTypes.contains(LogType.FOUND_IT));
+ }
+
+ private static Geocache createCache() {
+ final Geocache geocache = new Geocache();
+ geocache.setType(CacheType.TRADITIONAL);
+ geocache.setGeocode("EC727");
+ return geocache;
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
index d3e7a27..0caa7d4 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
@@ -20,9 +20,9 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
// set up settings required for test
TestSettings.setExcludeMine(false);
Settings.setCacheType(CacheType.ALL);
- Login.login();
+ GCLogin.getInstance().login();
- final String[] tokens = Login.getMapTokens();
+ final MapTokens tokens = GCLogin.getMapTokens();
{
final Viewport viewport = new Viewport(new Geopoint("N 52° 25.369 E 9° 35.499"), new Geopoint("N 52° 25.600 E 9° 36.200"));
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
index 40062f1..60ff500 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
@@ -45,10 +45,10 @@ public class GCConstantsTest extends AndroidTestCase {
*/
public static void testCacheCountOnline() {
- Login.logout();
- Login.setActualCachesFound(0);
- Login.login();
- assertTrue(Login.getActualCachesFound() > 0);
+ GCLogin.getInstance().logout();
+ GCLogin.getInstance().setActualCachesFound(0);
+ GCLogin.getInstance().login();
+ assertTrue(GCLogin.getInstance().getActualCachesFound() > 0);
}
public static void testConstants() {
diff --git a/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
index 9c3063d..2f11dfc 100644
--- a/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
@@ -27,4 +27,11 @@ public class CacheSizeTest extends AndroidTestCase {
assertEquals(size, CacheSize.getById(size.id.toUpperCase(Locale.US)));
}
}
+
+ public static void testGetByIdNumeric() {
+ assertEquals(CacheSize.REGULAR, CacheSize.getById("3"));
+ assertEquals(CacheSize.UNKNOWN, CacheSize.getById("0"));
+ assertEquals(CacheSize.UNKNOWN, CacheSize.getById("9"));
+ assertEquals(CacheSize.UNKNOWN, CacheSize.getById("-1"));
+ }
}
diff --git a/tests/src/cgeo/geocaching/export/ExportTest.java b/tests/src/cgeo/geocaching/export/ExportTest.java
index 6d39f8d..b8f1ffd 100644
--- a/tests/src/cgeo/geocaching/export/ExportTest.java
+++ b/tests/src/cgeo/geocaching/export/ExportTest.java
@@ -7,6 +7,7 @@ import cgeo.geocaching.LogEntry;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.utils.FileUtils;
import java.io.File;
import java.util.ArrayList;
@@ -43,7 +44,7 @@ public class ExportTest extends CGeoTestCase {
assertNotNull(result);
- result.delete();
+ FileUtils.deleteIgnoringFailure(result);
}
private static class GpxExportTester extends GpxExport {
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
index ee42d23..6d7456c 100644
--- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
@@ -12,6 +12,7 @@ import cgeo.geocaching.test.R;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.Log;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import android.net.Uri;
@@ -50,8 +51,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
// the "real" method check
assertEquals(wptsFileName, GPXImporter.getWaypointsFileNameForGpxFile(gpx));
// they also need to be deleted, because of case sensitive tests that will not work correct on case insensitive file systems
- gpx.delete();
- wpts.delete();
+ FileUtils.deleteQuietly(gpx);
+ FileUtils.deleteQuietly(wpts);
}
final File gpx1 = new File(tempDir, "abc.gpx");
assertNull(GPXImporter.getWaypointsFileNameForGpxFile(gpx1));
@@ -260,7 +261,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
msg1.copyFrom(msg);
messages.add(msg1);
lastMessage = System.currentTimeMillis();
- notify();
+ notifyAll();
}
public synchronized void waitForCompletion(final long milliseconds, final int maxMessages) {
@@ -287,7 +288,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertTrue("java.io.tmpdir is not defined", StringUtils.isNotBlank(globalTempDir));
tempDir = new File(globalTempDir, "cgeogpxesTest");
- tempDir.mkdir();
+ cgeo.geocaching.utils.FileUtils.mkdirs(tempDir);
assertTrue("Could not create directory " + tempDir.getPath(), tempDir.exists());
// workaround to get storage initialized
DataStore.getAllHistoryCachesCount();
@@ -306,21 +307,9 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
cachesInList.addAll(search.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB));
DataStore.markDropped(cachesInList);
DataStore.removeList(listId);
- deleteDirectory(tempDir);
+ FileUtils.deleteDirectory(tempDir);
TestSettings.setStoreOfflineMaps(importCacheStaticMaps);
TestSettings.setStoreOfflineWpMaps(importWpStaticMaps);
super.tearDown();
}
-
- private static void deleteDirectory(File dir) {
- for (File f : dir.listFiles()) {
- if (f.isFile()) {
- f.delete();
- } else if (f.isDirectory()) {
- deleteDirectory(f);
- }
- }
- dir.delete();
- }
-
}
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index 9604519..dcaad22 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -12,13 +12,13 @@ import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
import cgeo.geocaching.test.R;
+import cgeo.geocaching.utils.SynchronizedDateFormat;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
@@ -28,7 +28,7 @@ import java.util.Locale;
import java.util.Set;
public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
- private static final SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); // 2010-04-20T07:00:00Z
+ private static final SynchronizedDateFormat LOG_DATE_FORMAT = new SynchronizedDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); // 2010-04-20T07:00:00Z
public void testGPXVersion100() throws Exception {
testGPXVersion(R.raw.gc1bkp3_gpx100);
diff --git a/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java b/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java
index 234af7e..78bd14d 100644
--- a/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java
+++ b/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java
@@ -19,6 +19,6 @@ public class TerrainFilterTest extends CGeoTestCase {
}
public static void testAllFilters() {
- assertTrue(new TerrainFilter.Factory().getFilters().size() == 5); // terrain ranges from 1 to 5
+ assertTrue(new TerrainFilter.Factory().getFilters().size() == 7); // terrain ranges from 1 to 7 (due to ExtremCaching.com using that value)
}
}
diff --git a/tests/src/cgeo/geocaching/settings/TestSettings.java b/tests/src/cgeo/geocaching/settings/TestSettings.java
index d63200b..2e6809f 100644
--- a/tests/src/cgeo/geocaching/settings/TestSettings.java
+++ b/tests/src/cgeo/geocaching/settings/TestSettings.java
@@ -24,8 +24,8 @@ public final class TestSettings extends Settings {
putBoolean(R.string.pref_excludemine, exclude);
}
- public static boolean setLogin(final String username, final String password) {
- return Settings.setLogin(username, password);
+ public static void setLogin(final String username, final String password) {
+ Settings.setLogin(username, password);
}
public static void setStoreOfflineMaps(final boolean offlineMaps) {
diff --git a/tests/src/cgeo/geocaching/test/CgeoTestsActivity.java b/tests/src/cgeo/geocaching/test/CgeoTestsActivity.java
index 0f41cef..c1f6fdd 100644
--- a/tests/src/cgeo/geocaching/test/CgeoTestsActivity.java
+++ b/tests/src/cgeo/geocaching/test/CgeoTestsActivity.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.test;
+import butterknife.ButterKnife;
+
import android.app.Activity;
import android.content.ComponentName;
import android.content.pm.InstrumentationInfo;
@@ -14,6 +16,7 @@ import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
@@ -76,7 +79,9 @@ public class CgeoTestsActivity extends Activity {
Thread.sleep(50);
publishProgress(mReader.readLine());
} while (System.currentTimeMillis() < timeout);
- } catch (Exception e) {
+ } catch (InterruptedException e) {
+ publishProgress("ERROR: " + e);
+ } catch (IOException e) {
publishProgress("ERROR: " + e);
} finally {
publishProgress("END");
@@ -90,8 +95,8 @@ public class CgeoTestsActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cgeo_tests_activity);
- logView = (TextView) findViewById(R.id.logOutput);
- scrollView = (BottomAwareScrollView) findViewById(R.id.scrollView);
+ logView = ButterKnife.findById(this, R.id.logOutput);
+ scrollView = ButterKnife.findById(this, R.id.scrollView);
}
@Override
@@ -114,7 +119,7 @@ public class CgeoTestsActivity extends Activity {
* referenced from XML layout
*/
public void runTests(final View v) {
- final Button button = (Button) findViewById(R.id.buttonRun);
+ final Button button = ButterKnife.findById(this, R.id.buttonRun);
button.setEnabled(false);
try {
runTestsInternally();
diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
index 1e4b527..09139f2 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
@@ -1,6 +1,6 @@
package cgeo.geocaching.test.mock;
-import cgeo.geocaching.connector.gc.Login;
+import cgeo.geocaching.connector.gc.GCLogin;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
@@ -86,7 +86,7 @@ public class GC1ZXX2 extends MockedCache {
@Override
public Date getHiddenDate() {
try {
- return Login.parseGcCustomDate("16/10/2009", getDateFormat());
+ return GCLogin.parseGcCustomDate("16/10/2009", getDateFormat());
} catch (ParseException e) {
// intentionally left blank
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
index 9ca8552..c125422 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
@@ -1,6 +1,6 @@
package cgeo.geocaching.test.mock;
-import cgeo.geocaching.connector.gc.Login;
+import cgeo.geocaching.connector.gc.GCLogin;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
@@ -121,7 +121,7 @@ public class GC2CJPF extends MockedCache {
@Override
public Date getHiddenDate() {
try {
- return Login.parseGcCustomDate("31/07/2010", getDateFormat());
+ return GCLogin.parseGcCustomDate("31/07/2010", getDateFormat());
} catch (ParseException e) {
// intentionally left blank
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
index e85c3b9..a1337cd 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.test.mock;
import cgeo.geocaching.Image;
import cgeo.geocaching.Trackable;
-import cgeo.geocaching.connector.gc.Login;
+import cgeo.geocaching.connector.gc.GCLogin;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
@@ -89,7 +89,7 @@ public class GC2JVEH extends MockedCache {
@Override
public Date getHiddenDate() {
try {
- return Login.parseGcCustomDate("28/11/2010", getDateFormat());
+ return GCLogin.parseGcCustomDate("28/11/2010", getDateFormat());
} catch (ParseException e) {
// intentionally left blank
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java
index ae3c87d..ea8079b 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java
@@ -1,6 +1,6 @@
package cgeo.geocaching.test.mock;
-import cgeo.geocaching.connector.gc.Login;
+import cgeo.geocaching.connector.gc.GCLogin;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
@@ -86,7 +86,7 @@ public class GC3XX5J extends MockedCache {
@Override
public Date getHiddenDate() {
try {
- return Login.parseGcCustomDate("2012-10-01", getDateFormat());
+ return GCLogin.parseGcCustomDate("2012-10-01", getDateFormat());
} catch (ParseException e) {
// intentionally left blank
}
@@ -133,10 +133,4 @@ public class GC3XX5J extends MockedCache {
public String getShortDescription() {
return "Kadar zbolimo nam pomaga...<br /> <br /> When we get sick, they are helpful...";
}
-
- @Override
- public String getPersonalNote() {
- return super.getPersonalNote();
- }
-
}