<commit_before>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "mitkTestingMacros.h"
#include <mitkTestingConfig.h>
#include <mitkTestFixture.h>

#include <mitkIOUtil.h>
#include <mitkInteractionTestHelper.h>
#include <mitkPointSet.h>
#include <mitkPointSetDataInteractor.h>


class mitkPointSetDataInteractorTestSuite : public mitk::TestFixture
{

  CPPUNIT_TEST_SUITE(mitkPointSetDataInteractorTestSuite);
  MITK_TEST(AddPointInteraction);
  CPPUNIT_TEST_SUITE_END();


private:
  mitk::DataNode::Pointer testPointSetNode;
  mitk::PointSetDataInteractor::Pointer dataInteractor;
  mitk::PointSet::Pointer testPointSet;
  mitk::InteractionTestHelper::Pointer interactionTestHelper;

public:

  void setUp()
  {
    //Create DataNode as a container for our PointSet to be tested
    testPointSetNode = mitk::DataNode::New();

    // Create PointSetData Interactor
    dataInteractor = mitk::PointSetDataInteractor::New();
    // Load the according state machine for regular point set interaction
    dataInteractor->LoadStateMachine("PointSet.xml");
    // Set the configuration file that defines the triggers for the transitions
    dataInteractor->SetEventConfig("PointSetConfig.xml");
    // set the DataNode (which already is added to the DataStorage)
    dataInteractor->SetDataNode(testPointSetNode);

    //Create new PointSet which will receive the interaction input
    testPointSet = mitk::PointSet::New();
    testPointSetNode->SetData(testPointSet);
  }

  void tearDown()
  {
    //destroy all objects
    testPointSetNode = NULL;
    testPointSet = NULL;
    dataInteractor = NULL;
    //make sure to destroy the test helper object after each test
    interactionTestHelper = NULL;
  }

  void AddPointInteraction()
  {
    //Path to the reference PointSet
    std::string referencePointSetPath = "/Users/schroedt/Desktop/pointsetTestRef.mps";

    //Path to the interaction xml file
    std::string interactionXmlPath = "/Users/schroedt/Desktop/pointsetTest.xml";

    //Create test helper to initialize all necessary objects for interaction
    interactionTestHelper = mitk::InteractionTestHelper::New(interactionXmlPath);

    //Add our test node to the DataStorage of our test helper
    interactionTestHelper->AddNodeToStorage(testPointSetNode);

    //Start Interaction
    interactionTestHelper->PlaybackInteraction();

    //Load the reference PointSet
    mitk::PointSet::Pointer referencePointSet = mitk::IOUtil::LoadPointSet(referencePointSetPath);

    //Compare reference with the result of the interaction
    MITK_ASSERT_EQUAL(testPointSet.GetPointer(), referencePointSet.GetPointer(), "");
  }

};

MITK_TEST_SUITE_REGISTRATION(mitkPointSetDataInteractor)<commit_msg>Renamed members of PointSetDataInteractorTest<commit_after>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "mitkTestingMacros.h"
#include <mitkTestingConfig.h>
#include <mitkTestFixture.h>

#include <mitkIOUtil.h>
#include <mitkInteractionTestHelper.h>
#include <mitkPointSet.h>
#include <mitkPointSetDataInteractor.h>


class mitkPointSetDataInteractorTestSuite : public mitk::TestFixture
{

  CPPUNIT_TEST_SUITE(mitkPointSetDataInteractorTestSuite);
  MITK_TEST(AddPointInteraction);
  CPPUNIT_TEST_SUITE_END();


private:
  mitk::DataNode::Pointer m_TestPointSetNode;
  mitk::PointSetDataInteractor::Pointer m_DataInteractor;
  mitk::PointSet::Pointer m_TestPointSet;
  mitk::InteractionTestHelper::Pointer m_InteractionTestHelper;

public:

  void setUp()
  {
    //Create DataNode as a container for our PointSet to be tested
    m_TestPointSetNode = mitk::DataNode::New();

    // Create PointSetData Interactor
    m_DataInteractor = mitk::PointSetDataInteractor::New();
    // Load the according state machine for regular point set interaction
    m_DataInteractor->LoadStateMachine("PointSet.xml");
    // Set the configuration file that defines the triggers for the transitions
    m_DataInteractor->SetEventConfig("PointSetConfig.xml");
    // set the DataNode (which already is added to the DataStorage)
    m_DataInteractor->SetDataNode(m_TestPointSetNode);

    //Create new PointSet which will receive the interaction input
    m_TestPointSet = mitk::PointSet::New();
    m_TestPointSetNode->SetData(m_TestPointSet);
  }

  void tearDown()
  {
    //destroy all objects
    m_TestPointSetNode = NULL;
    m_TestPointSet = NULL;
    m_DataInteractor = NULL;
    //make sure to destroy the test helper object after each test
    m_InteractionTestHelper = NULL;
  }

  void AddPointInteraction()
  {
    //Path to the reference PointSet
    std::string referencePointSetPath = "/Users/schroedt/Desktop/pointsetTestRef.mps";

    //Path to the interaction xml file
    std::string interactionXmlPath = "/Users/schroedt/Desktop/pointsetTest.xml";

    //Create test helper to initialize all necessary objects for interaction
    m_InteractionTestHelper = mitk::InteractionTestHelper::New(interactionXmlPath);

    //Add our test node to the DataStorage of our test helper
    m_InteractionTestHelper->AddNodeToStorage(m_TestPointSetNode);

    //Start Interaction
    m_InteractionTestHelper->PlaybackInteraction();

    //Load the reference PointSet
    mitk::PointSet::Pointer referencePointSet = mitk::IOUtil::LoadPointSet(referencePointSetPath);

    //Compare reference with the result of the interaction
    MITK_ASSERT_EQUAL(m_TestPointSet.GetPointer(), referencePointSet.GetPointer(), "");
  }

};

MITK_TEST_SUITE_REGISTRATION(mitkPointSetDataInteractor)
{'fraction_non_alphanumeric': 0.12234042553191489, 'fraction_numerical': 0.0, 'mean_word_length': 5.170849420849421, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2397642', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1755, 'n_words': 468}