Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart@emeel.net>
92 lines
4.4 KiB
Plaintext
92 lines
4.4 KiB
Plaintext
<%
|
||
const type = locals.type;
|
||
const properties = locals.properties;
|
||
-%>
|
||
// This file is generated.
|
||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||
#import <XCTest/XCTest.h>
|
||
#import <Mapbox.h>
|
||
|
||
#import "MLNLight_Private.h"
|
||
|
||
#import "../../darwin/src/NSDate+MLNAdditions.h"
|
||
|
||
#import <mbgl/style/light.hpp>
|
||
#import <mbgl/style/types.hpp>
|
||
#include <mbgl/style/transition_options.hpp>
|
||
|
||
@interface MLNLightTest : XCTestCase
|
||
|
||
@end
|
||
|
||
@implementation MLNLightTest
|
||
|
||
- (void)testProperties {
|
||
|
||
MLNTransition defaultTransition = MLNTransitionMake(0, 0);
|
||
MLNTransition transition = MLNTransitionMake(6, 3);
|
||
mbgl::style::TransitionOptions transitionOptions { { MLNDurationFromTimeInterval(6) }, { MLNDurationFromTimeInterval(3) } };
|
||
|
||
<% for (const property of properties) { -%>
|
||
// <%- property.name %>
|
||
{
|
||
mbgl::style::Light light;
|
||
MLNLight *mglLight = [[MLNLight alloc] initWithMBGLLight:&light];
|
||
auto lightFromMLNLight = mglLight.mbglLight;
|
||
|
||
XCTAssertEqual(light.getDefault<%- camelize(property.name) -%>(), lightFromMLNLight.get<%- camelize(property.name) -%>());
|
||
<% if (property.transition) { -%>
|
||
auto <%- camelizeWithLeadingLowercase(property.name) -%>Transition = lightFromMLNLight.get<%- camelize(property.name) -%>Transition();
|
||
XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay && MLNTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay) == defaultTransition.delay);
|
||
XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration && MLNTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration) == defaultTransition.duration);
|
||
|
||
<% } -%>
|
||
<% if (property.type == "enum" && property.default) { -%>
|
||
XCTAssertEqual(mglLight.<%- camelizeWithLeadingLowercase(property.name) -%>.expressionType, NSConstantValueExpressionType, @"mglLight.<%- camelizeWithLeadingLowercase(property.name) -%> isn’t a constant value expression.");
|
||
XCTAssertEqualObjects(mglLight.<%- camelizeWithLeadingLowercase(property.name) -%>.constantValue, @"<%- property.default -%>");
|
||
|
||
<% } -%>
|
||
<% if (property.type == "array") { -%>
|
||
std::array<float, 3> positionArray = { { 6, 180, 90 } };
|
||
mbgl::style::Position position = { positionArray };
|
||
mbgl::style::PropertyValue<mbgl::style::Position> propertyValue = { position };
|
||
<% } else { -%>
|
||
mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> };
|
||
<% } -%>
|
||
light.set<%- camelize(property.name) -%>(propertyValue);
|
||
<% if (property.transition) { -%>
|
||
light.set<%- camelize(property.name) -%>Transition(transitionOptions);
|
||
|
||
<% } -%>
|
||
mglLight = [[MLNLight alloc] initWithMBGLLight:&light];
|
||
lightFromMLNLight = mglLight.mbglLight;
|
||
|
||
XCTAssertEqual(light.get<%- camelize(property.name) -%>(), lightFromMLNLight.get<%- camelize(property.name) -%>());
|
||
<% if (property.transition) { -%>
|
||
<%- camelizeWithLeadingLowercase(property.name) -%>Transition = lightFromMLNLight.get<%- camelize(property.name) -%>Transition();
|
||
XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay && MLNTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.delay) == transition.delay);
|
||
XCTAssert(<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration && MLNTimeIntervalFromDuration(*<%- camelizeWithLeadingLowercase(property.name) -%>Transition.duration) == transition.duration);
|
||
|
||
<% } -%>
|
||
}
|
||
|
||
<% } -%>
|
||
}
|
||
|
||
- (void)testValueAdditions {
|
||
MLNSphericalPosition position = MLNSphericalPositionMake(1.15, 210, 30);
|
||
|
||
XCTAssertEqual([NSValue valueWithMLNSphericalPosition:position].MLNSphericalPositionValue.radial, position.radial);
|
||
XCTAssertEqual([NSValue valueWithMLNSphericalPosition:position].MLNSphericalPositionValue.azimuthal, position.azimuthal);
|
||
XCTAssertEqual([NSValue valueWithMLNSphericalPosition:position].MLNSphericalPositionValue.polar, position.polar);
|
||
<% for (const property of properties) { -%>
|
||
<% if (property.type == "enum") { -%>
|
||
<% for (const value in property.values) { -%>
|
||
XCTAssertEqual([NSValue valueWithMLNLight<%- camelize(property.name) %>:MLNLight<%- camelize(property.name) %><%- camelize(value) %>].MLNLight<%- camelize(property.name) %>Value, MLNLight<%- camelize(property.name) %><%- camelize(value) %>);
|
||
<% } -%>
|
||
<% } -%>
|
||
<% } -%>
|
||
}
|
||
|
||
@end
|