Files
MapLibreParticleLab/platform/darwin/test/MLNLightTest.mm.ejs
Bart Louwers 2a8ebc4906 core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-22 20:50:14 +02:00

92 lines
4.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%
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 <mln/style/light.hpp>
#import <mln/style/types.hpp>
#include <mln/style/transition_options.hpp>
@interface MLNLightTest : XCTestCase
@end
@implementation MLNLightTest
- (void)testProperties {
MLNTransition defaultTransition = MLNTransitionMake(0, 0);
MLNTransition transition = MLNTransitionMake(6, 3);
mln::style::TransitionOptions transitionOptions { { MLNDurationFromTimeInterval(6) }, { MLNDurationFromTimeInterval(3) } };
<% for (const property of properties) { -%>
// <%- property.name %>
{
mln::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 } };
mln::style::Position position = { positionArray };
mln::style::PropertyValue<mln::style::Position> propertyValue = { position };
<% } else { -%>
mln::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