]> git.mxchange.org Git - simgear.git/blob - simgear/canvas/events/event_test.cpp
Canvas: Support for preventDefault() on Events.
[simgear.git] / simgear / canvas / events / event_test.cpp
1 /// Unit tests for reference counting and smart pointer classes
2 #define BOOST_TEST_MODULE structure
3 #include <BoostTestTargetConfig.h>
4
5 #include "MouseEvent.hxx"
6 #include "CustomEvent.hxx"
7
8 namespace sc = simgear::canvas;
9
10 BOOST_AUTO_TEST_CASE( canvas_event_types )
11 {
12   // Register type
13   BOOST_REQUIRE_EQUAL( sc::Event::strToType("test"),
14                        sc::Event::UNKNOWN );
15   BOOST_REQUIRE_EQUAL( sc::Event::getOrRegisterType("test"),
16                        sc::Event::CUSTOM_EVENT );
17   BOOST_REQUIRE_EQUAL( sc::Event::strToType("test"),
18                        sc::Event::CUSTOM_EVENT );
19   BOOST_REQUIRE_EQUAL( sc::Event::typeToStr(sc::Event::CUSTOM_EVENT),
20                        "test" );
21
22   // Basic internal type
23   BOOST_REQUIRE_EQUAL( sc::Event::typeToStr(sc::Event::MOUSE_DOWN),
24                        "mousedown" );
25   BOOST_REQUIRE_EQUAL( sc::Event::strToType("mousedown"),
26                        sc::Event::MOUSE_DOWN );
27
28   // Unknown type
29   BOOST_REQUIRE_EQUAL( sc::Event::typeToStr(123),
30                        "unknown" );
31
32   // Register type through custom event instance
33   sc::CustomEvent e("blub");
34   BOOST_REQUIRE_EQUAL( e.getTypeString(), "blub" );
35   BOOST_REQUIRE_NE( e.getType(), sc::Event::UNKNOWN );
36 }