diff options
| -rw-r--r-- | main/src/cgeo/geocaching/settings/Settings.java | 8 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/twitter/TwitterTest.java | 48 |
2 files changed, 38 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java index ad5ca46..442df2d 100644 --- a/main/src/cgeo/geocaching/settings/Settings.java +++ b/main/src/cgeo/geocaching/settings/Settings.java @@ -928,10 +928,18 @@ public final class Settings { return getString(R.string.pref_twitter_cache_message, "I found [NAME] ([URL])."); } + public static void setCacheTwitterMessage(final String template) { + putString(R.string.pref_twitter_cache_message, template); + } + public static String getTrackableTwitterMessage() { return getString(R.string.pref_twitter_trackable_message, "I touched [NAME] ([URL])."); } + public static void setTrackableTwitterMessage(final String template) { + putString(R.string.pref_twitter_trackable_message, template); + } + public static int getLogImageScale() { return getInt(R.string.pref_logImageScale, -1); } diff --git a/tests/src/cgeo/geocaching/twitter/TwitterTest.java b/tests/src/cgeo/geocaching/twitter/TwitterTest.java index 89ac456..7ce0f09 100644 --- a/tests/src/cgeo/geocaching/twitter/TwitterTest.java +++ b/tests/src/cgeo/geocaching/twitter/TwitterTest.java @@ -2,36 +2,48 @@ package cgeo.geocaching.twitter; import cgeo.geocaching.Geocache; import cgeo.geocaching.Trackable; +import cgeo.geocaching.settings.Settings; import junit.framework.TestCase; public class TwitterTest extends TestCase { public static void testTrackableMessage() { + final String oldMessage = Settings.getTrackableTwitterMessage(); + try { + Settings.setTrackableTwitterMessage("I touched [NAME] ([URL])."); Trackable tb = new Trackable(); tb.setName("Travel bug"); tb.setGeocode("TB1234"); - assertEquals("I touched Travel bug (http://www.geocaching.com//track/details.aspx?tracker=TB1234)! #cgeo #geocaching", Twitter.getStatusMessage(tb)); + assertEquals("I touched Travel bug (http://www.geocaching.com//track/details.aspx?tracker=TB1234). #cgeo #geocaching", Twitter.getStatusMessage(tb)); + } finally { + Settings.setTrackableTwitterMessage(oldMessage); + } } public static void testCacheMessage() { - Geocache cache = new Geocache(); - cache.setGeocode("GC1234"); - cache.setName("TwitterTest"); - assertEquals("I found TwitterTest (http://coord.info/GC1234) #cgeo #geocaching", Twitter.getStatusMessage(cache)); + final String oldMessage = Settings.getCacheTwitterMessage(); + try { + Settings.setCacheTwitterMessage("I found [NAME] ([URL])."); + Geocache cache = new Geocache(); + cache.setGeocode("GC1234"); + cache.setName("TwitterTest"); + assertEquals("I found TwitterTest (http://coord.info/GC1234). #cgeo #geocaching", Twitter.getStatusMessage(cache)); + } finally { + Settings.setCacheTwitterMessage(oldMessage); + } } - // TODO: re-enable when settings are ready - // public static void testAvoidDuplicateTags() { - // String oldMessage = Settings.getCacheTwitterMessage(); - // try { - // Geocache cache = new Geocache(); - // cache.setGeocode("GC1234"); - // cache.setName("TwitterTest"); - // Settings.setCacheTwitterMessage("[NAME] #cgeo"); - // assertEquals("TwitterTest #cgeo #geocaching", Twitter.getStatusMessage(cache)); - // } finally { - // Settings.setCacheTwitterMessage(oldMessage); - // } - // } + public static void testAvoidDuplicateTags() { + final String oldMessage = Settings.getCacheTwitterMessage(); + try { + Settings.setCacheTwitterMessage("[NAME] #cgeo"); + Geocache cache = new Geocache(); + cache.setGeocode("GC1234"); + cache.setName("TwitterTest"); + assertEquals("TwitterTest #cgeo #geocaching", Twitter.getStatusMessage(cache)); + } finally { + Settings.setCacheTwitterMessage(oldMessage); + } + } } |
