Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: Source/core/html/HTMLFormControlElementTest.cpp

Issue 389343002: Custom validation message to take into account text direction (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Corrected addition in core.gypi Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLFormControlElement.cpp ('k') | Source/core/page/ValidationMessageClient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLFormControlElementTest.cpp
diff --git a/Source/core/html/HTMLFormControlElementTest.cpp b/Source/core/html/HTMLFormControlElementTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9929d8ba88875e4fa5ae623df95f0d3c8d1ed2b
--- /dev/null
+++ b/Source/core/html/HTMLFormControlElementTest.cpp
@@ -0,0 +1,69 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/html/HTMLFormControlElement.h"
+
+#include "core/frame/FrameView.h"
+#include "core/html/HTMLDocument.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/testing/DummyPageHolder.h"
+#include <gtest/gtest.h>
+
+namespace blink {
+
+class HTMLFormControlElementTest : public ::testing::Test {
+protected:
+ virtual void SetUp() OVERRIDE;
+
+ DummyPageHolder& page() const { return *m_dummyPageHolder; }
+ HTMLDocument& document() const { return *m_document; }
+
+private:
+ OwnPtr<DummyPageHolder> m_dummyPageHolder;
+ RefPtrWillBePersistent<HTMLDocument> m_document;
+};
+
+void HTMLFormControlElementTest::SetUp()
+{
+ Page::PageClients pageClients;
+ fillWithEmptyClients(pageClients);
+ m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);
+
+ m_document = toHTMLDocument(&m_dummyPageHolder->document());
+ m_document->setMimeType("text/html");
+ m_document->setCharset("utf-8");
+}
+
+TEST_F(HTMLFormControlElementTest, customValidationMessageTextDirection)
+{
+ document().documentElement()->setInnerHTML("<body><input required id=input></body>", ASSERT_NO_EXCEPTION);
+ document().view()->updateLayoutAndStyleIfNeededRecursive();
+
+ HTMLInputElement* input = toHTMLInputElement(document().getElementById("input"));
+ input->setCustomValidity(String::fromUTF8("\xD8\xB9\xD8\xB1\xD8\xA8\xD9\x89"));
+ input->setAttribute(HTMLNames::titleAttr, AtomicString::fromUTF8("\xD8\xB9\xD8\xB1\xD8\xA8\xD9\x89"));
+
+ String message = input->validationMessage().stripWhiteSpace();
+ String subMessage = String();
+ TextDirection messageDir = RTL;
+ TextDirection subMessageDir = LTR;
+
+ input->findCustomValidationMessageTextDirection(message, messageDir, subMessage, subMessageDir);
+ EXPECT_EQ(RTL, messageDir);
+ EXPECT_EQ(LTR, subMessageDir);
+
+ input->renderer()->style()->setDirection(RTL);
+ input->findCustomValidationMessageTextDirection(message, messageDir, subMessage, subMessageDir);
+ EXPECT_EQ(RTL, messageDir);
+ EXPECT_EQ(RTL, subMessageDir);
+
+ input->setCustomValidity(String::fromUTF8("Main message."));
+ message = input->validationMessage().stripWhiteSpace();
+ input->findCustomValidationMessageTextDirection(message, messageDir, subMessage, subMessageDir);
+ EXPECT_EQ(LTR, messageDir);
+ EXPECT_EQ(RTL, subMessageDir);
+}
+
+}
« no previous file with comments | « Source/core/html/HTMLFormControlElement.cpp ('k') | Source/core/page/ValidationMessageClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698