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

Unified Diff: chrome/renderer/render_view_unittest.cc

Issue 42495: A tricky fix for Issue 1845 (Take 2).... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | « chrome/renderer/render_view.h ('k') | chrome/renderer/render_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view_unittest.cc
===================================================================
--- chrome/renderer/render_view_unittest.cc (revision 12427)
+++ chrome/renderer/render_view_unittest.cc (working copy)
@@ -316,3 +316,51 @@
}
}
}
+
+// 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);
+ }
+}
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698