| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/dom/ElementTraversal.h" |
| 5 #include "core/layout/LayoutBlock.h" | 6 #include "core/layout/LayoutBlock.h" |
| 6 | 7 |
| 7 #include "core/layout/LayoutBlockFlow.h" | 8 #include "core/layout/LayoutBlockFlow.h" |
| 8 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 class LayoutBlockTest : public RenderingTest {}; | 14 class LayoutBlockTest : public RenderingTest {}; |
| 14 | 15 |
| 15 TEST_F(LayoutBlockTest, LayoutNameCalledWithNullStyle) { | 16 TEST_F(LayoutBlockTest, LayoutNameCalledWithNullStyle) { |
| 16 LayoutObject* obj = LayoutBlockFlow::createAnonymous(&document()); | 17 LayoutObject* obj = LayoutBlockFlow::createAnonymous(&document()); |
| 17 EXPECT_FALSE(obj->style()); | 18 EXPECT_FALSE(obj->style()); |
| 18 EXPECT_STREQ("LayoutBlockFlow (anonymous)", | 19 EXPECT_STREQ("LayoutBlockFlow (anonymous)", |
| 19 obj->decoratedName().ascii().data()); | 20 obj->decoratedName().ascii().data()); |
| 20 obj->destroy(); | 21 obj->destroy(); |
| 21 } | 22 } |
| 22 | 23 |
| 24 TEST_F(LayoutBlockTest, WidthAvailableToChildrenChanged) { |
| 25 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); |
| 26 setBodyInnerHTML( |
| 27 "<!DOCTYPE html>" |
| 28 "<div id='list' style='overflow-y:auto; width:150px; height:100px'>" |
| 29 " <div style='height:20px'>Item</div>" |
| 30 " <div style='height:20px'>Item</div>" |
| 31 " <div style='height:20px'>Item</div>" |
| 32 " <div style='height:20px'>Item</div>" |
| 33 " <div style='height:20px'>Item</div>" |
| 34 " <div style='height:20px'>Item</div>" |
| 35 "</div>"); |
| 36 Element* listElement = document().getElementById("list"); |
| 37 ASSERT_TRUE(listElement); |
| 38 LayoutBox* listBox = toLayoutBox(listElement->layoutObject()); |
| 39 Element* itemElement = ElementTraversal::firstChild(*listElement); |
| 40 ASSERT_TRUE(itemElement); |
| 41 ASSERT_GT(listBox->verticalScrollbarWidth(), 0); |
| 42 ASSERT_EQ(itemElement->offsetWidth(), |
| 43 150 - listBox->verticalScrollbarWidth()); |
| 44 |
| 45 DummyExceptionStateForTesting exceptionState; |
| 46 listElement->style()->setCSSText("width:150px;height:100px;", exceptionState); |
| 47 ASSERT_FALSE(exceptionState.hadException()); |
| 48 document().view()->updateAllLifecyclePhases(); |
| 49 ASSERT_EQ(listBox->verticalScrollbarWidth(), 0); |
| 50 ASSERT_EQ(itemElement->offsetWidth(), 150); |
| 51 } |
| 52 |
| 23 } // namespace blink | 53 } // namespace blink |
| OLD | NEW |