diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 04:31:11 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 04:31:11 +0000 |
commit | 07f95333a47323bfbd65c8443e0fcc470956cb27 (patch) | |
tree | 9b49d3de4d7f454b03c59ba11ae33e09d2d06621 /chrome/renderer/render_view_unittest.cc | |
parent | 039169f20b03406981e7417761f62dde08eb23ab (diff) | |
download | chromium_src-07f95333a47323bfbd65c8443e0fcc470956cb27.zip chromium_src-07f95333a47323bfbd65c8443e0fcc470956cb27.tar.gz chromium_src-07f95333a47323bfbd65c8443e0fcc470956cb27.tar.bz2 |
A tricky fix for Issue 1845 (Take 2).
This is almost the same change as <http://codereview.chromium.org/39252/show>, which caused a build break on a Linux buildbot while compiling my new template function in "chrome/common/render_messages.h".
Even though I was not able to reproduce the build errors on my Linux box, I removed this function and use the int type in my IPC message 'ViewMsg_SetTextDirection'.
BUG=1845
Review URL: http://codereview.chromium.org/42495
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view_unittest.cc')
-rw-r--r-- | chrome/renderer/render_view_unittest.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index 9fa394a..fa26b44 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -316,3 +316,51 @@ TEST_F(RenderViewTest, ImeComposition) { } } } + +// Test that the RenderView::OnSetTextDirection() function can change the text +// direction of the selected input element. +TEST_F(RenderViewTest, OnSetTextDirection) { + // Load an HTML page consisting of a <textarea> element and a <div> element. + // This test changes the text direction of the <textarea> element, and + // writes the values of its 'dir' attribute and its 'direction' property to + // verify that the text direction is changed. + view_->set_delay_seconds_for_form_state_sync(0); + LoadHTML("<html>" + "<head>" + "</head>" + "<body>" + "<textarea id=\"test\"></textarea>" + "<div id=\"result\" contenteditable=\"true\"></div>" + "</body>" + "</html>"); + render_thread_.sink().ClearMessages(); + + static const struct { + WebTextDirection direction; + const wchar_t* expected_result; + } kTextDirection[] = { + {WEB_TEXT_DIRECTION_RTL, L"\x000A" L"rtl,rtl"}, + {WEB_TEXT_DIRECTION_LTR, L"\x000A" L"ltr,ltr"}, + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTextDirection); ++i) { + // Set the text direction of the <textarea> element. + ExecuteJavaScript("document.getElementById('test').focus();"); + view_->OnSetTextDirection(kTextDirection[i].direction); + + // Write the values of its DOM 'dir' attribute and its CSS 'direction' + // property to the <div> element. + ExecuteJavaScript("var result = document.getElementById('result');" + "var node = document.getElementById('test');" + "var style = getComputedStyle(node, null);" + "result.innerText =" + " node.getAttribute('dir') + ',' +" + " style.getPropertyValue('direction');"); + + // Copy the document content to std::wstring and compare with the + // expected result. + const int kMaxOutputCharacters = 16; + std::wstring output; + GetMainFrame()->GetContentAsPlainText(kMaxOutputCharacters, &output); + EXPECT_EQ(output, kTextDirection[i].expected_result); + } +} |