| 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/html/HTMLSelectElement.h" | 5 #include "core/html/HTMLSelectElement.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/html/HTMLDocument.h" | 8 #include "core/html/HTMLDocument.h" |
| 9 #include "core/html/forms/FormController.h" | 9 #include "core/html/forms/FormController.h" |
| 10 #include "core/loader/EmptyClients.h" | 10 #include "core/loader/EmptyClients.h" |
| 11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class HTMLSelectElementTest : public::testing::Test { | 16 class HTMLSelectElementTest : public::testing::Test { |
| 17 protected: | 17 protected: |
| 18 void SetUp() override; | 18 void SetUp() override; |
| 19 HTMLDocument& document() const { return *m_document; } | 19 HTMLDocument& document() const { return *m_document; } |
| 20 | 20 |
| 21 private: | 21 private: |
| 22 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 22 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| 23 RefPtrWillBePersistent<HTMLDocument> m_document; | 23 Persistent<HTMLDocument> m_document; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 void HTMLSelectElementTest::SetUp() | 26 void HTMLSelectElementTest::SetUp() |
| 27 { | 27 { |
| 28 Page::PageClients pageClients; | 28 Page::PageClients pageClients; |
| 29 fillWithEmptyClients(pageClients); | 29 fillWithEmptyClients(pageClients); |
| 30 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients)
; | 30 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients)
; |
| 31 | 31 |
| 32 m_document = toHTMLDocument(&m_dummyPageHolder->document()); | 32 m_document = toHTMLDocument(&m_dummyPageHolder->document()); |
| 33 m_document->setMimeType("text/html"); | 33 m_document->setMimeType("text/html"); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 EXPECT_TRUE(select->popupIsVisible()); | 121 EXPECT_TRUE(select->popupIsVisible()); |
| 122 document().detach(); | 122 document().detach(); |
| 123 EXPECT_FALSE(select->popupIsVisible()); | 123 EXPECT_FALSE(select->popupIsVisible()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 TEST_F(HTMLSelectElementTest, ActiveSelectionEndAfterOptionRemoval) | 126 TEST_F(HTMLSelectElementTest, ActiveSelectionEndAfterOptionRemoval) |
| 127 { | 127 { |
| 128 document().documentElement()->setInnerHTML("<select><optgroup><option select
ed>o1</option></optgroup></select>", ASSERT_NO_EXCEPTION); | 128 document().documentElement()->setInnerHTML("<select><optgroup><option select
ed>o1</option></optgroup></select>", ASSERT_NO_EXCEPTION); |
| 129 document().view()->updateAllLifecyclePhases(); | 129 document().view()->updateAllLifecyclePhases(); |
| 130 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil
d()); | 130 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil
d()); |
| 131 RefPtrWillBeRawPtr<HTMLOptionElement> option = toHTMLOptionElement(select->f
irstChild()->firstChild()); | 131 RawPtr<HTMLOptionElement> option = toHTMLOptionElement(select->firstChild()-
>firstChild()); |
| 132 EXPECT_EQ(1, select->activeSelectionEndListIndex()); | 132 EXPECT_EQ(1, select->activeSelectionEndListIndex()); |
| 133 select->firstChild()->removeChild(option, ASSERT_NO_EXCEPTION); | 133 select->firstChild()->removeChild(option, ASSERT_NO_EXCEPTION); |
| 134 EXPECT_EQ(-1, select->activeSelectionEndListIndex()); | 134 EXPECT_EQ(-1, select->activeSelectionEndListIndex()); |
| 135 select->appendChild(option, ASSERT_NO_EXCEPTION); | 135 select->appendChild(option, ASSERT_NO_EXCEPTION); |
| 136 EXPECT_EQ(1, select->activeSelectionEndListIndex()); | 136 EXPECT_EQ(1, select->activeSelectionEndListIndex()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace blink | 139 } // namespace blink |
| OLD | NEW |