Index: third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp |
diff --git a/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp b/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp |
index d08f7e425b3185b7a4572131af8c7674f08b964a..f60be84782e83130a34f20bae85a1a030b712912 100644 |
--- a/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp |
+++ b/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp |
@@ -483,4 +483,182 @@ TEST_F(TextAutosizerTest, DeviceScaleAdjustmentWithViewport) { |
EXPECT_FLOAT_EQ(60.f, autosized->layoutObject()->style()->computedFontSize()); |
} |
+TEST_F(TextAutosizerTest, ChangingSuperClusterFirstText) { |
+ setBodyInnerHTML( |
+ "<meta name='viewport' content='width=800'>" |
+ "<style>" |
+ " html { font-size: 16px; }" |
+ " body { width: 800px; margin: 0; overflow-y: hidden; }" |
+ " .supercluster { width:560px; }" |
+ "</style>" |
+ "<div class='supercluster'>" |
+ " <div id='longText'>short blah blah</div>" |
+ "</div>" |
+ "<div class='supercluster'>" |
+ " <div id='shortText'>short blah blah</div>" |
+ "</div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ Element* longTextElement = document().getElementById("longText"); |
+ longTextElement->setInnerHTML( |
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed " |
+ "do eiusmod tempor" |
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim " |
+ "veniam, quis nostrud" |
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo " |
+ "consequat. Duis aute irure" |
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu " |
+ "fugiat nulla pariatur." |
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa " |
+ "qui officia deserunt" |
+ " mollit anim id est laborum.", |
+ ASSERT_NO_EXCEPTION); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ LayoutObject* longText = |
+ document().getElementById("longText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize()); |
+ //(specified font-size = 16px) * (block width = 560px) / |
+ // (window width = 320px) = 28px. |
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize()); |
+ LayoutObject* shortText = |
+ document().getElementById("shortText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize()); |
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize()); |
+} |
+ |
+TEST_F(TextAutosizerTest, ChangingSuperClusterSecondText) { |
+ setBodyInnerHTML( |
+ "<meta name='viewport' content='width=800'>" |
+ "<style>" |
+ " html { font-size: 16px; }" |
+ " body { width: 800px; margin: 0; overflow-y: hidden; }" |
+ " .supercluster { width:560px; }" |
+ "</style>" |
+ "<div class='supercluster'>" |
+ " <div id='shortText'>short blah blah</div>" |
+ "</div>" |
+ "<div class='supercluster'>" |
+ " <div id='longText'>short blah blah</div>" |
+ "</div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ Element* longTextElement = document().getElementById("longText"); |
+ longTextElement->setInnerHTML( |
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed " |
+ "do eiusmod tempor" |
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim " |
+ "veniam, quis nostrud" |
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo " |
+ "consequat. Duis aute irure" |
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu " |
+ "fugiat nulla pariatur." |
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa " |
+ "qui officia deserunt" |
+ " mollit anim id est laborum.", |
+ ASSERT_NO_EXCEPTION); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ LayoutObject* longText = |
+ document().getElementById("longText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize()); |
+ //(specified font-size = 16px) * (block width = 560px) / |
+ // (window width = 320px) = 28px. |
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize()); |
+ LayoutObject* shortText = |
+ document().getElementById("shortText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize()); |
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize()); |
+} |
+ |
+TEST_F(TextAutosizerTest, AddingSuperCluster) { |
+ setBodyInnerHTML( |
+ "<meta name='viewport' content='width=800'>" |
+ "<style>" |
+ " html { font-size: 16px; }" |
+ " body { width: 800px; margin: 0; overflow-y: hidden; }" |
+ " .supercluster { width:560px; }" |
+ "</style>" |
+ "<div>" |
+ " <div class='supercluster' id='shortText'>" |
+ " short blah blah" |
+ " </div>" |
+ "</div>" |
+ "<div id='container'></div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ Element* container = document().getElementById("container"); |
+ container->setInnerHTML( |
+ "<div class='supercluster' id='longText'>" |
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed " |
+ "do eiusmod tempor" |
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim " |
+ "veniam, quis nostrud" |
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo " |
+ "consequat. Duis aute irure" |
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu " |
+ "fugiat nulla pariatur." |
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa " |
+ "qui officia deserunt" |
+ " mollit anim id est laborum." |
+ "</div>", |
+ ASSERT_NO_EXCEPTION); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ LayoutObject* longText = |
+ document().getElementById("longText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize()); |
+ //(specified font-size = 16px) * (block width = 560px) / |
+ // (window width = 320px) = 28px. |
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize()); |
+ LayoutObject* shortText = |
+ document().getElementById("shortText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize()); |
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize()); |
+} |
+ |
+TEST_F(TextAutosizerTest, ChangingInheritedClusterTextInsideSuperCluster) { |
+ setBodyInnerHTML( |
+ "<meta name='viewport' content='width=800'>" |
+ "<style>" |
+ " html { font-size: 16px; }" |
+ " body { width: 800px; margin: 0; overflow-y: hidden; }" |
+ " .supercluster { width:560px; }" |
+ " .cluster{width:560px;}" |
+ "</style>" |
+ "<div class='supercluster'>" |
+ " <div class='cluster' id='longText'>short blah blah</div>" |
+ "</div>" |
+ "<div class='supercluster'>" |
+ " <div class='cluster' id='shortText'>short blah blah</div>" |
+ "</div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ Element* longTextElement = document().getElementById("longText"); |
+ longTextElement->setInnerHTML( |
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed " |
+ "do eiusmod tempor" |
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim " |
+ "veniam, quis nostrud" |
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo " |
+ "consequat. Duis aute irure" |
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu " |
+ "fugiat nulla pariatur." |
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa " |
+ "qui officia deserunt" |
+ " mollit anim id est laborum.", |
+ ASSERT_NO_EXCEPTION); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ LayoutObject* longText = |
+ document().getElementById("longText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize()); |
+ //(specified font-size = 16px) * (block width = 560px) / |
+ // (window width = 320px) = 28px. |
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize()); |
+ LayoutObject* shortText = |
+ document().getElementById("shortText")->layoutObject(); |
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize()); |
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize()); |
+} |
} // namespace blink |