Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <mitkEventMapper.h>
00020 #include <mitkEvent.h>
00021 #include <mitkInteractionConst.h>
00022 #include "mitkTestingMacros.h"
00023 #include <mitkStandardFileLocations.h>
00024 #include <mitkStateEvent.h>
00025 int mitkEventMapperTest(int , char* [])
00026 {
00027 MITK_TEST_BEGIN("EventMapper")
00028
00029
00030 mitk::Event* mouseButtonPressEvent = new mitk::Event(NULL, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none);
00031 const int mouseButtonPressID = 1;
00032
00033 mitk::Event* uniqueEventFile1 = new mitk::Event(NULL, mitk::Type_MouseButtonPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_R);
00034 const int uniqueEventIDFile1 = 13000;
00035 mitk::Event* uniqueEventFile2 = new mitk::Event(NULL, mitk::Type_MouseButtonPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_N);
00036 const int uniqueEventIDFile2 = 13001;
00037
00038
00039
00040 mitk::EventMapper* eventMapper = mitk::EventMapper::New();
00041
00042
00043 MITK_TEST_CONDITION_REQUIRED(eventMapper->LoadStandardBehavior(),"Testing LoadStandardBehavior(): ")
00044 std::cout<<"StyleName: " << eventMapper->GetStyleName()<<"\n";
00045
00046 mitk::StateEvent stateEvent;
00047 stateEvent.Set(0, mouseButtonPressEvent);
00048 eventMapper->RefreshStateEvent(&stateEvent);
00049 MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == mouseButtonPressID,"Testing event mapping of standard xml-file: ")
00050
00051 std::string xmlFileName1( mitk::StandardFileLocations::GetInstance()->FindFile("TestStateMachine1.xml", "Core/Code/Testing/Data") );
00052 MITK_TEST_CONDITION_REQUIRED(!xmlFileName1.empty(),"Getting xml file 1: ")
00053 MITK_TEST_CONDITION_REQUIRED(eventMapper->LoadBehavior(xmlFileName1),"Parsing xml file 1 should throw warning: ")
00054
00055 stateEvent.Set(0, uniqueEventFile1);
00056 eventMapper->RefreshStateEvent(&stateEvent);
00057 MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == uniqueEventIDFile1,"Testing event mapping of first additionally loaded xml-file: ")
00058
00059
00060 stateEvent.Set(0, mouseButtonPressEvent);
00061 eventMapper->RefreshStateEvent(&stateEvent);
00062 MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == mouseButtonPressID,"Testing if standard information still available: ")
00063
00064
00065 std::string xmlFileName2( mitk::StandardFileLocations::GetInstance()->FindFile("TestStateMachine2.xml", "Core/Code/Testing/Data") );
00066 MITK_TEST_CONDITION_REQUIRED(!xmlFileName2.empty(),"Getting xml file 2: ")
00067 MITK_TEST_CONDITION_REQUIRED(eventMapper->LoadBehavior(xmlFileName2),"Parsing xml file 2. Warning of double entry should be thrown: ")
00068
00069 stateEvent.Set(0, uniqueEventFile2);
00070 eventMapper->RefreshStateEvent(&stateEvent);
00071 MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == uniqueEventIDFile2,"Testing event mapping of second additionally loaded xml-file: ")
00072
00073
00074 stateEvent.Set(0, mouseButtonPressEvent);
00075 eventMapper->RefreshStateEvent(&stateEvent);
00076 MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == mouseButtonPressID,"Testing if standard information still available: ")
00077
00078 eventMapper->Delete();
00079
00080
00081 MITK_TEST_END();
00082 }