From 5fcb4d4c14ac16f0957055279381eac1cf2452d3 Mon Sep 17 00:00:00 2001 From: Sasi Shanmugarajah Date: Mon, 11 Jul 2022 17:16:24 -0400 Subject: [PATCH] APL-CORE: August 2022 Release of APL 2022.1 compliant core engine (2022.1.1) For more details on this release refer to CHANGELOG.md To learn about APL see: https://developer.amazon.com/docs/alexa-presentation-language/understand-apl.html --- CHANGELOG.md | 6 ++++ .../src/component/gridsequencecomponent.cpp | 2 +- .../unittest_grid_sequence_component.cpp | 33 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f79fad1..c7712e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [2022.1.1] + +### Changed + +- Bug fixes + ## [2022.1.0] This release adds support for version 2022.1 of the APL specification. diff --git a/aplcore/src/component/gridsequencecomponent.cpp b/aplcore/src/component/gridsequencecomponent.cpp index b153ddd..b87124f 100644 --- a/aplcore/src/component/gridsequencecomponent.cpp +++ b/aplcore/src/component/gridsequencecomponent.cpp @@ -232,7 +232,7 @@ GridSequenceComponent::adjustChildDimensions( auto d = crossAxisArray.at(0).asDimension(*mContext); if (d.isAbsolute() || d.isRelative()) { auto adjustedSize = adjustedCrossAxisSizes.at(0); - if (adjustedSize > 0) { + if (adjustedSize > 0 && autoSizeBudget >= 0) { adjustedCrossAxisSizes.insert(adjustedCrossAxisSizes.end(), std::floor(autoSizeBudget/adjustedSize), adjustedSize); autoSizeBudget = 0; } diff --git a/unit/component/unittest_grid_sequence_component.cpp b/unit/component/unittest_grid_sequence_component.cpp index 1c2431f..04cd92c 100644 --- a/unit/component/unittest_grid_sequence_component.cpp +++ b/unit/component/unittest_grid_sequence_component.cpp @@ -2294,4 +2294,37 @@ TEST_F(GridSequenceComponentTest, ScrollOffsetReinflate) { // Validate second layout pass when scroll position need not to be adjusted after re-inflation advanceTime(10); ASSERT_TRUE(CheckChildrenLaidOut(component, {0,3}, true)); +} + +static const char* GRIDSEQUENCE_LARGE_CHILD = R"({ + "type": "APL", + "version": "1.4", + "extensions":{ + "name":"E", + "uri":"aplext:Event" + }, + "mainTemplate": { + "parameters": [], + "item": { + "type": "GridSequence", + "scrollDirection": "vertical", + "width": 60, + "height": 40, + "childWidth": "65dp", + "childHeight": "20dp", + "items": { + "type": "Frame", + "backgroundColor": "${data}" + }, + "data": [ "red", "blue", "green", "yellow", "gray", "orange", "white", "purple", "magenta", "cyan" ] + } + } +})"; + +TEST_F(GridSequenceComponentTest, InflateLargeChild) { + loadDocument(GRIDSEQUENCE_LARGE_CHILD); + ASSERT_TRUE(component); + + ASSERT_EQ(kComponentTypeGridSequence, component->getType()); + ASSERT_EQ(kScrollDirectionVertical, component->getCalculated(kPropertyScrollDirection).asInt()); } \ No newline at end of file