| 27 | #include <string> |
| 28 | |
| 29 | int mitkEventConfigTest(int argc, char *argv[]) |
| 30 | { |
| 31 | MITK_TEST_BEGIN("EventConfig") |
| 32 | |
| 33 | if (argc != 2) |
| 34 | { |
| 35 | MITK_ERROR << "Test needs configuration test file as parameter."; |
| 36 | return -1; |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | * Loads a test a Config file and test if Config is build up correctly, |
| 41 | * and if mapping from mitkEvents to EventVariant names works properly. |
| 42 | * Indirectly this also tests the EventFactory Class, since we also test if the events have been constructed properly. |
| 43 | * |
| 44 | * The configuration object is constructed in three different ways, |
| 45 | * each one is tested here. |
| 46 | */ |
| 47 | |
| 48 | // Construction using compiled-in resources: |
| 49 | us::Module *module = us::GetModuleContext()->GetModule(); |
| 50 | mitk::EventConfig newConfig("StatemachineConfigTest.xml", module); |
| 51 | |
| 52 | MITK_TEST_CONDITION_REQUIRED(newConfig.IsValid() == true, "01 Check if file can be loaded and is valid"); |
| 53 | /* |
| 54 | * Test the global properties: |
| 55 | * Test if stored values match the ones in the test config file. |
| 56 | */ |
| 57 | mitk::PropertyList::Pointer properties = newConfig.GetAttributes(); |
| 58 | std::string prop1, prop2; |
| 59 | MITK_TEST_CONDITION_REQUIRED(properties->GetStringProperty("property1", prop1) && prop1 == "yes" && |
| 60 | properties->GetStringProperty("scrollModus", prop2) && prop2 == "leftright", |
| 61 | "02 Check Global Properties"); |
| 62 | |
| 63 | /* |
| 64 | * Check if Events get mapped to the proper Variants |
| 65 | */ |
| 66 | mitk::Point2D pos; |
| 67 | mitk::MousePressEvent::Pointer mpe1 = |
| 68 | mitk::MousePressEvent::New(nullptr, |
| 69 | pos, |
| 70 | mitk::InteractionEvent::MiddleMouseButton | mitk::InteractionEvent::LeftMouseButton, |
| 71 | mitk::InteractionEvent::ControlKey | mitk::InteractionEvent::AltKey, |
| 72 | mitk::InteractionEvent::LeftMouseButton); |
| 73 | mitk::MousePressEvent::Pointer standard1 = mitk::MousePressEvent::New(nullptr, |
| 74 | pos, |
| 75 | mitk::InteractionEvent::LeftMouseButton, |
| 76 | mitk::InteractionEvent::NoKey, |
| 77 | mitk::InteractionEvent::LeftMouseButton); |
| 78 | mitk::MouseMoveEvent::Pointer mme1 = |
| 79 | mitk::MouseMoveEvent::New(nullptr, |
| 80 | pos, |
| 81 | mitk::InteractionEvent::RightMouseButton | mitk::InteractionEvent::LeftMouseButton, |
| 82 | mitk::InteractionEvent::ShiftKey); |
| 83 | mitk::MouseMoveEvent::Pointer mme2 = |
| 84 | mitk::MouseMoveEvent::New(nullptr, pos, mitk::InteractionEvent::RightMouseButton, mitk::InteractionEvent::ShiftKey); |
| 85 | mitk::MouseWheelEvent::Pointer mwe1 = mitk::MouseWheelEvent::New( |
| 86 | nullptr, pos, mitk::InteractionEvent::RightMouseButton, mitk::InteractionEvent::ShiftKey, -2); |
nothing calls this directly
no test coverage detected