| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "web/ExternalPopupMenu.h" | 5 #include "web/ExternalPopupMenu.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/dom/NodeComputedStyle.h" | 8 #include "core/dom/NodeComputedStyle.h" |
| 9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 class ExternalPopupMenuDisplayNoneItemsTest : public testing::Test { | 28 class ExternalPopupMenuDisplayNoneItemsTest : public testing::Test { |
| 29 public: | 29 public: |
| 30 ExternalPopupMenuDisplayNoneItemsTest() { } | 30 ExternalPopupMenuDisplayNoneItemsTest() { } |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 void SetUp() override | 33 void SetUp() override |
| 34 { | 34 { |
| 35 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 35 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 36 RefPtrWillBeRawPtr<HTMLSelectElement> element = HTMLSelectElement::creat
e(m_dummyPageHolder->document()); | 36 RawPtr<HTMLSelectElement> element = HTMLSelectElement::create(m_dummyPag
eHolder->document()); |
| 37 // Set the 4th an 5th items to have "display: none" property | 37 // Set the 4th an 5th items to have "display: none" property |
| 38 element->setInnerHTML("<option><option><option><option style='display:no
ne;'><option style='display:none;'><option><option>", ASSERT_NO_EXCEPTION); | 38 element->setInnerHTML("<option><option><option><option style='display:no
ne;'><option style='display:none;'><option><option>", ASSERT_NO_EXCEPTION); |
| 39 m_dummyPageHolder->document().body()->appendChild(element.get(), ASSERT_
NO_EXCEPTION); | 39 m_dummyPageHolder->document().body()->appendChild(element.get(), ASSERT_
NO_EXCEPTION); |
| 40 m_ownerElement = element.release(); | 40 m_ownerElement = element.release(); |
| 41 m_dummyPageHolder->document().updateLayoutIgnorePendingStylesheets(); | 41 m_dummyPageHolder->document().updateLayoutIgnorePendingStylesheets(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 44 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| 45 RefPtrWillBePersistent<HTMLSelectElement> m_ownerElement; | 45 Persistent<HTMLSelectElement> m_ownerElement; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 TEST_F(ExternalPopupMenuDisplayNoneItemsTest, PopupMenuInfoSizeTest) | 48 TEST_F(ExternalPopupMenuDisplayNoneItemsTest, PopupMenuInfoSizeTest) |
| 49 { | 49 { |
| 50 WebPopupMenuInfo info; | 50 WebPopupMenuInfo info; |
| 51 ExternalPopupMenu::getPopupMenuInfo(info, *m_ownerElement); | 51 ExternalPopupMenu::getPopupMenuInfo(info, *m_ownerElement); |
| 52 EXPECT_EQ(5U, info.items.size()); | 52 EXPECT_EQ(5U, info.items.size()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 TEST_F(ExternalPopupMenuDisplayNoneItemsTest, IndexMappingTest) | 55 TEST_F(ExternalPopupMenuDisplayNoneItemsTest, IndexMappingTest) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 ASSERT_TRUE(select->popupIsVisible()); | 210 ASSERT_TRUE(select->popupIsVisible()); |
| 211 | 211 |
| 212 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(select-
>popup()); | 212 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(select-
>popup()); |
| 213 WebVector<int> indices; | 213 WebVector<int> indices; |
| 214 client->didAcceptIndices(indices); | 214 client->didAcceptIndices(indices); |
| 215 EXPECT_FALSE(select->popupIsVisible()); | 215 EXPECT_FALSE(select->popupIsVisible()); |
| 216 EXPECT_EQ(-1, select->selectedIndex()); | 216 EXPECT_EQ(-1, select->selectedIndex()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace blink | 219 } // namespace blink |
| OLD | NEW |