summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_ime_input_event.h
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-21 07:09:32 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-21 07:09:32 +0000
commit397c2396865ba5bd314827141f647a47d1cbb3fb (patch)
treea6b3972a4d3904940df315b8385aa77b625d4541 /ppapi/tests/test_ime_input_event.h
parent455258051a2cb4591155cd099e959ce593340736 (diff)
downloadchromium_src-397c2396865ba5bd314827141f647a47d1cbb3fb.zip
chromium_src-397c2396865ba5bd314827141f647a47d1cbb3fb.tar.gz
chromium_src-397c2396865ba5bd314827141f647a47d1cbb3fb.tar.bz2
Test for Pepper IME events.
This patch adds a way to simulate IME composition events inside the renderer process, and tests that IME events are properly passed between the renderer and plugins. ppapi/tests/test_ime_input_event.cc: is the actual test case ppapi/{api,c,cpp}/dev/*ime_input_event_dev*: implements an API to create IME events from plugins for testing. other files: wire necessary stuff for simulating IME events. Since Pepper IME events are not delivered through WebKit/DOM layer but rather directly sent from renderer to plugins, the simulation part also follows the similar code path. BUG=126714 TEST=browser_tests PPAPITest.ImeInputEvent Review URL: https://chromiumcodereview.appspot.com/10391101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_ime_input_event.h')
-rw-r--r--ppapi/tests/test_ime_input_event.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/ppapi/tests/test_ime_input_event.h b/ppapi/tests/test_ime_input_event.h
new file mode 100644
index 0000000..483167c
--- /dev/null
+++ b/ppapi/tests/test_ime_input_event.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_TESTS_TEST_IME_INPUT_EVENT_H_
+#define PPAPI_TESTS_TEST_IME_INPUT_EVENT_H_
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
+#include "ppapi/c/ppb_input_event.h"
+#include "ppapi/cpp/input_event.h"
+#include "ppapi/tests/test_case.h"
+
+class TestImeInputEvent : public TestCase {
+ public:
+ explicit TestImeInputEvent(TestingInstance* instance);
+ ~TestImeInputEvent();
+
+ // TestCase implementation.
+ virtual void RunTests(const std::string& test_filter);
+ virtual bool Init();
+ virtual bool HandleInputEvent(const pp::InputEvent& input_event);
+ virtual void HandleMessage(const pp::Var& message_data);
+ virtual void DidChangeView(const pp::View& view);
+
+ private:
+ pp::InputEvent CreateImeCompositionStartEvent();
+ pp::InputEvent CreateImeCompositionUpdateEvent(
+ const std::string& text,
+ const std::vector<uint32_t>& segments,
+ int32_t target_segment,
+ const std::pair<uint32_t, uint32_t>& selection);
+ pp::InputEvent CreateImeCompositionEndEvent(const std::string& text);
+ pp::InputEvent CreateImeTextEvent(const std::string& text);
+ pp::InputEvent CreateCharEvent(const std::string& text);
+
+ void GetFocusBySimulatingMouseClick();
+ bool SimulateInputEvent(const pp::InputEvent& input_event);
+ bool AreEquivalentEvents(PP_Resource first, PP_Resource second);
+
+ // The test cases.
+ std::string TestImeCommit();
+ std::string TestImeCancel();
+ std::string TestImeUnawareCommit();
+ std::string TestImeUnawareCancel();
+
+ const PPB_InputEvent* input_event_interface_;
+ const PPB_KeyboardInputEvent* keyboard_input_event_interface_;
+ const PPB_IMEInputEvent_Dev* ime_input_event_interface_;
+
+ pp::Rect view_rect_;
+ bool received_unexpected_event_;
+ bool received_finish_message_;
+ std::vector<pp::InputEvent> expected_events_;
+};
+
+#endif // PPAPI_TESTS_TEST_IME_INPUT_EVENT_H_