aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo
diff options
context:
space:
mode:
authorMarco Jacob <mjacob@union06.de>2013-06-15 16:23:55 +0200
committerMarco Jacob <mjacob@union06.de>2013-06-26 18:08:20 +0200
commitfbc75936daaa3ea5e2596c0aa71593cbe9f33614 (patch)
tree682973d51b4c1e1578e02ae8e690c88dbc74aeb1 /tests/src/cgeo
parent3d41a7c9b48fea09d6cc74cd96fa1a13b777eeb2 (diff)
downloadcgeo-fbc75936daaa3ea5e2596c0aa71593cbe9f33614.zip
cgeo-fbc75936daaa3ea5e2596c0aa71593cbe9f33614.tar.gz
cgeo-fbc75936daaa3ea5e2596c0aa71593cbe9f33614.tar.bz2
make personalNote multiline again, upload button, merge on refresh
Diffstat (limited to 'tests/src/cgeo')
-rw-r--r--tests/src/cgeo/geocaching/PersonalNoteTest.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/PersonalNoteTest.java b/tests/src/cgeo/geocaching/PersonalNoteTest.java
new file mode 100644
index 0000000..fd185ed
--- /dev/null
+++ b/tests/src/cgeo/geocaching/PersonalNoteTest.java
@@ -0,0 +1,68 @@
+package cgeo.geocaching;
+
+import junit.framework.TestCase;
+
+public class PersonalNoteTest extends TestCase {
+
+ public static void testParse() {
+ final String testString = "merged:\nSimple cgeo note\n--\nSimple provider note";
+ Geocache cache = new Geocache();
+ cache.setPersonalNote(testString);
+ PersonalNote parsedNote = new PersonalNote(cache);
+ assertEquals(testString, parsedNote.toString());
+ assertPersonalNote(parsedNote, "Simple cgeo note", "Simple provider note");
+
+ }
+
+ public static void testParseProviderOnly() {
+ final String testString = "Simple provider note";
+ Geocache cache = new Geocache();
+ cache.setPersonalNote(testString);
+ PersonalNote parsedNote = new PersonalNote(cache);
+ assertEquals(testString, parsedNote.toString());
+ assertPersonalNote(parsedNote, null, "Simple provider note");
+ }
+
+ public static void testParseCgeoOnly() {
+ final String testString = "merged:\nSimple cgeo note";
+ Geocache cache = new Geocache();
+ cache.setPersonalNote(testString);
+ PersonalNote parsedNote = new PersonalNote(cache);
+ assertEquals("Simple cgeo note", parsedNote.toString());
+ assertPersonalNote(parsedNote, null, "Simple cgeo note");
+ }
+
+ public static void testSimpleMerge() {
+ Geocache cache1 = new Geocache(); // not stored
+ cache1.setPersonalNote("merged:\nSimple cgeo note\n--\nSimple provider note");
+ PersonalNote myNote = new PersonalNote(cache1);
+ Geocache cache2 = new Geocache();
+ cache2.setListId(StoredList.STANDARD_LIST_ID); // stored
+ cache2.setPersonalNote("merged:\ncgeo note\n--\nProvider note");
+ PersonalNote otherNote = new PersonalNote(cache2);
+ PersonalNote result = myNote.mergeWith(otherNote);
+ assertEquals("merged:\ncgeo note\n--\nSimple provider note", result.toString());
+ assertPersonalNote(result, "cgeo note", "Simple provider note");
+ }
+
+ public static void testMixedMerge() {
+ Geocache cache1 = new Geocache(); // not stored
+ cache1.setPersonalNote("merged:\nSimple cgeo note\n--\nSimple provider note");
+ PersonalNote myNote = new PersonalNote(cache1);
+ Geocache cache2 = new Geocache();
+ cache2.setListId(StoredList.STANDARD_LIST_ID); // stored
+ cache2.setPersonalNote("Provider note");
+ PersonalNote otherNote = new PersonalNote(cache2);
+ PersonalNote result = myNote.mergeWith(otherNote);
+ assertEquals("merged:\nSimple cgeo note\n--\nSimple provider note", result.toString());
+ assertPersonalNote(result, "Simple cgeo note", "Simple provider note");
+ result = otherNote.mergeWith(myNote);
+ assertEquals("merged:\nSimple cgeo note\n--\nProvider note", result.toString());
+ assertPersonalNote(result, "Simple cgeo note", "Provider note");
+ }
+
+ private static void assertPersonalNote(final PersonalNote note, final String cgeoNote, final String providerNote) {
+ assertEquals(cgeoNote, note.getCgeoNote());
+ assertEquals(providerNote, note.getProviderNote());
+ }
+}