| 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/HTMLInputElement.h" | 5 #include "core/html/HTMLInputElement.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/VisualViewport.h" |
| 8 #include "core/html/HTMLBodyElement.h" | 11 #include "core/html/HTMLBodyElement.h" |
| 9 #include "core/html/HTMLFormElement.h" | 12 #include "core/html/HTMLFormElement.h" |
| 10 #include "core/html/HTMLHtmlElement.h" | 13 #include "core/html/HTMLHtmlElement.h" |
| 14 #include "core/html/forms/DateTimeChooser.h" |
| 11 #include "core/testing/DummyPageHolder.h" | 15 #include "core/testing/DummyPageHolder.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include <memory> | 17 #include <memory> |
| 14 | 18 |
| 15 namespace blink { | 19 namespace blink { |
| 16 | 20 |
| 17 TEST(HTMLInputElementTest, create) | 21 TEST(HTMLInputElementTest, create) |
| 18 { | 22 { |
| 19 Document* document = Document::create(); | 23 Document* document = Document::create(); |
| 20 HTMLInputElement* input = HTMLInputElement::create(*document, nullptr, /* cr
eatedByParser */ false); | 24 HTMLInputElement* input = HTMLInputElement::create(*document, nullptr, /* cr
eatedByParser */ false); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 Document* document = Document::create(); | 81 Document* document = Document::create(); |
| 78 HTMLInputElement* input = HTMLInputElement::create(*document, nullptr, false
); | 82 HTMLInputElement* input = HTMLInputElement::create(*document, nullptr, false
); |
| 79 input->setAttribute(HTMLNames::typeAttr, "image"); | 83 input->setAttribute(HTMLNames::typeAttr, "image"); |
| 80 input->ensureFallbackContent(); | 84 input->ensureFallbackContent(); |
| 81 // Make sure ensurePrimaryContent() recreates UA shadow tree, and updating | 85 // Make sure ensurePrimaryContent() recreates UA shadow tree, and updating |
| 82 // |value| doesn't crash. | 86 // |value| doesn't crash. |
| 83 input->ensurePrimaryContent(); | 87 input->ensurePrimaryContent(); |
| 84 input->setAttribute(HTMLNames::valueAttr, "aaa"); | 88 input->setAttribute(HTMLNames::valueAttr, "aaa"); |
| 85 } | 89 } |
| 86 | 90 |
| 91 TEST(HTMLInputElementTest, DateTimeChooserSizeParamRespectsScale) |
| 92 { |
| 93 std::unique_ptr<DummyPageHolder> pageHolder = DummyPageHolder::create(); |
| 94 Document* document = &(pageHolder->document()); |
| 95 document->view()->frame().host()->visualViewport().setScale(2.f); |
| 96 document->body()->setInnerHTML("<input type='date' style='width:200px;height
:50px' />", ASSERT_NO_EXCEPTION); |
| 97 document->view()->updateAllLifecyclePhases(); |
| 98 HTMLInputElement* input = toHTMLInputElement(document->body()->firstChild())
; |
| 99 |
| 100 DateTimeChooserParameters params; |
| 101 bool success = input->setupDateTimeChooserParameters(params); |
| 102 EXPECT_TRUE(success); |
| 103 EXPECT_EQ("date", params.type); |
| 104 EXPECT_EQ(IntRect(16, 16, 400, 100), params.anchorRectInScreen); |
| 105 } |
| 106 |
| 87 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |