| 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/dom/Document.h" |
| 7 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 8 #include "core/html/HTMLDocument.h" | |
| 9 #include "core/html/HTMLFormElement.h" | 9 #include "core/html/HTMLFormElement.h" |
| 10 #include "core/html/forms/FormController.h" | 10 #include "core/html/forms/FormController.h" |
| 11 #include "core/loader/EmptyClients.h" | 11 #include "core/loader/EmptyClients.h" |
| 12 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class HTMLSelectElementTest : public::testing::Test { | 18 class HTMLSelectElementTest : public::testing::Test { |
| 19 protected: | 19 protected: |
| 20 void SetUp() override; | 20 void SetUp() override; |
| 21 HTMLDocument& document() const { return *m_document; } | 21 Document& document() const { return *m_document; } |
| 22 | |
| 23 private: | 22 private: |
| 24 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 23 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 25 Persistent<HTMLDocument> m_document; | 24 Persistent<Document> m_document; |
| 26 }; | 25 }; |
| 27 | 26 |
| 28 void HTMLSelectElementTest::SetUp() | 27 void HTMLSelectElementTest::SetUp() |
| 29 { | 28 { |
| 30 Page::PageClients pageClients; | 29 Page::PageClients pageClients; |
| 31 fillWithEmptyClients(pageClients); | 30 fillWithEmptyClients(pageClients); |
| 32 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients)
; | 31 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients)
; |
| 33 | 32 |
| 34 m_document = toHTMLDocument(&m_dummyPageHolder->document()); | 33 m_document = &m_dummyPageHolder->document(); |
| 35 m_document->setMimeType("text/html"); | 34 m_document->setMimeType("text/html"); |
| 36 } | 35 } |
| 37 | 36 |
| 38 TEST_F(HTMLSelectElementTest, SaveRestoreSelectSingleFormControlState) | 37 TEST_F(HTMLSelectElementTest, SaveRestoreSelectSingleFormControlState) |
| 39 { | 38 { |
| 40 document().documentElement()->setInnerHTML(String("<!DOCTYPE HTML><select id
='sel'>" | 39 document().documentElement()->setInnerHTML(String("<!DOCTYPE HTML><select id
='sel'>" |
| 41 "<option value='111' id='0'>111</option>" | 40 "<option value='111' id='0'>111</option>" |
| 42 "<option value='222'>222</option>" | 41 "<option value='222'>222</option>" |
| 43 "<option value='111' selected id='2'>!666</option>" | 42 "<option value='111' selected id='2'>!666</option>" |
| 44 "<option value='999'>999</option></select>"), ASSERT_NO_EXCEPTION); | 43 "<option value='999'>999</option></select>"), ASSERT_NO_EXCEPTION); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 TEST_F(HTMLSelectElementTest, SetRecalcListItemsByOptgroupRemoval) | 375 TEST_F(HTMLSelectElementTest, SetRecalcListItemsByOptgroupRemoval) |
| 377 { | 376 { |
| 378 document().documentElement()->setInnerHTML("<select><optgroup><option>sub1</
option><option>sub2</option></optgroup></select>", ASSERT_NO_EXCEPTION); | 377 document().documentElement()->setInnerHTML("<select><optgroup><option>sub1</
option><option>sub2</option></optgroup></select>", ASSERT_NO_EXCEPTION); |
| 379 document().view()->updateAllLifecyclePhases(); | 378 document().view()->updateAllLifecyclePhases(); |
| 380 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil
d()); | 379 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil
d()); |
| 381 select->setInnerHTML("", ASSERT_NO_EXCEPTION); | 380 select->setInnerHTML("", ASSERT_NO_EXCEPTION); |
| 382 // PASS if setInnerHTML didn't have a check failure. | 381 // PASS if setInnerHTML didn't have a check failure. |
| 383 } | 382 } |
| 384 | 383 |
| 385 } // namespace blink | 384 } // namespace blink |
| OLD | NEW |