Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / html / HTMLFormControlElementTest.cpp
blob5f02e88861777be2e7fe6c454cef2bd04c298b6d
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
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "core/html/HTMLFormControlElement.h"
8 #include "core/frame/FrameView.h"
9 #include "core/html/HTMLDocument.h"
10 #include "core/html/HTMLInputElement.h"
11 #include "core/layout/LayoutObject.h"
12 #include "core/loader/EmptyClients.h"
13 #include "core/testing/DummyPageHolder.h"
14 #include <gtest/gtest.h>
16 namespace blink {
18 class HTMLFormControlElementTest : public ::testing::Test {
19 protected:
20 void SetUp() override;
22 DummyPageHolder& page() const { return *m_dummyPageHolder; }
23 HTMLDocument& document() const { return *m_document; }
25 private:
26 OwnPtr<DummyPageHolder> m_dummyPageHolder;
27 RefPtrWillBePersistent<HTMLDocument> m_document;
30 void HTMLFormControlElementTest::SetUp()
32 Page::PageClients pageClients;
33 fillWithEmptyClients(pageClients);
34 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);
36 m_document = toHTMLDocument(&m_dummyPageHolder->document());
37 m_document->setMimeType("text/html");
40 TEST_F(HTMLFormControlElementTest, customValidationMessageTextDirection)
42 document().documentElement()->setInnerHTML("<body><input required id=input></body>", ASSERT_NO_EXCEPTION);
43 document().view()->updateAllLifecyclePhases();
45 HTMLInputElement* input = toHTMLInputElement(document().getElementById("input"));
46 input->setCustomValidity(String::fromUTF8("\xD8\xB9\xD8\xB1\xD8\xA8\xD9\x89"));
47 input->setAttribute(HTMLNames::titleAttr, AtomicString::fromUTF8("\xD8\xB9\xD8\xB1\xD8\xA8\xD9\x89"));
49 String message = input->validationMessage().stripWhiteSpace();
50 String subMessage = String();
51 TextDirection messageDir = RTL;
52 TextDirection subMessageDir = LTR;
54 input->findCustomValidationMessageTextDirection(message, messageDir, subMessage, subMessageDir);
55 EXPECT_EQ(RTL, messageDir);
56 EXPECT_EQ(LTR, subMessageDir);
58 input->layoutObject()->mutableStyleRef().setDirection(RTL);
59 input->findCustomValidationMessageTextDirection(message, messageDir, subMessage, subMessageDir);
60 EXPECT_EQ(RTL, messageDir);
61 EXPECT_EQ(RTL, subMessageDir);
63 input->setCustomValidity(String::fromUTF8("Main message."));
64 message = input->validationMessage().stripWhiteSpace();
65 input->findCustomValidationMessageTextDirection(message, messageDir, subMessage, subMessageDir);
66 EXPECT_EQ(LTR, messageDir);
67 EXPECT_EQ(RTL, subMessageDir);
70 } // namespace blink