示例#1
0
  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,
示例#2
0
  // 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());