mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-15 07:22:49 +03:00
Span’s own RichText was using the parent match width while still inheriting text-align: center, so the text was rendered offset inside the correct span box.
This commit is contained in:
@@ -3800,6 +3800,43 @@ UTEST( UIHTML, FlexAnchorInFlexNavVisible ) {
|
||||
Engine::destroySingleton();
|
||||
}
|
||||
|
||||
UTEST( UIHTML, FlexTextSpanWrapContentUsesItemWidth ) {
|
||||
Engine::instance()->createWindow( WindowSettings( 1280, 720, "Flex Text Span Width Test",
|
||||
WindowStyle::Default, WindowBackend::Default,
|
||||
32, {}, 1, false, true ),
|
||||
ContextSettings( false, 0, 0, GLv_default, true, false ) );
|
||||
|
||||
UISceneNode* sceneNode = init_test_inline_block();
|
||||
sceneNode->setURI( "file://" + Sys::getProcessPath() + "assets/html/" );
|
||||
|
||||
std::string html;
|
||||
FileSystem::fileGet( "assets/html/newsblur_home_prices_small.html", html );
|
||||
sceneNode->loadLayoutFromString( HTMLFormatter::HTMLtoXML( html ) );
|
||||
|
||||
sceneNode->update( Seconds( 1 ) );
|
||||
sceneNode->updateDirtyLayouts();
|
||||
|
||||
auto priceAmount = sceneNode->getRoot()->findByClass( "NB-pricing-tier-price-amount" );
|
||||
ASSERT_TRUE( priceAmount != nullptr );
|
||||
ASSERT_TRUE( priceAmount->isType( UI_TYPE_TEXTSPAN ) );
|
||||
|
||||
auto* amountSpan = priceAmount->asType<UITextSpan>();
|
||||
auto* amountRichText = amountSpan->getRichTextPtr();
|
||||
ASSERT_TRUE( amountRichText != nullptr );
|
||||
amountRichText->updateLayout();
|
||||
|
||||
const auto& lines = amountRichText->getLines();
|
||||
ASSERT_EQ( lines.size(), 1u );
|
||||
ASSERT_EQ( lines.front().spans.size(), 1u );
|
||||
ASSERT_EQ( lines.front().spans.front().type, RichText::RenderSpan::Type::Text );
|
||||
ASSERT_TRUE( lines.front().spans.front().text != nullptr );
|
||||
EXPECT_STRINGEQ( lines.front().spans.front().text->getString(), "$36" );
|
||||
EXPECT_NEAR( lines.front().spans.front().position.x, 0.f, 1.f );
|
||||
EXPECT_NEAR( amountSpan->getPixelsSize().getWidth(), lines.front().spans.front().size.x, 2.f );
|
||||
|
||||
Engine::destroySingleton();
|
||||
}
|
||||
|
||||
UTEST( UIHTML, FlexLiItemsWrapContentWidth ) {
|
||||
Engine::instance()->createWindow( WindowSettings( 1024, 768, "Flex LI Width Test",
|
||||
WindowStyle::Default, WindowBackend::Default,
|
||||
|
||||
Reference in New Issue
Block a user