test_ime_input_event.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PPAPI_TESTS_TEST_IME_INPUT_EVENT_H_
  5. #define PPAPI_TESTS_TEST_IME_INPUT_EVENT_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include <utility>
  9. #include <vector>
  10. #include "ppapi/c/ppb_input_event.h"
  11. #include "ppapi/cpp/input_event.h"
  12. #include "ppapi/tests/test_case.h"
  13. class TestImeInputEvent : public TestCase {
  14. public:
  15. explicit TestImeInputEvent(TestingInstance* instance);
  16. ~TestImeInputEvent();
  17. // TestCase implementation.
  18. virtual void RunTests(const std::string& test_filter);
  19. virtual bool Init();
  20. virtual bool HandleInputEvent(const pp::InputEvent& input_event);
  21. virtual void HandleMessage(const pp::Var& message_data);
  22. virtual void DidChangeView(const pp::View& view);
  23. private:
  24. pp::InputEvent CreateImeCompositionStartEvent();
  25. pp::InputEvent CreateImeCompositionUpdateEvent(
  26. const std::string& text,
  27. const std::vector<uint32_t>& segments,
  28. int32_t target_segment,
  29. const std::pair<uint32_t, uint32_t>& selection);
  30. pp::InputEvent CreateImeCompositionEndEvent(const std::string& text);
  31. pp::InputEvent CreateImeTextEvent(const std::string& text);
  32. pp::InputEvent CreateCharEvent(const std::string& text);
  33. void GetFocusBySimulatingMouseClick();
  34. bool SimulateInputEvent(const pp::InputEvent& input_event);
  35. bool AreEquivalentEvents(PP_Resource first, PP_Resource second);
  36. // The test cases.
  37. std::string TestImeCommit();
  38. std::string TestImeCancel();
  39. std::string TestImeUnawareCommit();
  40. std::string TestImeUnawareCancel();
  41. const PPB_InputEvent* input_event_interface_;
  42. const PPB_KeyboardInputEvent* keyboard_input_event_interface_;
  43. const PPB_IMEInputEvent* ime_input_event_interface_;
  44. pp::Rect view_rect_;
  45. bool received_unexpected_event_;
  46. bool received_finish_message_;
  47. std::vector<pp::InputEvent> expected_events_;
  48. };
  49. #endif // PPAPI_TESTS_TEST_IME_INPUT_EVENT_H_