aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--tests/.settings/org.eclipse.jdt.ui.prefs7
-rw-r--r--tests/AndroidManifest.xml2
-rw-r--r--tests/ant.properties2
-rw-r--r--tests/libs/espresso-1.1-bundled.jarbin0 -> 2804014 bytes
-rw-r--r--tests/res/raw/gcvote.xml13
-rw-r--r--tests/res/raw/giga_lab_caches.gpx221
-rw-r--r--tests/src/cgeo/geocaching/CgeoApplicationTest.java6
-rw-r--r--tests/src/cgeo/geocaching/GeocacheTest.java2
-rw-r--r--tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java30
-rw-r--r--tests/src/cgeo/geocaching/activity/logtrackable/AbstractLogTrackableActivityTest.java31
-rw-r--r--tests/src/cgeo/geocaching/activity/logtrackable/LogTrackableActivityTest.java26
-rw-r--r--tests/src/cgeo/geocaching/activity/waypoint/AbstractAddWaypointActivityTest.java12
-rw-r--r--tests/src/cgeo/geocaching/activity/waypoint/AbstractEditWaypointActivityTest.java28
-rw-r--r--tests/src/cgeo/geocaching/activity/waypoint/AbstractWaypointActivityTest.java52
-rw-r--r--tests/src/cgeo/geocaching/activity/waypoint/AddWaypointActivityTest.java62
-rw-r--r--tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMultiTest.java34
-rw-r--r--tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMysteryTest.java32
-rw-r--r--tests/src/cgeo/geocaching/activity/waypoint/EditWaypointActivityTest.java29
-rw-r--r--tests/src/cgeo/geocaching/export/GpxSerializerTest.java2
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java39
-rw-r--r--tests/src/cgeo/geocaching/gcvote/GCVoteTest.java47
-rw-r--r--tests/src/cgeo/geocaching/geopoint/UnitsTest.java6
-rw-r--r--tests/src/cgeo/geocaching/sensors/SensorsTest.java3
-rw-r--r--tests/src/cgeo/geocaching/settings/TestSettings.java2
-rw-r--r--tests/src/cgeo/geocaching/speech/TextFactoryTest.java2
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java4
-rw-r--r--tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java5
-rw-r--r--tests/src/cgeo/geocaching/utils/TextUtilsTest.java7
-rw-r--r--tests/src/cgeo/junit/CgeoTestRunner.java120
-rw-r--r--tests/tests.iml1
31 files changed, 817 insertions, 22 deletions
diff --git a/tests/.settings/org.eclipse.jdt.core.prefs b/tests/.settings/org.eclipse.jdt.core.prefs
index e9dd68c..3d2d78c 100644
--- a/tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/.settings/org.eclipse.jdt.core.prefs
@@ -115,12 +115,14 @@ org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=0
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
@@ -140,6 +142,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
@@ -185,6 +188,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
@@ -232,6 +236,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=inser
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
@@ -250,12 +255,14 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invoca
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
@@ -279,6 +286,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invoc
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
@@ -306,6 +314,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do n
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
@@ -334,6 +343,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invoc
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
@@ -343,6 +353,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=inser
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
@@ -369,4 +380,5 @@ org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/tests/.settings/org.eclipse.jdt.ui.prefs b/tests/.settings/org.eclipse.jdt.ui.prefs
index 7616a5b..1fda530 100644
--- a/tests/.settings/org.eclipse.jdt.ui.prefs
+++ b/tests/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,3 @@
-#Wed Sep 14 20:41:07 CEST 2011
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_cgeo
@@ -20,10 +19,12 @@ sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.insert_inferred_type_arguments=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=false
@@ -39,6 +40,7 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=false
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
@@ -52,10 +54,13 @@ sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_type_arguments=false
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 690838c..814b6de 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -13,7 +13,7 @@
android:required="false" />
<instrumentation
- android:name="com.zutubi.android.junitreport.JUnitReportTestRunner"
+ android:name="cgeo.junit.CgeoTestRunner"
android:targetPackage="cgeo.geocaching" />
<application
diff --git a/tests/ant.properties b/tests/ant.properties
index 84cba61..11b92ba 100644
--- a/tests/ant.properties
+++ b/tests/ant.properties
@@ -18,4 +18,4 @@
tested.project.dir=../main
# Use a test runner which can create JUnit compliant XML reports
-test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner
+test.runner=cgeo.junit.CgeoTestRunner
diff --git a/tests/libs/espresso-1.1-bundled.jar b/tests/libs/espresso-1.1-bundled.jar
new file mode 100644
index 0000000..3a1712a
--- /dev/null
+++ b/tests/libs/espresso-1.1-bundled.jar
Binary files differ
diff --git a/tests/res/raw/gcvote.xml b/tests/res/raw/gcvote.xml
new file mode 100644
index 0000000..c58100a
--- /dev/null
+++ b/tests/res/raw/gcvote.xml
@@ -0,0 +1,13 @@
+<votes userName='' currentVersion='3.2' securityState='locked' loggedIn='false'>
+<vote userName='' cacheId='120f6a89-94db-4897-9813-4d79d59ffb09' voteMedian='2.5' voteAvg='2.9' voteCnt='5' voteUser='0' waypoint='GC3MVFN' vote1='0' vote2='3' vote3='1' vote4='1' vote5='0' rawVotes='(2.5:3)(3.0:1)(4.0:1)'/>
+<vote userName='' cacheId='3683c154-4a2a-45cd-a20e-ae503ee8975c' voteMedian='2.5' voteAvg='2.75' voteCnt='6' voteUser='0' waypoint='GC3JCQG' vote1='0' vote2='4' vote3='1' vote4='1' vote5='0' rawVotes='(2.0:1)(2.5:3)(3.0:1)(4.0:1)'/>
+<vote userName='' cacheId='411fa2e5-7f03-458e-a2e0-f3eda8fd7140' voteMedian='4' voteAvg='4' voteCnt='1' voteUser='0' waypoint='GC2X3X2' vote1='0' vote2='0' vote3='0' vote4='1' vote5='0' rawVotes='(4.0:1)'/>
+<vote userName='' cacheId='44f9a8c1-97ac-451a-9269-4b7dc1322db5' voteMedian='3' voteAvg='3.3333333333333' voteCnt='3' voteUser='0' waypoint='GC30X77' vote1='0' vote2='0' vote3='2' vote4='1' vote5='0' rawVotes='(3.0:2)(4.0:1)'/>
+<vote userName='' cacheId='5520c33b-3941-45ca-9056-ea655dbaadf7' voteMedian='3.75' voteAvg='3.75' voteCnt='2' voteUser='0' waypoint='GC1WEVZ' vote1='0' vote2='0' vote3='1' vote4='1' vote5='0' rawVotes='(3.5:1)(4.0:1)'/>
+<vote userName='' cacheId='5be5cbe3-9094-4a48-b534-dbc52b337315' voteMedian='3.5' voteAvg='3.5' voteCnt='2' voteUser='0' waypoint='GC3JCY7' vote1='0' vote2='0' vote3='1' vote4='1' vote5='0' rawVotes='(3.0:1)(4.0:1)'/>
+<vote userName='' cacheId='735334dd-e284-4a7b-bc78-f3534f52a46d' voteMedian='2.5' voteAvg='2.6666666666667' voteCnt='3' voteUser='0' waypoint='GC3QD6N' vote1='0' vote2='2' vote3='1' vote4='0' vote5='0' rawVotes='(2.5:2)(3.0:1)'/>
+<vote userName='' cacheId='92a611f9-9ff3-41ac-ae4e-d2927c86e836' voteMedian='3.25' voteAvg='3.5625' voteCnt='8' voteUser='0' waypoint='GCKF13' vote1='0' vote2='0' vote3='5' vote4='2' vote5='1' rawVotes='(3.0:4)(3.5:1)(4.0:2)(5.0:1)'/>
+<vote userName='' cacheId='a02894bb-4a08-4c09-a73c-25939894ba15' voteMedian='3' voteAvg='3.1666666666667' voteCnt='9' voteUser='0' waypoint='GC2R3X3' vote1='0' vote2='2' vote3='5' vote4='2' vote5='0' rawVotes='(2.0:1)(2.5:1)(3.0:3)(3.5:2)(4.0:2)'/>
+<vote userName='' cacheId='a1711706-09c4-44de-bda8-36df7e53d57c' voteMedian='3.5' voteAvg='3.5' voteCnt='4' voteUser='0' waypoint='GC3MVN6' vote1='0' vote2='0' vote3='2' vote4='2' vote5='0' rawVotes='(3.0:2)(4.0:2)'/>
+<errorstring></errorstring>
+</votes>
diff --git a/tests/res/raw/giga_lab_caches.gpx b/tests/res/raw/giga_lab_caches.gpx
new file mode 100644
index 0000000..a18224e
--- /dev/null
+++ b/tests/res/raw/giga_lab_caches.gpx
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0/1 http://www.groundspeak.com/cache/1/0/1/cache.xsd" version="1.0" creator="Groundspeak, Inc. All Rights Reserved. http://www.groundspeak.com" xmlns="http://www.topografix.com/GPX/1/0">
+ <name>Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>This is a cache list generated from Labs.Geocaching.com specifically for Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <author>Groundspeak</author>
+ <time>2014-09-06T04:40:43.0556858Z</time>
+ <keywords>lab cache, cache, geocache, groundspeak</keywords>
+ <wpt lat="48.173617" lon="11.553767">
+ <name>01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>01_Munich Olympic Walk Of Stars_Updated (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635824454" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">01_Munich Olympic Walk Of Stars_Updated (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Ein Paar schrge Vgel: Seit 2003 haben sich Berhmtheiten aus Sport, Musik und Unterhaltung mit ihren Hnden im Munich Walk of Stars verewigt. Hier findet man Knstler vereint, die ansonsten an entgegengesetzten Enden des musikalischen Spektrums anzusiedeln sind.
+Frage: Wie lautet der Vorname des Musikers CAT STEVANS, der in unmittelbarer Nhe der schrgen Vgel seine Hnde in den Beton gedrckt hat?
+
+ENG:
+Crazy birds: Since 2003 celebrities from the worlds of sport, music and entertainment have been leaving their marks at the Munich Walk of Stars. Amongst others, artists who one would normally place on opposite ends of the musical spectrum are placed in close neighbourhood.
+Question: What is the first name of the musician CAT STEVANS located directly next to the crazy birds (DEU: Spatzen = ENG: Sparrows)?
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.177983" lon="11.555683">
+ <name>02_BMW-Welt-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>02_BMW-Welt (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635824453" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>02_BMW-Welt-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">02_BMW-Welt (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Doppelkegel &amp; Dachwolke: Seit der Erffnung des Gebudes 2007 hat dessen Architektur diverse Preise gewonnen. Einige Urkunden sind im Eingangsbereich zu besichtigen. Nur eine davon stammt aus dem Jahr 2009.
+Frage: Wie lautet das erste Wort auf der Urkunde (ohne "*" Sternchen)?
+
+ENG:
+Double Cone &amp; Flying Cloud: Since the opening of this building in 2007 its architecture has won several awards. Some of those certificates are on display in the entrance area. Only one of them dates from 2009.
+Question: What is the first word on the certificate (without "*" asterisk)?
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.178867" lon="11.553133">
+ <name>03_Olympisches Dorf-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>03_Olympisches Dorf (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635824452" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>03_Olympisches Dorf-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">03_Olympisches Dorf (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Malen nach Zahlen: Die ehemaligen Wohnungen der Sportler der Olympischen Spiele 1972 werden nun von Studenten bewohnt. Manche haben ihren Bungalow aufwndig bemalt. Ein Gemlde ziert die Rckwand zweier Wohnungen. Auf diesem Gemlde sind beinahe alle Mnchner Sehenswrdigkeiten verewigt.
+Frage: Multipliziere die Ziffern der beiden Hausnummern.
+
+ENG:
+Painting by Numbers: The former athletes' apartments of the Olympic Games 1972 are now being lived in by students. Some of them took great lengths to paint their bungalows. One painting decorates the back wall of two apartments and shows nearly all the main attractions in Munich.
+Question: Multiply the two street numbers of the apartments.
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.179817" lon="11.549333">
+ <name>04_Connollystrasse-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>04_Connollystrasse (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635824451" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>04_Connollystrasse-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">04_Connollystrasse (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Gedenksttte: Am 5. September 1972 nahmen Mitglieder einer palstinensischen Terrororganisation elf israelische Sportler als Geiseln. Bei der Befreiungsaktion kamen alle elf Athleten ums Leben. Eine Gedenktafel erinnert an der Connollystrae 31 an sie.
+Frage: Wie lautet das letzte Wort auf der Gedenktafel im lateinischen Alphabet?
+
+ENG:
+Memorial Site: On September 5th 1972, members of a Palestinian terror organisation took eleven Israeli athletes as hostages. During the attempted rescue all of the eleven athletes lost their lives. They are being remembered at a memorial at Connollystrae 31.
+Question: What is the last word of the memorial in Roman alphabet?
+
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.170083" lon="11.545583">
+ <name>05_Nationenbaum-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>05_Nationenbaum (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635824450" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>05_Nationenbaum-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">05_Nationenbaum (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Typisch Belgisch: Einige der 1972 an den Olympischen Spielen teilnehmenden Nationen haben in diesem Areal Bume gepflanzt. Die von sterreich und San Marino gestifteten Bume sind von der gleichen Art.
+Frage: Wie lautet das Wort, das im lateinischen Namen doppelt vorkommt?
+
+ENG:
+Typically Belgian: Some of the participating countries in the 1972 Olympic Games planted trees in this area. The trees donated by Austria and San Marino are of the same species.
+Question: Name the word occurring twice in the Latin name.
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.173283" lon="11.5506">
+ <name>06_Theatron-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>06_Theatron (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635668281" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>06_Theatron-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">06_Theatron (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Seebhne: Auf einer kleinen Halbinsel im Olympiasee befindet sich eine Seebhne, umgeben von den Steinstufen des viertelrunden Theatron. Schaue von der Tribne aus in Richtung Olympiaturm.
+Frage: Schaue von der Tribne aus in Richtung Olympiaturm. Wie viele Schwimmer siehst Du?
+
+
+ENG:
+Lake Placid: Situated on a small peninsula of the Olympic Lake is a small stage, surrounded by the stone steps of the Theatron.Take a look from the stands in the direction of the Olympic Tower.
+Question: How many swimmers do you see?
+
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.16985" lon="11.55155">
+ <name>07_Olympiaberg-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>07_Olympiaberg (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635668280" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>07_Olympiaberg-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">07_Olympiaberg (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Mnchner Alpen: Der Olympiaberg entstand zwischen 1947 und 1958 aus Trmmern des Zweiten Weltkrieges. Vom Gipfel aus siehst Du die weltberhmte Architektur des Olympiastadions, der Olympiahalle und der Olympiaschwimmhalle.
+Frage: Wie viele "Zeltstangen" ragen mit ihren Kpfen ber den Horizont?
+
+ENG:
+Munich Alps: The Olympiaberg was piled up between 1947 and 1958 from rubble left after World War II. From the summit you get a great view of the world renowned architecture of the Olympic Stadium, the Olympic Hall and the Olympic Swimming Pool.
+Question: How many "tent poles" raise their heads above the horizon?
+
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.1702" lon="11.546217">
+ <name>08_Engelbaum-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>08_Engelbaum (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635668279" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>08_Engelbaum-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">08_Engelbaum (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Pltzlich war er da - der Spender dieser Figur bleibt auch Jahre nach der Installation unbekannt. Der Engel im Baum trgt ein Instrument im Arm. Gesucht ist der englische Name des Instruments.
+Frage: Welches Instrument trgt der Engel (engl.)?
+
+ENG:
+An angel in a tree - no one knows when or who placed this religious figure here. Have a look at it - and name the instrument which is laying in the angel arms.
+Question: The angel holds an instrument. Name it.
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.1744" lon="11.551917">
+ <name>09_Gruselkabinett-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>09_Gruselkabinett (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635668278" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>09_Gruselkabinett-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">09_Gruselkabinett (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Ein Knstler zeigt hier erstaunliche Einblicke in den menschlichen Krper. Mit einer als Plastinat bekannten Methode zeigt er, wie der menschliche Krper ohne Haut aussieht. Sehenswert und kurios. Wenn Du die Zeit hast, dann unbedingt mitnehmen.
+Frage: Vorname des Plastinators, der hier eine Ausstellung macht.
+
+ENG:
+An artist of plastination presents his work here. A view inside the human body in an extreme stylish way. Please have a look at the exhibition. It is special!
+Question: First name of the initiator of the exhibition.
+-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+ <wpt lat="48.17085" lon="11.556083">
+ <name>10_Schuttblume-Project MUNICH2014 - Mia san Giga! Olympiapark</name>
+ <desc>10_Schuttblume (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</desc>
+ <sym>Geocache</sym>
+ <groundspeak:cache id="-635668277" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
+ <groundspeak:name>10_Schuttblume-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:name>
+ <groundspeak:owner id="0" />
+ <groundspeak:type>Geocache|Lab Cache</groundspeak:type>
+ <groundspeak:difficulty>0</groundspeak:difficulty>
+ <groundspeak:terrain>0</groundspeak:terrain>
+ <groundspeak:short_description html="false">10_Schuttblume (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark</groundspeak:short_description>
+ <groundspeak:long_description html="false">DEU:
+Die Schuttblume ist ein den zivilen Luftkriegsopfern des Zweiten Weltkrieges gewidmetes Mahnmal auf dem Olympiaberg, das zu den Olympischen Spielen 1972 vom Deutschen Gewerkschaftsbund und der Landeshauptstadt Mnchen gestiftet wurde
+Frage: Gedenktafel am Boden - letztes Wort ist gesucht
+
+ENG:
+The Schuttblume (engl.Flower made of rubble) is a memorial side. It is dedicated to all the victims of the Second World War air war. It was donated 1972 during the Olympics.
+Question: plaque on the ground - last word is...-DEU: LAB Caches zum Project MUNICH2014 - Mia san Giga! Olympia Stadion</groundspeak:long_description>
+ </groundspeak:cache>
+ </wpt>
+</gpx> \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
index de3f4ba..5344742 100644
--- a/tests/src/cgeo/geocaching/CgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
@@ -165,7 +165,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
deleteCacheFromDBAndLogout(cache.getGeocode());
- SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null);
+ SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST.id, true, null);
assertThat(search).isNotNull();
assertThat(search.getGeocodes()).hasSize(1);
assertThat(search.getGeocodes().contains(cache.getGeocode())).isTrue();
@@ -180,7 +180,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
deleteCacheFromDBAndLogout(cache.getGeocode());
- search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null);
+ search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST.id, true, null);
assertThat(search).isNotNull();
assertThat(search.getGeocodes()).isEmpty();
}
@@ -201,7 +201,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
deleteCacheFromDBAndLogout(cache.getGeocode());
- final SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null);
+ final SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST.id, true, null);
assertThat(search).isNotNull();
assertThat(search.getGeocodes()).isEmpty();
}
diff --git a/tests/src/cgeo/geocaching/GeocacheTest.java b/tests/src/cgeo/geocaching/GeocacheTest.java
index b3ec6be..722e1cf 100644
--- a/tests/src/cgeo/geocaching/GeocacheTest.java
+++ b/tests/src/cgeo/geocaching/GeocacheTest.java
@@ -86,7 +86,7 @@ public class GeocacheTest extends CGeoTestCase {
assertThat(waypoint.getCoords()).isEqualTo(new Geopoint("N51 13.888 E007 03.444"));
// assertThat(waypoint.getNote()).isEqualTo("Test");
assertThat(waypoint.getName()).isEqualTo(CgeoApplication.getInstance().getString(R.string.cache_personal_note) + " 1");
- cache.store(StoredList.TEMPORARY_LIST_ID, null);
+ cache.store(StoredList.TEMPORARY_LIST.id, null);
}
removeCacheCompletely(geocode);
} finally {
diff --git a/tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java b/tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java
new file mode 100644
index 0000000..0647ec8
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java
@@ -0,0 +1,30 @@
+package cgeo.geocaching.activity;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onData;
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
+import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
+import static org.hamcrest.Matchers.hasToString;
+import static org.hamcrest.Matchers.startsWith;
+
+import android.app.Activity;
+import android.test.ActivityInstrumentationTestCase2;
+
+public abstract class AbstractEspressoTest<T extends Activity> extends ActivityInstrumentationTestCase2<T> {
+
+ public AbstractEspressoTest(Class<T> activityClass) {
+ super(activityClass);
+ }
+
+ protected final void clickActionBarItem(int labelResourceId) {
+ onData(hasToString(startsWith(getString(labelResourceId)))).perform(click());
+ }
+
+ protected final void openActionBar() {
+ openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
+ }
+
+ protected final String getString(int resId) {
+ return getActivity().getString(resId);
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/activity/logtrackable/AbstractLogTrackableActivityTest.java b/tests/src/cgeo/geocaching/activity/logtrackable/AbstractLogTrackableActivityTest.java
new file mode 100644
index 0000000..d93f1ad
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/logtrackable/AbstractLogTrackableActivityTest.java
@@ -0,0 +1,31 @@
+package cgeo.geocaching.activity.logtrackable;
+
+import cgeo.geocaching.DataStore;
+import cgeo.geocaching.LogTrackableActivity;
+import cgeo.geocaching.Trackable;
+import cgeo.geocaching.activity.AbstractEspressoTest;
+
+public abstract class AbstractLogTrackableActivityTest extends AbstractEspressoTest<LogTrackableActivity> {
+
+ private static Trackable trackable;
+
+ public AbstractLogTrackableActivityTest() {
+ super(LogTrackableActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ createTrackable();
+ setActivityIntent(LogTrackableActivity.getIntent(getInstrumentation().getContext(), trackable));
+ getActivity();
+ }
+
+ protected static void createTrackable() {
+ trackable = new Trackable();
+ trackable.setName("Test trackable");
+ trackable.setGeocode("TB4D09K");
+ DataStore.saveTrackable(trackable);
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/activity/logtrackable/LogTrackableActivityTest.java b/tests/src/cgeo/geocaching/activity/logtrackable/LogTrackableActivityTest.java
new file mode 100644
index 0000000..cb2a209
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/logtrackable/LogTrackableActivityTest.java
@@ -0,0 +1,26 @@
+package cgeo.geocaching.activity.logtrackable;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.doesNotExist;
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+import cgeo.geocaching.R;
+
+public class LogTrackableActivityTest extends AbstractLogTrackableActivityTest {
+
+ public void testInsertNameExists() throws Exception {
+ openActionBar();
+ clickActionBarItem(R.string.log_add);
+
+ onView(withText(getString(R.string.init_signature_template_name))).check(matches(isDisplayed()));
+ }
+
+ public void testInsertNumberNotExists() throws Exception {
+ openActionBar();
+ clickActionBarItem(R.string.log_add);
+
+ onView(withText(getString(R.string.init_signature_template_number))).check(doesNotExist());
+ }
+}
diff --git a/tests/src/cgeo/geocaching/activity/waypoint/AbstractAddWaypointActivityTest.java b/tests/src/cgeo/geocaching/activity/waypoint/AbstractAddWaypointActivityTest.java
new file mode 100644
index 0000000..7be6150
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/waypoint/AbstractAddWaypointActivityTest.java
@@ -0,0 +1,12 @@
+package cgeo.geocaching.activity.waypoint;
+
+import cgeo.geocaching.EditWaypointActivity_;
+
+public abstract class AbstractAddWaypointActivityTest extends AbstractWaypointActivityTest {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ setActivityIntent(new EditWaypointActivity_.IntentBuilder_(getInstrumentation().getContext()).geocode(getCache().getGeocode()).get());
+ getActivity();
+ }
+}
diff --git a/tests/src/cgeo/geocaching/activity/waypoint/AbstractEditWaypointActivityTest.java b/tests/src/cgeo/geocaching/activity/waypoint/AbstractEditWaypointActivityTest.java
new file mode 100644
index 0000000..bf8224a
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/waypoint/AbstractEditWaypointActivityTest.java
@@ -0,0 +1,28 @@
+package cgeo.geocaching.activity.waypoint;
+
+import cgeo.geocaching.EditWaypointActivity_;
+import cgeo.geocaching.Waypoint;
+import cgeo.geocaching.enumerations.WaypointType;
+
+public abstract class AbstractEditWaypointActivityTest extends AbstractWaypointActivityTest {
+ private Waypoint waypoint;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ createWaypoint();
+ getCache().addOrChangeWaypoint(waypoint, true);
+ final int waypointId = getCache().getWaypoints().get(0).getId();
+ setActivityIntent(new EditWaypointActivity_.IntentBuilder_(getInstrumentation().getContext()).geocode(getCache().getGeocode()).waypointId(waypointId).get());
+ getActivity();
+ }
+
+ private void createWaypoint() {
+ waypoint = new Waypoint("Test waypoint", WaypointType.PUZZLE, true);
+ waypoint.setNote("Test note");
+ }
+
+ protected final Waypoint getWaypoint() {
+ return waypoint;
+ }
+}
diff --git a/tests/src/cgeo/geocaching/activity/waypoint/AbstractWaypointActivityTest.java b/tests/src/cgeo/geocaching/activity/waypoint/AbstractWaypointActivityTest.java
new file mode 100644
index 0000000..36c4302
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/waypoint/AbstractWaypointActivityTest.java
@@ -0,0 +1,52 @@
+package cgeo.geocaching.activity.waypoint;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import cgeo.geocaching.DataStore;
+import cgeo.geocaching.EditWaypointActivity_;
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.activity.AbstractEspressoTest;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LoadFlags;
+import cgeo.geocaching.enumerations.LoadFlags.SaveFlag;
+
+import java.util.Collections;
+
+public abstract class AbstractWaypointActivityTest extends AbstractEspressoTest<EditWaypointActivity_> {
+
+ private Geocache cache;
+
+ public AbstractWaypointActivityTest() {
+ super(EditWaypointActivity_.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ cache = createTestCache();
+ DataStore.saveCache(cache, Collections.singleton(SaveFlag.CACHE));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ removeTestCache();
+ super.tearDown();
+ }
+
+ protected final Geocache getCache() {
+ return cache;
+ }
+
+ private void removeTestCache() {
+ DataStore.removeCache(cache.getGeocode(), LoadFlags.REMOVE_ALL);
+ assertThat(DataStore.loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB)).isNull();
+ }
+
+ @SuppressWarnings("static-method")
+ protected Geocache createTestCache() {
+ Geocache testCache = new Geocache();
+ testCache.setGeocode("TEST");
+ testCache.setType(CacheType.TRADITIONAL);
+ return testCache;
+ }
+}
diff --git a/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointActivityTest.java b/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointActivityTest.java
new file mode 100644
index 0000000..853054a
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointActivityTest.java
@@ -0,0 +1,62 @@
+package cgeo.geocaching.activity.waypoint;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import com.google.android.apps.common.testing.ui.espresso.action.ViewActions;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onData;
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isClickable;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isNotChecked;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
+
+import static org.hamcrest.Matchers.hasToString;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.startsWith;
+
+public class AddWaypointActivityTest extends AbstractAddWaypointActivityTest {
+
+ public static void testAddWayPointHasTypeSelection() {
+ onView(withId(R.id.type)).check(matches(isDisplayed()));
+ }
+
+ public static void testDefaultWaypointTypeForTraditional() {
+ onView(withId(R.id.type)).check(matches(withChild(withText(WaypointType.WAYPOINT.getL10n()))));
+ onView(withId(R.id.name)).check(matches(withText(WaypointType.WAYPOINT.getL10n() + " 1")));
+ }
+
+ public static void testFieldsAreEmpty() {
+ onView(withId(R.id.note)).check(matches(withText("")));
+ onView(withId(R.id.bearing)).check(matches(withText("")));
+ onView(withId(R.id.distance)).check(matches(withText("")));
+ }
+
+ public static void testNewWaypointNotVisited() {
+ onView(withId(R.id.wpt_visited_checkbox)).check(matches(isNotChecked()));
+ }
+
+ public static void testSwitchingWaypointTypeChangesWaypointName() {
+ WaypointType waypointType = WaypointType.FINAL;
+
+ // verify we don't have a final type yet
+ onView(withId(R.id.name)).check(matches(not(withText(waypointType.getL10n()))));
+
+ // open type selector
+ onView(withId(R.id.type)).perform(ViewActions.click());
+
+ // select final type
+ onData(hasToString(startsWith(waypointType.getL10n()))).inAdapterView(isClickable()).perform(click());
+
+ // verify changed name
+ onView(withId(R.id.name)).check(matches(withText(waypointType.getL10n())));
+ }
+}
diff --git a/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMultiTest.java b/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMultiTest.java
new file mode 100644
index 0000000..c66c8de
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMultiTest.java
@@ -0,0 +1,34 @@
+package cgeo.geocaching.activity.waypoint;
+
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.R;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import com.google.android.apps.common.testing.ui.espresso.ViewInteraction;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+public class AddWaypointMultiTest extends AbstractAddWaypointActivityTest {
+
+ @Override
+ protected Geocache createTestCache() {
+ final Geocache cache = super.createTestCache();
+ cache.setType(CacheType.MULTI);
+ return cache;
+ }
+
+ public static void testMysteryDefaultWaypointFinal() {
+ final ViewInteraction waypointTypeSelector = onView(withId(R.id.type));
+ waypointTypeSelector.check(matches(isDisplayed()));
+ waypointTypeSelector.check(matches(withChild(withText(WaypointType.STAGE.getL10n()))));
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMysteryTest.java b/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMysteryTest.java
new file mode 100644
index 0000000..810aa25
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/waypoint/AddWaypointMysteryTest.java
@@ -0,0 +1,32 @@
+package cgeo.geocaching.activity.waypoint;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.R;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import com.google.android.apps.common.testing.ui.espresso.ViewInteraction;
+
+public class AddWaypointMysteryTest extends AbstractAddWaypointActivityTest {
+
+ @Override
+ protected Geocache createTestCache() {
+ final Geocache cache = super.createTestCache();
+ cache.setType(CacheType.MYSTERY);
+ return cache;
+ }
+
+ public static void testMysteryDefaultWaypointFinal() {
+ final ViewInteraction waypointTypeSelector = onView(withId(R.id.type));
+ waypointTypeSelector.check(matches(isDisplayed()));
+ waypointTypeSelector.check(matches(withChild(withText(WaypointType.FINAL.getL10n()))));
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/activity/waypoint/EditWaypointActivityTest.java b/tests/src/cgeo/geocaching/activity/waypoint/EditWaypointActivityTest.java
new file mode 100644
index 0000000..d419555
--- /dev/null
+++ b/tests/src/cgeo/geocaching/activity/waypoint/EditWaypointActivityTest.java
@@ -0,0 +1,29 @@
+package cgeo.geocaching.activity.waypoint;
+
+import cgeo.geocaching.R;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class EditWaypointActivityTest extends AbstractEditWaypointActivityTest {
+
+ public void testFieldsAreNotEmpty() {
+ String name = getWaypoint().getName();
+ assertThat(name).isNotEmpty();
+ onView(withId(R.id.name)).check(matches(withText(name)));
+
+ final String note = getWaypoint().getNote();
+ assertThat(note).isNotEmpty();
+ onView(withId(R.id.note)).check(matches(withText(note)));
+
+ onView(withId(R.id.type)).check(matches(withChild(withText(getWaypoint().getWaypointType().getL10n()))));
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/export/GpxSerializerTest.java b/tests/src/cgeo/geocaching/export/GpxSerializerTest.java
index 809c121..c43ad38 100644
--- a/tests/src/cgeo/geocaching/export/GpxSerializerTest.java
+++ b/tests/src/cgeo/geocaching/export/GpxSerializerTest.java
@@ -67,7 +67,7 @@ public class GpxSerializerTest extends AbstractResourceInstrumentationTestCase {
assertThat(gpxFirst.length() > 0).isTrue();
- final GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST_ID);
+ final GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST.id);
final InputStream stream = new ByteArrayInputStream(gpxFirst.getBytes(CharEncoding.UTF_8));
Collection<Geocache> caches = parser.parse(stream, null);
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index 6171bab..7c72a61 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -375,14 +375,41 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
public void testGPXMysteryType() throws IOException, ParserException {
final List<Geocache> caches = readGPX10(R.raw.tc2012);
- Geocache mystery = null;
- for (Geocache geocache : caches) {
- if (geocache.getName().equals("U017")) {
- mystery = geocache;
- }
- }
+ Geocache mystery = getCache(caches, "U017");
assertThat(mystery).isNotNull();
assert (mystery != null);
assertThat(mystery.getType()).isEqualTo(CacheType.MYSTERY);
}
+
+ private static Geocache getCache(final List<Geocache> caches, String geocode) {
+ for (Geocache geocache : caches) {
+ if (geocache.getName().equals(geocode)) {
+ return geocache;
+ }
+ }
+ return null;
+ }
+
+ public void testLabCaches() throws IOException, ParserException {
+ final List<Geocache> caches = readGPX10(R.raw.giga_lab_caches);
+ assertThat(caches).hasSize(10);
+ Geocache lab = getCache(caches, "01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark");
+ assertThat(lab).isNotNull();
+
+ // parse labs as virtual for the time being
+ assertThat(lab.getType()).isEqualTo(CacheType.VIRTUAL);
+
+ // no difficulty and terrain rating
+ assertThat(lab.getTerrain()).isEqualTo(0);
+ assertThat(lab.getDifficulty()).isEqualTo(0);
+
+ // geocodes are just big hashes
+ assertThat(lab.getGeocode()).isEqualTo("01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark".toUpperCase(Locale.US));
+
+ // other normal cache properties
+ assertThat(lab.getName()).isEqualTo("01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark");
+ assertThat(lab.getShortDescription()).isEqualTo("01_Munich Olympic Walk Of Stars_Updated (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark");
+ assertThat(lab.getDescription()).startsWith("DEU:");
+ }
+
}
diff --git a/tests/src/cgeo/geocaching/gcvote/GCVoteTest.java b/tests/src/cgeo/geocaching/gcvote/GCVoteTest.java
new file mode 100644
index 0000000..c1b5e75
--- /dev/null
+++ b/tests/src/cgeo/geocaching/gcvote/GCVoteTest.java
@@ -0,0 +1,47 @@
+package cgeo.geocaching.gcvote;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
+import cgeo.geocaching.test.R;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+public class GCVoteTest extends AbstractResourceInstrumentationTestCase {
+
+ private InputStream responseStream;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ responseStream = new ByteArrayInputStream(getFileContent(R.raw.gcvote).getBytes());
+ responseStream.mark(getFileContent(R.raw.gcvote).getBytes().length + 1);
+ }
+
+ private InputStream responseStream() {
+ try {
+ responseStream.reset();
+ } catch (final IOException ignored) {
+ // Cannot happen
+ }
+ return responseStream;
+ }
+
+ public void testGetRatingsByGeocode() {
+ final Map<String, GCVoteRating> ratings = GCVote.getRatingsFromXMLResponse(responseStream(), false);
+ assertThat(ratings).hasSize(10);
+ assertThat(ratings).containsKey("GCKF13");
+ assertThat(ratings.get("GC1WEVZ")).isEqualToComparingFieldByField(new GCVoteRating(3.75f, 2, 0));
+ }
+
+ public void testGetRatingsByGuid() {
+ final Map<String, GCVoteRating> ratings = GCVote.getRatingsFromXMLResponse(responseStream(), true);
+ assertThat(ratings).hasSize(10);
+ assertThat(ratings).containsKey("a02894bb-4a08-4c09-a73c-25939894ba15");
+ assertThat(ratings.get("5520c33b-3941-45ca-9056-ea655dbaadf7")).isEqualToComparingFieldByField(new GCVoteRating(3.75f, 2, 0));
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/geopoint/UnitsTest.java b/tests/src/cgeo/geocaching/geopoint/UnitsTest.java
index f208984..7f3bdab 100644
--- a/tests/src/cgeo/geocaching/geopoint/UnitsTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/UnitsTest.java
@@ -14,7 +14,7 @@ public class UnitsTest extends CGeoTestCase {
final String actual = Units.getDistanceFromKilometers(distance);
if (!StringUtils.equals(expected, actual.replace(',', '.'))) { // make 1.2 the same as 1,2
fail("getHumanDistance(" + distance +
- ") [metric: " + (!Settings.isUseImperialUnits() ? "yes" : "no") +
+ ") [metric: " + (!Settings.useImperialUnits() ? "yes" : "no") +
"] fails to match " + expected + ": " + actual);
}
}
@@ -23,7 +23,7 @@ public class UnitsTest extends CGeoTestCase {
@SuppressWarnings("static-method")
public void testDistance() {
assertThat(Units.getDistanceFromKilometers(null)).isEqualTo("?");
- final boolean savedImperial = Settings.isUseImperialUnits();
+ final boolean savedImperial = Settings.useImperialUnits();
try {
TestSettings.setUseImperialUnits(false);
assertDistance("123 km", 122.782f);
@@ -46,7 +46,7 @@ public class UnitsTest extends CGeoTestCase {
@SuppressWarnings("static-method")
public void testSpeed() {
assertThat(Units.getDistanceFromKilometers(null)).isEqualTo("?");
- final boolean savedImperial = Settings.isUseImperialUnits();
+ final boolean savedImperial = Settings.useImperialUnits();
try {
TestSettings.setUseImperialUnits(false);
assertSpeed("123 km/h", 122.782f);
diff --git a/tests/src/cgeo/geocaching/sensors/SensorsTest.java b/tests/src/cgeo/geocaching/sensors/SensorsTest.java
index c4f70aa..b54cd13 100644
--- a/tests/src/cgeo/geocaching/sensors/SensorsTest.java
+++ b/tests/src/cgeo/geocaching/sensors/SensorsTest.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.sensors;
import static org.assertj.core.api.Assertions.assertThat;
import cgeo.geocaching.MainActivity;
+import cgeo.geocaching.utils.AngleUtils;
import android.test.ActivityInstrumentationTestCase2;
@@ -18,7 +19,7 @@ public class SensorsTest extends ActivityInstrumentationTestCase2<MainActivity>
}
public static void testGetDirectionNow() {
- final float angle = DirectionProvider.getDirectionNow(1.0f);
+ final float angle = AngleUtils.getDirectionNow(1.0f);
assertThat(angle == 1.0f || angle == 91.0f || angle == 181.0f || angle == 271.0f).isTrue();
}
diff --git a/tests/src/cgeo/geocaching/settings/TestSettings.java b/tests/src/cgeo/geocaching/settings/TestSettings.java
index 279f658..b82c120 100644
--- a/tests/src/cgeo/geocaching/settings/TestSettings.java
+++ b/tests/src/cgeo/geocaching/settings/TestSettings.java
@@ -37,7 +37,7 @@ public final class TestSettings extends Settings {
}
public static void setUseImperialUnits(final boolean imperial) {
- putBoolean(R.string.pref_units, imperial);
+ putBoolean(R.string.pref_units_imperial, imperial);
}
public static void setCacheTwitterMessage(final String template) {
diff --git a/tests/src/cgeo/geocaching/speech/TextFactoryTest.java b/tests/src/cgeo/geocaching/speech/TextFactoryTest.java
index c53aec9..1f309ba 100644
--- a/tests/src/cgeo/geocaching/speech/TextFactoryTest.java
+++ b/tests/src/cgeo/geocaching/speech/TextFactoryTest.java
@@ -35,7 +35,7 @@ public class TextFactoryTest extends AndroidTestCase {
final Configuration config = resources.getConfiguration();
defaultLocale1 = config.locale;
defaultLocale2 = Locale.getDefault();
- defaultMetric = !Settings.isUseImperialUnits();
+ defaultMetric = !Settings.useImperialUnits();
}
@Override
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
index eaac181..2a22895 100644
--- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
+++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
@@ -75,7 +75,7 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
protected void setUp() throws Exception {
super.setUp();
temporaryListId = DataStore.createList("Temporary unit testing");
- assertThat(temporaryListId != StoredList.TEMPORARY_LIST_ID).isTrue();
+ assertThat(temporaryListId != StoredList.TEMPORARY_LIST.id).isTrue();
assertThat(temporaryListId != StoredList.STANDARD_LIST_ID).isTrue();
}
@@ -95,7 +95,7 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
final protected Geocache loadCacheFromResource(int resourceId) throws IOException, ParserException {
final InputStream instream = getResourceStream(resourceId);
try {
- GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST_ID);
+ GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST.id);
Collection<Geocache> caches = parser.parse(instream, null);
assertThat(caches).isNotNull();
assertThat(caches.isEmpty()).isFalse();
diff --git a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
index 65e86b8..e75c2e6 100644
--- a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
@@ -15,4 +15,9 @@ public class HtmlUtilsTest extends TestCase {
assertThat(HtmlUtils.extractText("<b>bold</b>")).isEqualTo("bold");
}
+ public static void testRemoveExtraParagraph() {
+ assertThat(HtmlUtils.removeExtraParagraph("<p></p>")).isEqualTo("");
+ assertThat(HtmlUtils.removeExtraParagraph("<p>Test</p>")).isEqualTo("Test");
+ assertThat(HtmlUtils.removeExtraParagraph("<p>1</p><p>2</p>")).isEqualTo("<p>1</p><p>2</p>");
+ }
}
diff --git a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
index 29c4864..709fcc4 100644
--- a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
@@ -26,4 +26,11 @@ public class TextUtilsTest extends AndroidTestCase {
assertThat(TextUtils.getMatch("some" + "\u001C" + "control" + (char) 0x1D + "characters removed", patternAll, "")).isEqualTo("some control characters removed");
assertThat(TextUtils.getMatch("newline\nalso\nremoved", patternAll, "")).isEqualTo("newline also removed");
}
+
+ public static void testGetMatch() {
+ final Pattern patternAll = Pattern.compile("foo(...)");
+ final String text = "abc-foobar-def-fooxyz-ghi-foobaz-jkl";
+ assertThat(TextUtils.getMatch(text, patternAll, false, 1, null, false)).isEqualTo("bar");
+ assertThat(TextUtils.getMatch(text, patternAll, false, 1, null, true)).isEqualTo("baz");
+ }
}
diff --git a/tests/src/cgeo/junit/CgeoTestRunner.java b/tests/src/cgeo/junit/CgeoTestRunner.java
new file mode 100644
index 0000000..7a6f15e
--- /dev/null
+++ b/tests/src/cgeo/junit/CgeoTestRunner.java
@@ -0,0 +1,120 @@
+package cgeo.junit;
+
+import com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner;
+import com.zutubi.android.junitreport.JUnitReportListener;
+import com.zutubi.android.junitreport.JUnitReportTestRunner;
+
+import android.os.Bundle;
+import android.test.AndroidTestRunner;
+import android.util.Log;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Test runner which derives from the newer Google instrumentation test runner used by the Espresso test framework. It
+ * adds junit report functionality by cloning the behaviour of the {@link JUnitReportTestRunner}.
+ *
+ */
+public class CgeoTestRunner extends GoogleInstrumentationTestRunner {
+
+ /**
+ * Name of the report file(s) to write, may contain __suite__ in multiFile mode.
+ */
+ private static final String ARG_REPORT_FILE = "reportFile";
+ /**
+ * If specified, path of the directory to write report files to. May start with __external__.
+ * If not set files are written to the internal storage directory of the app under test.
+ */
+ private static final String ARG_REPORT_DIR = "reportDir";
+ /**
+ * If true, stack traces in the report will be filtered to remove common noise (e.g. framework
+ * methods).
+ */
+ private static final String ARG_FILTER_TRACES = "filterTraces";
+ /**
+ * If true, produce a separate file for each test suite. By default a single report is created
+ * for all suites.
+ */
+ private static final String ARG_MULTI_FILE = "multiFile";
+ /**
+ * Default name of the single report file.
+ */
+ private static final String DEFAULT_SINGLE_REPORT_FILE = "junit-report.xml";
+ /**
+ * Default name pattern for multiple report files.
+ */
+ private static final String DEFAULT_MULTI_REPORT_FILE = "junit-report-" + JUnitReportListener.TOKEN_SUITE + ".xml";
+
+ private static final String LOG_TAG = CgeoTestRunner.class.getSimpleName();
+
+ private JUnitReportListener mListener;
+ private String mReportFile;
+ private String mReportDir;
+ private boolean mFilterTraces = true;
+ private boolean mMultiFile = false;
+
+ @Override
+ public void onCreate(Bundle arguments) {
+ if (arguments != null) {
+ Log.i(LOG_TAG, "Created with arguments: " + arguments.keySet());
+ mReportFile = arguments.getString(ARG_REPORT_FILE);
+ mReportDir = arguments.getString(ARG_REPORT_DIR);
+ mFilterTraces = getBooleanArgument(arguments, ARG_FILTER_TRACES, true);
+ mMultiFile = getBooleanArgument(arguments, ARG_MULTI_FILE, false);
+ } else {
+ Log.i(LOG_TAG, "No arguments provided");
+ }
+
+ if (mReportFile == null) {
+ mReportFile = mMultiFile ? DEFAULT_MULTI_REPORT_FILE : DEFAULT_SINGLE_REPORT_FILE;
+ }
+ Log.i(LOG_TAG, "report directory '" + mReportDir + "'");
+ Log.i(LOG_TAG, "report file '" + mReportFile + "'");
+
+ super.onCreate(arguments);
+ }
+
+ private static boolean getBooleanArgument(Bundle arguments, String name, boolean defaultValue) {
+ String value = arguments.getString(name);
+ if (value == null) {
+ return defaultValue;
+ }
+ return Boolean.parseBoolean(value);
+ }
+
+ @Override
+ public void start() {
+ mListener = new JUnitReportListener(getContext(), getTargetContext(), mReportFile, mReportDir, mFilterTraces, mMultiFile);
+ try {
+ Class<?> c = getClass();
+ Field bridgeTestRunner = c.getSuperclass().getDeclaredField("bridgeTestRunner");
+ bridgeTestRunner.setAccessible(true);
+ Object obj = bridgeTestRunner.get(this);
+ Method m = obj.getClass().getDeclaredMethod("getAndroidTestRunner", (Class[]) null);
+ AndroidTestRunner androidTestRunner = (AndroidTestRunner) m.invoke(obj);
+ androidTestRunner.addTestListener(mListener);
+ } catch (NoSuchFieldException x) {
+ Log.e(LOG_TAG, x.toString());
+ } catch (SecurityException e) {
+ Log.e(LOG_TAG, e.toString());
+ } catch (NoSuchMethodException e) {
+ Log.e(LOG_TAG, e.toString());
+ } catch (IllegalAccessException x) {
+ Log.e(LOG_TAG, x.toString());
+ } catch (InvocationTargetException e) {
+ Log.e(LOG_TAG, e.toString());
+ }
+ super.start();
+ }
+
+ @Override
+ public void finish(int resultCode, Bundle results) {
+ if (mListener != null) {
+ mListener.close();
+ }
+
+ super.finish(resultCode, results);
+ }
+}
diff --git a/tests/tests.iml b/tests/tests.iml
index 6a6c905..ac5381c 100644
--- a/tests/tests.iml
+++ b/tests/tests.iml
@@ -4,6 +4,7 @@
<facet type="android" name="Android">
<configuration>
<option name="PACK_TEST_CODE" value="true" />
+ <option name="UPDATE_PROPERTY_FILES" value="false" />
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
</configuration>
</facet>