コード例 #1
0
  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myUndoController != nullptr, "Testing instantiation")

  // check default model (verbose...)
  mitk::VerboseLimitedLinearUndo::Pointer standardModel =
    dynamic_cast<mitk::VerboseLimitedLinearUndo *>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(standardModel.IsNotNull(),
                               "Testing if the standard undo model VerboseLimitedLinearUndo is returned")

  // switch to limitedlinearundomodel
  myUndoController->AddUndoModel(mitk::UndoController::LIMITEDLINEARUNDO);
  mitk::LimitedLinearUndo::Pointer linearModel =
    dynamic_cast<mitk::LimitedLinearUndo *>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(linearModel.IsNotNull(), "Testing to add and then to read a LimitedLinearUndoModel")

  // switching to verbose again
  myUndoController->SwitchUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::VerboseLimitedLinearUndo::Pointer anotherVerboseModelPointer =
    dynamic_cast<mitk::VerboseLimitedLinearUndo *>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(standardModel == anotherVerboseModelPointer,
                               "Testing to switch back again and to be sure, that the poiinters are the same")

  // removing verbose; model should be switch to limited
  myUndoController->RemoveUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::LimitedLinearUndo::Pointer anotherLinearModel =
    dynamic_cast<mitk::LimitedLinearUndo *>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(
    linearModel == anotherLinearModel,
    "Testing to remove the VerboseLimitedLinearUndoModel and to automatically switch to LimitedLinearUndo")
コード例 #2
0
ファイル: mitkUndoControllerTest.cpp プロジェクト: 0r/MITK
  // let's create an object of our class
  auto  myUndoController = new mitk::UndoController();

  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myUndoController != nullptr, "Testing instantiation")

  //check default model (verbose...)
  mitk::VerboseLimitedLinearUndo::Pointer standardModel = dynamic_cast<mitk::VerboseLimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(standardModel.IsNotNull(),"Testing if the standard undo model VerboseLimitedLinearUndo is returned")

  //switch to limitedlinearundomodel
  myUndoController->AddUndoModel(mitk::UndoController::LIMITEDLINEARUNDO);
  mitk::LimitedLinearUndo::Pointer linearModel = dynamic_cast<mitk::LimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(linearModel.IsNotNull(),"Testing to add and then to read a LimitedLinearUndoModel")

  //switching to verbose again
  myUndoController->SwitchUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::VerboseLimitedLinearUndo::Pointer anotherVerboseModelPointer = dynamic_cast<mitk::VerboseLimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(standardModel == anotherVerboseModelPointer,"Testing to switch back again and to be sure, that the poiinters are the same")

  //removing verbose; model should be switch to limited
  myUndoController->RemoveUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::LimitedLinearUndo::Pointer anotherLinearModel = dynamic_cast<mitk::LimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(linearModel == anotherLinearModel,"Testing to remove the VerboseLimitedLinearUndoModel and to automatically switch to LimitedLinearUndo")

  //switch to limitedlinearundomodel
  myUndoController->AddUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::VerboseLimitedLinearUndo::Pointer newVerboseModelPointer = dynamic_cast<mitk::VerboseLimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(newVerboseModelPointer != standardModel,"Testing to add verbose model and if the new model is equal to the deleted one. Should not be the case!")