diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 04:57:14 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 04:57:14 +0000 |
commit | 03bd6648b11dd3d915103f847feed28d0af4c7c2 (patch) | |
tree | 85abd3b835fc6509aa935c673092860b9d4bdda9 /chrome/renderer | |
parent | 2255d61195136acb02d4b6a1e4b70977975ee716 (diff) | |
download | chromium_src-03bd6648b11dd3d915103f847feed28d0af4c7c2.zip chromium_src-03bd6648b11dd3d915103f847feed28d0af4c7c2.tar.gz chromium_src-03bd6648b11dd3d915103f847feed28d0af4c7c2.tar.bz2 |
Add the first unit-test that tests our IME backend.
This change is the first unit-test that tests our IME backend in the RenderWidget class. Thanks to the unit-test framework for the RenderView class created by Carlos and Brett, we can now implement this unit test. (I'm not sure I use this framework correctly, though. Please blame me if I use it improperly.)
Currently, this IME test just tests if our IME code can properly activate (or de-activate) IMEs for an <input> element and the initial position of a candidate window. I'm going to add more practical cases to this test.
Review URL: http://codereview.chromium.org/20014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_view.h | 1 | ||||
-rw-r--r-- | chrome/renderer/render_view_unittest.cc | 55 |
2 files changed, 56 insertions, 0 deletions
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index b177ed0..94d842d 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -337,6 +337,7 @@ class RenderView : public RenderWidget, private: FRIEND_TEST(RenderViewTest, OnLoadAlternateHTMLText); FRIEND_TEST(RenderViewTest, OnNavStateChanged); + FRIEND_TEST(RenderViewTest, OnImeStateChanged); explicit RenderView(RenderThreadBase* render_thread); diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index fd8b2df..82aff43 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -130,3 +130,58 @@ TEST_F(RenderViewTest, OnNavStateChanged) { 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, ¶ms); + 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, ¶ms); + EXPECT_EQ(params.a, IME_DISABLE); + } +} + |