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

Side by Side 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: Removed |dir| value read. Updated tests to use setDirection. 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "config.h"
6 #include "core/html/HTMLFormControlElement.h"
7
8 #include "core/frame/FrameView.h"
9 #include "core/html/HTMLDocument.h"
10 #include "core/html/HTMLInputElement.h"
11 #include "core/testing/DummyPageHolder.h"
12 #include <gtest/gtest.h>
13
14 using namespace blink;
tkent 2014/08/11 01:45:48 We may simply use blink namespace like: namespace
Habib Virji 2014/08/11 20:34:29 Done.
15
16 namespace {
17
18 class HTMLFormControlElementTest : public ::testing::Test {
19 protected:
20 virtual void SetUp() OVERRIDE;
21
22 DummyPageHolder& page() const { return *m_dummyPageHolder; }
23 HTMLDocument& document() const { return *m_document; }
24
25 private:
26 OwnPtr<DummyPageHolder> m_dummyPageHolder;
27 RefPtrWillBePersistent<HTMLDocument> m_document;
28 };
29
30 void HTMLFormControlElementTest::SetUp()
31 {
32 Page::PageClients pageClients;
33 fillWithEmptyClients(pageClients);
34 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ;
35
36 m_document = toHTMLDocument(&m_dummyPageHolder->document());
37 m_document->setMimeType("text/html");
38 m_document->setCharset("utf-8");
39 m_document->documentElement()->setInnerHTML("<body><input required id=input> </body>", ASSERT_NO_EXCEPTION);
tkent 2014/08/11 01:45:49 Please move setInnerHTML call to the TEST_F. HTMLF
Habib Virji 2014/08/11 20:34:29 Done.
40 m_document->view()->updateLayoutAndStyleIfNeededRecursive();
41 }
42
43 TEST_F(HTMLFormControlElementTest, customValidationMessageTextDirection)
44 {
45 SetUp();
tkent 2014/08/11 01:45:48 Do not call SetUp(). It is automatically called.
Habib Virji 2014/08/11 20:34:29 Done.
46
47 HTMLInputElement* input = toHTMLInputElement(document().getElementById("inpu t"));
48 input->setCustomValidity(String::fromUTF8("عربى"));
tkent 2014/08/11 01:45:48 Please do not write non-ASCII characters in source
Habib Virji 2014/08/11 20:34:29 Done.
49 input->setAttribute(HTMLNames::titleAttr, AtomicString::fromUTF8("عربى"));
50
51 String message = input->validationMessage().stripWhiteSpace();
52 String subMessage = String();
53 TextDirection messageDir = RTL;
54 TextDirection subMessageDir = LTR;
55
56 input->findCustomValidationMessageTextDirection(message, messageDir, subMess age, subMessageDir);
57 EXPECT_EQ(messageDir, RTL);
58 EXPECT_EQ(subMessageDir, LTR);
59
60 input->renderer()->style()->setDirection(RTL);
61 input->findCustomValidationMessageTextDirection(message, messageDir, subMess age, subMessageDir);
62 EXPECT_EQ(messageDir, RTL);
63 EXPECT_EQ(subMessageDir, RTL);
64
65 input->setCustomValidity(String::fromUTF8("Main message."));
66 message = input->validationMessage().stripWhiteSpace();
67 input->findCustomValidationMessageTextDirection(message, messageDir, subMess age, subMessageDir);
68 EXPECT_EQ(messageDir, LTR);
69 EXPECT_EQ(subMessageDir, RTL);
70 }
71
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698