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

Unified Diff: chrome/renderer/render_view_unittest.cc

Issue 20014: Add the first unit-test that tests our IME backend.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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') | no next file » | 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 9630)
+++ chrome/renderer/render_view_unittest.cc (working copy)
@@ -130,3 +130,58 @@
EXPECT_TRUE(render_thread_.sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID));
}
+
+// Test that our IME backend sends a notification message when the input focus
+// changes.
+TEST_F(RenderViewTest, OnImeStateChanged) {
+ // Enable our IME backend code.
+ view_->OnImeSetInputMode(true);
+
+ // Load an HTML page consisting of two input fields.
+ view_->set_delay_seconds_for_form_state_sync(0);
+ LoadHTML("<html>"
+ "<head>"
+ "</head>"
+ "<body>"
+ "<input id=\"test1\" type=\"text\"></input>"
+ "<input id=\"test2\" type=\"password\"></input>"
+ "</body>"
+ "</html>");
+ render_thread_.sink().ClearMessages();
+
+ const int kRepeatCount = 10;
+ for (int i = 0; i < kRepeatCount; i++) {
+ // Move the input focus to the first <input> element, where we should
+ // activate IMEs.
+ ExecuteJavaScript("document.getElementById('test1').focus();");
+ ProcessPendingMessages();
+ render_thread_.sink().ClearMessages();
+
+ // Update the IME status and verify if our IME backend sends an IPC message
+ // to activate IMEs.
+ view_->UpdateIME();
+ const IPC::Message* msg = render_thread_.sink().GetMessageAt(0);
+ EXPECT_TRUE(msg != NULL);
+ EXPECT_EQ(ViewHostMsg_ImeUpdateStatus::ID, msg->type());
+ ViewHostMsg_ImeUpdateStatus::Param params;
+ ViewHostMsg_ImeUpdateStatus::Read(msg, &params);
+ EXPECT_EQ(params.a, IME_COMPLETE_COMPOSITION);
+ EXPECT_TRUE(params.b.x() > 0 && params.b.y() > 0);
+
+ // Move the input focus to the second <input> element, where we should
+ // de-activate IMEs.
+ ExecuteJavaScript("document.getElementById('test2').focus();");
+ ProcessPendingMessages();
+ render_thread_.sink().ClearMessages();
+
+ // Update the IME status and verify if our IME backend sends an IPC message
+ // to de-activate IMEs.
+ view_->UpdateIME();
+ msg = render_thread_.sink().GetMessageAt(0);
+ EXPECT_TRUE(msg != NULL);
+ EXPECT_EQ(ViewHostMsg_ImeUpdateStatus::ID, msg->type());
+ ViewHostMsg_ImeUpdateStatus::Read(msg, &params);
+ EXPECT_EQ(params.a, IME_DISABLE);
+ }
+}
+
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698