Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Programmatically sending events to sf::Window  (Read 1852 times)

0 Members and 1 Guest are viewing this topic.

deathvango

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Programmatically sending events to sf::Window
« on: November 28, 2015, 08:28:51 pm »
Hello,

I am using boost::test as a testing framework and am trying to create some tests for how my application will be processing user input to a window. The handling of each individual event is already under a test as they are not part of the same procedure that polls the events, so that's not my concern. I just want to make sure that the actual procedure that has the sf::Window::pollEvent() loop is also tested.

However, I am having trouble determining how one can programmatically send an event to a sf::Window, such as sf::Event::Resized or sf::Event::KeyPressed, which can then be processed by my pollEvent() procedure. Any ideas?

If I need to clarify more then let me know.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Programmatically sending events to sf::Window
« Reply #1 on: November 28, 2015, 08:40:10 pm »
It's not possible through the SFML API.
If you must you can write OS specific code and let the OS send events to the SFML window.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Programmatically sending events to sf::Window
« Reply #2 on: November 29, 2015, 09:20:50 pm »
Wrap the call to sf::Window::pollEvent(). Use one implementation of this adapter to use actual events from the window, and another that takes simulated events from a mock object.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything