Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.

Add runtime-styling tests for 'smart setStyle' - #170

Merged
jfirebaugh merged 12 commits into
masterfrom
set-style-tests
Nov 22, 2016
Merged

jfirebaugh merged 12 commits into
masterfrom
set-style-tests

Conversation

@anandthakker

Copy link
Copy Markdown
Contributor

For each existing runtime-styling test, adds a corresponding test using setStyle

@anandthakker

Copy link
Copy Markdown
Contributor Author

Ready for 👀 @jfirebaugh @lucaswoj

The first commit is just the bulk copy of each runtime-styling/xxxx/ dir to runtime-styling/set-style-xxxx/, so probably slightly easier to read by just looking at each of the subsequent commits.

@jfirebaugh

jfirebaugh commented Nov 16, 2016 •

Copy link
Copy Markdown
Contributor

Looks good! Can you also add tests for:

  • Changes to layer.source, layer.source-layer, and layer.type
  • Changes to glyphs and sprite
  • Changes to sources that trigger layer add/readd
  • Layer reordering

@anandthakker

Copy link
Copy Markdown
Contributor Author

👍 ack--yeah, good call.

@anandthakker

Copy link
Copy Markdown
Contributor Author

Changes to glyphs

This one might be a weird -- I think what this will entail is putting a set of font data that is different from glyphs/Open Sans Semibold,Arial Unicode MS Bold somewhere like glyphs-alternate/Open Sans Semibold,Arial Unicode MS Bold, so that we can do a setStyle that changes local://glyphs/{fontstack}/{range}.pbf to local://glyphs-alternate/{fontstack}/{range}.pbf and actually produces a different visual result. I'm not at all familiar w/ the glyphs stuff -- does this sound about right?

@anandthakker

Copy link
Copy Markdown
Contributor Author

Oh, actually -- maybe it would be simpler (and less contrived?) to add glyphs-atlernate/Some Other Font, and then, in the setStyle operation, update glyphs: and change the style to use Some Other Font

@jfirebaugh

Copy link
Copy Markdown
Contributor

Would a hack like local://glyphs/alternate/../{fontstack}/{range}.pbf work?

@anandthakker

anandthakker commented Nov 16, 2016 •

Copy link
Copy Markdown
Contributor Author

@jfirebaugh It would probably work as far as testing that setStyle doesn't blow up, but my concern is that, since this URL would be pointing to the same font files, the expected output after the setStyle operation would be identical to what's shown before it -- so the test would not be able to distinguish between setStyle incorrectly being a noop vs. actually doing the work.

@lucaswoj

Copy link
Copy Markdown

You should be able to change the url from local://glyphs/Open Sans Semibold,Arial Unicode MS Bold/{range}.pbf to local://glyphs/NotoCJK/{range}.pbf

@anandthakker

Copy link
Copy Markdown
Contributor Author

Ohh, nice--that would be simpler.

@jfirebaugh

Copy link
Copy Markdown
Contributor

https://github.com/mapbox/mapbox-gl-style-spec/blob/mb-pages/lib/validate/validate_glyphs_url.js#L14

local://glyphs/Open Sans Semibold,Arial Unicode MS Bold/{range}.pbf?ignore={fontstack} would work though. 😁

@anandthakker

Copy link
Copy Markdown
Contributor Author

Update:

  • Added regression test for Removing a symbol layer and immediately readding it as a circle layer causes TypeError in draw_circle mapbox-gl-js#3633 (Normally this would belong in its own PR, but since set-style-layer-change-source-type is being added here, and is equivalent, I figured I might as well sneak the regression test in.
  • Skipped tests for native, confirming locally (via npm link) that the suite passes.
  • Added the following tests that @jfirebaugh pointed out above (and that I really should have completed in the first place before submitting for review 😬 )
    • Changes to layer.source, layer.source-layer, and layer.type: set-style-layer-change-{source,source-type,source-layer}
    • Changes to glyphs and sprite: set-style-{sprite,glyphs}
    • Changes to sources that trigger layer add/readd set-style-source-update
    • Layer reordering set-style-layer-reorder

@anandthakker

anandthakker commented Nov 17, 2016 •

Copy link
Copy Markdown
Contributor Author

Ugh, weirdness. The text-font/chinese test fails on my machine due to three of the icons being very slightly offset. Happens on gl-js master and also on the smart-set-style branch.

Not a big deal if CircleCI is still happy, except that this probably means that the expected image for the set-style-glyphs test (which is based on this one and which I generated with UPDATE=1 on my laptop) is gonna be wrong as well

@anandthakker

Copy link
Copy Markdown
Contributor Author

fail

@anandthakker

Copy link
Copy Markdown
Contributor Author

K, dealt with the above by just removing the icons. They aren't relevant to this test anyway.

"id": "fill",
"type": "fill",
"source": "vector",
"source-layer": "building"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason that expected.png looks right -- original style uses source-layer: 'landuse'.

Here's what the geojson dumps look like for landuse and building, respectively:

screen shot 2016-11-16 at 6 46 45 pm

screen shot 2016-11-16 at 6 48 38 pm

(the rendered image is right around the traffic circle)

"id": "circle",
"type": "circle",
"source": "geojson"
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason that expected.png looks right: the original circle layer uses an sdf icon colored red.

{
"id": "circle",
"type": "circle",
"source": "geojson"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason that expected.png looks right: the original circle layer points at wrong-geojson, whose coordinates are off-center.

0
]
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason that expected.png looks right: in the original style, the point is off-center.

"id": "circle",
"type": "circle",
"source": "geojson"
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason that expected.png looks right: in the original style, the smaller, red circle (circle-2) comes after the black one, so that it appears in the center.

(Note -- in this commit, this test is wrong because the source also changes; fixed in e7e13da.)

"symbol-placement": "point",
"icon-allow-overlap": true,
"icon-ignore-placement": true,
"icon-image": "restaurant-12"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason that expected.png looks right: the original style uses generic_icon from the emerald sprite set.

"text-field": "{name}",
"text-font": [
"NotoCJK"
],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason that expected.png looks right: the original style uses text-field: 'HELLO', rendered with Open Sans / Arial.

@anandthakker

anandthakker commented Nov 17, 2016 •

Copy link
Copy Markdown
Contributor Author

In response to a sudden bout of paranoia--and also hopefully to make the review a little easier--I added code comments in each of the new tests indicating why the expected.png makes sense. (A couple of them are 'outdated' because I was going commit-by-commit.)

I think this should now be ready for review.

@anandthakker

Copy link
Copy Markdown
Contributor Author

@mollymerp didn't want to lose track of your Slack question re: reusing expected images for runtime-styling/set-style-xxx and runtime-styling/xxx tests. Can't see the logs, but to paraphrase my answer:

  • The bulk of the set-style-xxx tests are directly copied from the equivalent, pre-existing runtime-styling. In those cases, I only changed style.json to use setStyle instead of whatever individual operation was being tested (addLayer, setLayoutProperty, etc.). The expected.png images are identical.
  • A few tests are totally new, because they test setStyle-specific things like reordering layers, changing glyphs, etc. For those, I tried to leave a note in the diff explaining why the expected image makes sense.

So, there are lots of duplicated images, but I figured that, eventually, the non-set-style versions of the tests will just be removed entirely... so maybe the dupe-ing is okay, temporarily?

@jfirebaugh
jfirebaugh merged commit cfa20f8 into master Nov 22, 2016
@jfirebaugh
jfirebaugh deleted the set-style-tests branch November 22, 2016 00:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants