test_input_event.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_INPUT_EVENT_H_
  5. #define PPAPI_TESTS_TEST_INPUT_EVENT_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include <vector>
  9. #include "ppapi/c/ppb_input_event.h"
  10. #include "ppapi/c/private/ppb_testing_private.h"
  11. #include "ppapi/cpp/input_event.h"
  12. #include "ppapi/cpp/point.h"
  13. #include "ppapi/cpp/rect.h"
  14. #include "ppapi/tests/test_case.h"
  15. #include "ppapi/tests/test_utils.h"
  16. class TestInputEvent : public TestCase {
  17. public:
  18. explicit TestInputEvent(TestingInstance* instance);
  19. ~TestInputEvent();
  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. // TestCase implementation.
  24. virtual bool Init();
  25. virtual void RunTests(const std::string& test_filter);
  26. private:
  27. pp::InputEvent CreateMouseEvent(PP_InputEvent_Type type,
  28. PP_InputEvent_MouseButton buttons);
  29. pp::InputEvent CreateWheelEvent();
  30. pp::InputEvent CreateKeyEvent(PP_InputEvent_Type type,
  31. uint32_t key_code, const std::string& code);
  32. pp::InputEvent CreateCharEvent(const std::string& text);
  33. pp::InputEvent CreateTouchEvent(PP_InputEvent_Type type,
  34. const pp::FloatPoint& location);
  35. void PostMessageBarrier();
  36. bool SimulateInputEvent(const pp::InputEvent& input_event);
  37. bool AreEquivalentEvents(PP_Resource first, PP_Resource second);
  38. std::string TestEvents();
  39. std::string TestAcceptTouchEvent_1();
  40. std::string TestAcceptTouchEvent_2();
  41. std::string TestAcceptTouchEvent_3();
  42. std::string TestAcceptTouchEvent_4();
  43. const PPB_InputEvent* input_event_interface_;
  44. const PPB_MouseInputEvent* mouse_input_event_interface_;
  45. const PPB_WheelInputEvent* wheel_input_event_interface_;
  46. const PPB_KeyboardInputEvent* keyboard_input_event_interface_;
  47. const PPB_TouchInputEvent* touch_input_event_interface_;
  48. NestedEvent nested_event_;
  49. pp::Rect view_rect_;
  50. pp::InputEvent expected_input_event_;
  51. bool received_expected_event_;
  52. bool received_finish_message_;
  53. };
  54. #endif // PPAPI_TESTS_TEST_INPUT_EVENT_H_