Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Rewrite style layer tests #7708

Merged
merged 1 commit into from
Jan 13, 2017
Merged

Rewrite style layer tests #7708

merged 1 commit into from
Jan 13, 2017

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Jan 13, 2017

Replaced the style layer integration tests with unit tests. Until #7664, we weren’t really testing integration in these style layer test classes, anyways, since the added layers were getting blown away as soon as the style finished loading.

Test conversion of style values to property values and vice versa, not just round-tripping. Test the initial state and null-resetting of each null-resettable property. Test NSValue additions for style attribute enumerations. Test properties common to all style layer classes. Test MGLStyle’s source and layer collections.

Eviscerated implementations of unavailable style layer properties corresponding to style specification properties that were renamed. (This improves test coverage; this code can never run anyways.) Implemented corresponding getters to prevent ivars from being autosynthesized for these unavailable properties.

/cc @boundsj @friedbunny @frederoni

Replaced the style layer integration tests with unit tests. Test conversion of style values to property values and vice versa, not just round-tripping. Test the initial state and null-resetting of each null-resettable property. Test NSValue additions for style attribute enumerations. Test properties common to all style layer classes. Test MGLStyle’s source and layer collections.

Eviscerated implementations of unavailable style layer properties corresponding to style specification properties that were renamed. Implemented corresponding getters to prevent ivars from being autosynthesized for these unavailable properties.

Added a missing bridging header to the iOS test project.
@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor runtime styling tests labels Jan 13, 2017
@1ec5 1ec5 added this to the ios-v3.4.0 milestone Jan 13, 2017
@1ec5 1ec5 self-assigned this Jan 13, 2017
@1ec5 1ec5 requested a review from boundsj January 13, 2017 00:58
@mention-bot
Copy link

@1ec5, thanks for your PR! By analyzing this pull request, we identified @boundsj, @jfirebaugh and @incanus to be potential reviewers.

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 13, 2017

I put this issue on the v3.4.0 milestone because it doesn’t touch any shipping code (other than some dead code the compiler makes us put in) but makes us more confident about the shipping code (for example, leading me to find #7704). These tests can just as easily go into v3.4.1, however.

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 13, 2017

macOS SDK test coverage is at 29.16% overall, up from 27%:

macos

Relevant files compared to #7548 (comment):

  • MGLForegroundStyleLayer.m: 100%
  • NSValue+MGLStyleAttributeAdditions.m: 100%
  • NSPredicate+MGLAdditions.mm: 99.24%
  • MGLStyleLayer.mm: 97.78% 📈
  • NSCompoundPredicate+MGLAdditions.mm: 96.72%
  • NSComparisonPredicate+MGLAdditions.mm: 96.72%
  • MGLAttributionInfo.mm: 95.50%
  • MGLFillStyleLayer.mm: 89.44% 📈
  • MGLLineStyleLayer.mm: 87.14% 📈
  • MGLShapeSource.mm: 85.82% 📈
  • MGLSymbolStyleLayer.mm: 84.89% 📈
  • MGLCircleStyleLayer.mm: 81.91% 📈
  • MGLStyleValue_Private.h: 80.72% 📈
  • MGLStyleValue.mm: 76.19% 📈
  • MGLRasterStyleLayer.mm: 76.16% 📈
  • MGLBackgroundStyleLayer.mm: 74.70% 📈
  • MGLVectorSource: 72.55% 📈
  • MGLTileSource.mm: 62.89%
  • MGLRasterSource.mm: 61.97% 📈
  • MGLSource.mm: 58.62%
  • MGLStyle.mm: 53.54% 📈
  • MGLVectorStyleLayer.mm: 47.06% 📉
  • MGLOpenGLStyleLayer.mm: 39.47%
  • NSExpression+MGLAdditions.mm: 27.13%
  • MGLMapView.mm: 17.40% 📉

@1ec5 1ec5 requested a review from friedbunny January 13, 2017 01:45
Copy link
Contributor

@boundsj boundsj left a comment

Choose a reason for hiding this comment

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

This is great!!! In the interest of time, I focused on background and fill layer in my review. My only high level comment is that the MGLRuntimeStylingHelper function factory used to make the tests a bit more readable. Now you have to understand more about the mbgl implementation to make sense of the constant and property tests. I think that is fine but we might consider streamlining this in future refactors.

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 13, 2017

MGLRuntimeStylingHelper did make the tests more readable. However, I decided to replace it with more codegen so that objCTestValue() and mbglTestValue() always chooses a value other than the default. (I punted on doing that for some types, like number and enum.) That way we can be sure the property was actually set as opposed to being kept at the default.


@interface NSValue (MGLStyleLayerTestAdditions)

+ (instancetype)valueWithMGLVector:(CGVector)vector;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

macOS lacks +[NSValue valueWithCGVector:] and NSValue.cgVectorValue for some reason. It’s possible to call +[NSValue value:withObjCType:] and -[NSValue getValue:] instead, but that approach requires more than one statement at a time, so it doesn’t fit neatly into the assertion statements.

I’m considering upstreaming this category to the SDK proper, using +[NSValue valueWithMGLCoordinate:] and NSValue.mglCoordinateValue as a precedent.

@1ec5 1ec5 merged commit 4d50366 into release-ios-v3.4.0 Jan 13, 2017
@1ec5 1ec5 deleted the 1ec5-layer-unit-test branch January 13, 2017 18:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor runtime styling tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants