| 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/HTMLFormControlElement.h" | 5 #include "core/html/HTMLFormControlElement.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/html/HTMLInputElement.h" | 10 #include "core/html/HTMLInputElement.h" |
| 11 #include "core/layout/LayoutObject.h" | 11 #include "core/layout/LayoutObject.h" |
| 12 #include "core/loader/EmptyClients.h" | 12 #include "core/loader/EmptyClients.h" |
| 13 #include "core/page/ScopedPageSuspender.h" |
| 13 #include "core/page/ValidationMessageClient.h" | 14 #include "core/page/ValidationMessageClient.h" |
| 14 #include "core/testing/DummyPageHolder.h" | 15 #include "core/testing/DummyPageHolder.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 class MockValidationMessageClient | 21 class MockValidationMessageClient |
| 21 : public GarbageCollectedFinalized<MockValidationMessageClient>, | 22 : public GarbageCollectedFinalized<MockValidationMessageClient>, |
| 22 public ValidationMessageClient { | 23 public ValidationMessageClient { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 Member<const Element> anchor_; | 53 Member<const Element> anchor_; |
| 53 }; | 54 }; |
| 54 } | 55 } |
| 55 | 56 |
| 56 class HTMLFormControlElementTest : public ::testing::Test { | 57 class HTMLFormControlElementTest : public ::testing::Test { |
| 57 protected: | 58 protected: |
| 58 void SetUp() override; | 59 void SetUp() override; |
| 59 | 60 |
| 60 DummyPageHolder& Page() const { return *dummy_page_holder_; } | 61 Page& GetPage() const { return dummy_page_holder_->GetPage(); } |
| 61 Document& GetDocument() const { return *document_; } | 62 Document& GetDocument() const { return *document_; } |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 std::unique_ptr<DummyPageHolder> dummy_page_holder_; | 65 std::unique_ptr<DummyPageHolder> dummy_page_holder_; |
| 65 Persistent<Document> document_; | 66 Persistent<Document> document_; |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 void HTMLFormControlElementTest::SetUp() { | 69 void HTMLFormControlElementTest::SetUp() { |
| 69 Page::PageClients page_clients; | 70 Page::PageClients page_clients; |
| 70 FillWithEmptyClients(page_clients); | 71 FillWithEmptyClients(page_clients); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 EXPECT_EQ(TextDirection::kLtr, message_dir); | 122 EXPECT_EQ(TextDirection::kLtr, message_dir); |
| 122 EXPECT_EQ(TextDirection::kRtl, sub_message_dir); | 123 EXPECT_EQ(TextDirection::kRtl, sub_message_dir); |
| 123 } | 124 } |
| 124 | 125 |
| 125 TEST_F(HTMLFormControlElementTest, UpdateValidationMessageSkippedIfPrinting) { | 126 TEST_F(HTMLFormControlElementTest, UpdateValidationMessageSkippedIfPrinting) { |
| 126 GetDocument().documentElement()->setInnerHTML( | 127 GetDocument().documentElement()->setInnerHTML( |
| 127 "<body><input required id=input></body>"); | 128 "<body><input required id=input></body>"); |
| 128 GetDocument().View()->UpdateAllLifecyclePhases(); | 129 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 129 ValidationMessageClient* validation_message_client = | 130 ValidationMessageClient* validation_message_client = |
| 130 new MockValidationMessageClient(); | 131 new MockValidationMessageClient(); |
| 131 GetDocument().GetPage()->SetValidationMessageClient( | 132 GetPage().SetValidationMessageClient(validation_message_client); |
| 132 validation_message_client); | 133 Page::OrdinaryPages().insert(&GetPage()); |
| 133 | 134 |
| 134 HTMLInputElement* input = | 135 HTMLInputElement* input = |
| 135 toHTMLInputElement(GetDocument().getElementById("input")); | 136 toHTMLInputElement(GetDocument().getElementById("input")); |
| 136 GetDocument().GetFrame()->SetPrinting(true, FloatSize(800, 600), | 137 ScopedPageSuspender suspender; // print() suspends the page. |
| 137 FloatSize(800, 600), 1); | |
| 138 input->reportValidity(); | 138 input->reportValidity(); |
| 139 EXPECT_FALSE(validation_message_client->IsValidationMessageVisible(*input)); | 139 EXPECT_FALSE(validation_message_client->IsValidationMessageVisible(*input)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |