[core] Add image sections to format expression

This commit is contained in:
Alexander Shalamov
2019-11-12 22:21:12 +02:00
parent 5e3ef2e9e0
commit a01ecc92a0
8 changed files with 153 additions and 94 deletions

View File

@@ -343,7 +343,8 @@ void testHasOverrides(LayoutType& layout) {
EXPECT_FALSE(MockOverrides::hasOverrides(layout.template get<TextField>()));
// Expression, overridden text-color.
FormatExpressionSection section(literal(""), nullopt, nullopt, toColor(literal("red")));
FormatExpressionSection section(literal(""));
section.setTextSectionOptions(nullopt, nullopt, toColor(literal("red")));
auto formatExprOverride = std::make_unique<FormatExpression>(std::vector<FormatExpressionSection>{section});
PropertyExpression<Formatted> propExprOverride(std::move(formatExprOverride));
layout.template get<TextField>() = PropertyValueType<Formatted>(std::move(propExprOverride));
@@ -351,7 +352,9 @@ void testHasOverrides(LayoutType& layout) {
// Nested expressions, overridden text-color.
auto formattedExpr1 = format("first paragraph");
std::vector<FormatExpressionSection> sections{ { literal("second paragraph"), nullopt, nullopt, toColor(literal("blue")) } };
FormatExpressionSection secondParagraph(literal("second paragraph"));
secondParagraph.setTextSectionOptions(nullopt, nullopt, toColor(literal("blue")));
std::vector<FormatExpressionSection> sections{{std::move(secondParagraph)}};
auto formattedExpr2 = std::make_unique<FormatExpression>(std::move(sections));
std::unordered_map<std::string, std::shared_ptr<Expression>> branches{ { "1st", std::move(formattedExpr1) },
{ "2nd", std::move(formattedExpr2) } };