aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo
diff options
context:
space:
mode:
authorMarco Jacob <mjacob@union06.de>2013-03-11 02:47:32 -0700
committerMarco Jacob <mjacob@union06.de>2013-03-11 02:47:32 -0700
commit3eb51b70e1830e46009aecca0fb820217557c222 (patch)
tree2b86880ac0cbcfce3393f293ca58011c8afa5439 /tests/src/cgeo
parentb820a76ff95653ec983610e40b69f8d24570b250 (diff)
parent39a01a589e85afecd58e138e5f1fe212bc985079 (diff)
downloadcgeo-3eb51b70e1830e46009aecca0fb820217557c222.zip
cgeo-3eb51b70e1830e46009aecca0fb820217557c222.tar.gz
cgeo-3eb51b70e1830e46009aecca0fb820217557c222.tar.bz2
Merge pull request #2561 from marco-jacob/fixCgeoTests
Fix cgeo tests
Diffstat (limited to 'tests/src/cgeo')
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java6
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2CJPF.html2
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC3XX5J.html2
-rw-r--r--tests/src/cgeo/geocaching/utils/BaseUtilsTest.java10
4 files changed, 9 insertions, 11 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
index 15ad7a3..8298ad7 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
@@ -8,6 +8,10 @@ import android.text.Html;
public class GCConstantsTest extends AndroidTestCase {
+ // adapt the following after downloading new mock html files
+ public static final String MOCK_LOGIN_NAME = "JoSaMaJa";
+ public static final int MOCK_CACHES_FOUND = 419;
+
public static void testLocation() {
// GC37GFJ
assertEquals("Bretagne, France", parseLocation(" <span id=\"ctl00_ContentBody_Location\">In Bretagne, France</span><br />"));
@@ -22,7 +26,7 @@ public class GCConstantsTest extends AndroidTestCase {
public static void testCacheCount() {
assertCacheCount(1510, "<strong style=\"display:block\"> 1.510 Caches Found</strong>");
assertCacheCount(1510, "<strong style=\"display:block\"> 1,510 Caches Found</strong>");
- assertCacheCount(725, MockedCache.readCachePage("GC2CJPF")); // # of caches found by blafoo at the point of time creating the mocked data
+ assertCacheCount(MOCK_CACHES_FOUND, MockedCache.readCachePage("GC2CJPF"));
}
private static void assertCacheCount(final int count, final String html) {
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html
index 64d5f6b..6321f1d 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html
+++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html
@@ -643,7 +643,7 @@ P.S. An warmen Tagen Badesachen und Handtuch mitnehmen.</span>
Additional Hints</strong>
(<a id="ctl00_ContentBody_lnkDH" onclick="dht(this);return false;" title="Decrypt" href="#">Decrypt</a>)</p>
<div id="div_hint" class="span-8 WrapFix">
- Qnf Svany vfg hagre Fgrvara</div>
+ Das Final ist unter Steinen</div>
<div id='dk' style="display: block;" class="span-9 last">
<span id="ctl00_ContentBody_EncryptionKey" class="right"><div class="DecryptionKeyWidget"> <p class="WidgetHeader">Decryption Key</p> <p class="WidgetBody">A|B|C|D|E|F|G|H|I|J|K|L|M<br /> -------------------------<br /> N|O|P|Q|R|S|T|U|V|W|X|Y|Z</p> <p class="WidgetFooter">(letter above equals below, and vice versa)</p></div></span>
</div>
diff --git a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html
index e696625..db89925 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html
+++ b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html
@@ -614,7 +614,7 @@ PRINESI SVOJE PISALO / BRING YOUR OWN PEN<br /></span>
Additional Hints</strong>
(<a id="ctl00_ContentBody_lnkDH" onclick="dht(this);return false;" title="Decrypt" href="#">Decrypt</a>)</p>
<div id="div_hint" class="span-8 WrapFix">
- Bqznxav xnzra bo gveh / Erzbir gur fgbar jvpu yvrf orfvqr gur envy</div>
+ Odmakni kamen ob tiru / Remove the stone wich lies beside the rail</div>
<div id='dk' style="display: block;" class="span-9 last">
<span id="ctl00_ContentBody_EncryptionKey" class="right"><div class="DecryptionKeyWidget"> <p class="WidgetHeader">Decryption Key</p> <p class="WidgetBody">A|B|C|D|E|F|G|H|I|J|K|L|M<br /> -------------------------<br /> N|O|P|Q|R|S|T|U|V|W|X|Y|Z</p> <p class="WidgetFooter">(letter above equals below, and vice versa)</p></div></span>
</div>
diff --git a/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java b/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java
index 07ad7fe..78a833c 100644
--- a/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.utils;
import cgeo.geocaching.connector.gc.GCConstants;
+import cgeo.geocaching.connector.gc.GCConstantsTest;
import cgeo.geocaching.test.mock.MockedCache;
import android.test.AndroidTestCase;
@@ -10,15 +11,8 @@ import java.util.regex.Pattern;
public class BaseUtilsTest extends AndroidTestCase {
public static void testRegEx() {
final String page = MockedCache.readCachePage("GC2CJPF");
- assertEquals("blafoo", BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???"));
+ assertEquals(GCConstantsTest.MOCK_LOGIN_NAME, BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???"));
assertTrue(page.contains("id=\"ctl00_hlRenew\"") || GCConstants.MEMBER_STATUS_PM.equals(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")));
- int cachesFound = 0;
- try {
- cachesFound = Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,.]", ""));
- } catch (NumberFormatException e) {
- fail();
- }
- assertTrue(cachesFound >= 491);
}
public static void testReplaceWhitespaces() {