Skip to content

test(data): cover KML and GeoJSON styles and KML layer parsing - #1808

Open
kikoso wants to merge 2 commits into
mainfrom
test/data-styles-and-parsers
Open

kikoso wants to merge 2 commits into
mainfrom
test/data-styles-and-parsers

Conversation

@kikoso

@kikoso kikoso commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

First test-coverage PR for the data module: behaviour tests for the parts that need no map.

  • KmlStyleTest: KML aabbggrr colors (8 and 6 digits, whitespace), fill, outline and width, marker hue, heading and hotspot (fraction and fallback units), color modes, balloon text, setters, and computeRandomColor.
  • GeoJsonStylesTest: polygon, line string and point styles. Every setter notifies observers exactly once (GeoJsonLayer redraws from those notifications), and toPolygonOptions / toPolylineOptions / toMarkerOptions carry every property.
  • KmlLayerParsingTest: how KmlLayer turns KML into its model: document and nested folder containers, placemark properties and ExtendedData, shared and inline styles, polygons with holes, ground overlays, and placemarks across nested folders.

Coverage

Before After
data lines 57.1% (1,678 / 2,938) 68.2% (2,005 / 2,938)
data branches 38.7% 43.0%
KmlStyle 11.5% 96.2%
GeoJsonPolygonStyle / LineStringStyle / PointStyle 28% / 30% / 49% 100% / 100% / 100%
KmlPolygon 38.1% 100%
KmlLayer 50.6% 73.6%

Bugs found

Five tests are @Ignored because they document bugs found while writing them. Each was confirmed to fail with the @Ignore removed, and each has a comment explaining the cause.

  1. StyleMap styles are never applied. Style maps store the normal styleUrl with its # ("#red"), shared styles are keyed by bare id ("red"), so a placemark styled through a StyleMap ends up unstyled. Google Earth exports use a StyleMap on almost every placemark.
  2. A shared <Style> without an id crashes KmlLayer (NullPointerException from it.id!!).
  3. A GroundOverlay without a LatLonBox crashes KmlLayer (latLonBox!!). Google Earth writes gx:LatLonQuad instead of a LatLonBox for rotated overlays.
  4. GeoJsonLineStringStyle.toPolylineOptions drops the pattern and the start/end caps. Inside PolylineOptions().apply { }, the unqualified getPattern() / getStartCap() / getEndCap() resolve to the new options' own getters, so the defaults are copied instead of the style's values.
  5. KmlStyle random icon color mode randomizes the hue instead of the color. getMarkerOptions passes the hue (0 to 360) to computeRandomColor, which expects ARGB, so a green marker turns blue.

Bugs 2 and 3 are reachable with untrusted input. These are left for a follow-up fix PR so they show up as fix: entries in the changelog; removing each @Ignore is the test for its fix.

Testing

./gradlew :data:testDebugUnitTest: 187 tests, 0 failures, 5 skipped (the known bugs above). :data:lintDebug passes; its 8 findings are existing warnings in production code.

Adds behaviour tests for the parts of the data module that need no map:

- KmlStyle: KML aabbggrr colors, fill, outline, width, marker hue,
  heading, hotspot, color modes, balloon text and computeRandomColor.
- GeoJsonPolygonStyle, GeoJsonLineStringStyle, GeoJsonPointStyle: every
  setter notifies observers once, and the to*Options conversions carry
  every property.
- KmlLayer parsing: document and nested folder containers, placemark
  properties and extended data, shared and inline styles, polygons with
  holes, ground overlays and placemarks across nested folders.

data line coverage goes from 57.1% to 68.2%.

Five tests are ignored because they document bugs found while writing
them:
- KmlStyle random icon color mode randomizes the hue value instead of
  the color, so a green marker turns blue.
- GeoJsonLineStringStyle.toPolylineOptions drops the pattern and caps.
- Styles referenced through a StyleMap are never applied.
- A shared Style without an id crashes KmlLayer.
- A ground overlay without a LatLonBox (gx:LatLonQuad) crashes KmlLayer.
@googlemaps-bot

googlemaps-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 60.59% -0.1% 🍏
Files changed 79.21% 🍏

Module Coverage
Kover Gradle Plugin XML report for :data 61.36% -0.2% 🍏
Files
Module File Coverage
Kover Gradle Plugin XML report for :data GeoJsonLineStringStyle.kt 100% 🍏
KmlStyle.kt 98.4% 🍏
KmlLayer.kt 62.45% -1.82% 🍏

…ugs (#1809)

- KmlLayer resolved StyleMap entries with their leading '#' while shared
  styles are keyed by bare id, so placemarks styled through a StyleMap
  were unstyled.
- KmlLayer no longer throws on a shared Style or StyleMap without an id;
  they are skipped since nothing can reference them.
- KmlLayer no longer throws on a GroundOverlay without a LatLonBox (for
  example gx:LatLonQuad); the overlay is skipped with a warning.
- GeoJsonLineStringStyle.toPolylineOptions now keeps the pattern and the
  start and end caps.
- KmlStyle random icon color mode now randomizes the marker color
  instead of its hue, so markers keep their color family.

The regression tests from the data coverage tests are no longer ignored.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants