Skip to content

Commit

Permalink
Refs #6541. Checking axis titles.
Browse files Browse the repository at this point in the history
Comparing the axis titles in the resulting datasets for the MDEW and MDHW
loading presenters.
  • Loading branch information
Michael Reuter committed Feb 20, 2013
1 parent bb7e1db commit 7d7290d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Code/Mantid/Vates/VatesAPI/test/MDEWLoadingPresenterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ void testDepthChanged()
presenter.extractMetadata(boost::dynamic_pointer_cast<IMDEventWorkspace>(ws));
vtkDataSet *ds = vtkUnstructuredGrid::New();
TSM_ASSERT_THROWS_NOTHING("Should pass", presenter.setAxisLabels(ds));
TSM_ASSERT_EQUALS("X Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForX"), "A (A)");
TSM_ASSERT_EQUALS("Y Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForY"), "B (A)");
TSM_ASSERT_EQUALS("Z Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForZ"), "C (A)");
}

void testCanSetAxisLabelsFrom4DData()
Expand All @@ -196,6 +202,12 @@ void testDepthChanged()
presenter.extractMetadata(boost::dynamic_pointer_cast<IMDEventWorkspace>(ws));
vtkDataSet *ds = vtkUnstructuredGrid::New();
TSM_ASSERT_THROWS_NOTHING("Should pass", presenter.setAxisLabels(ds));
TSM_ASSERT_EQUALS("X Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForX"), "A (A)");
TSM_ASSERT_EQUALS("Y Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForY"), "B (A)");
TSM_ASSERT_EQUALS("Z Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForZ"), "C (A)");
}

void testCanLoadFileBasedOnExtension()
Expand Down
12 changes: 12 additions & 0 deletions Code/Mantid/Vates/VatesAPI/test/MDHWLoadingPresenterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ void testCanSetAxisLabelsFrom3DData()
presenter.extractMetadata(boost::dynamic_pointer_cast<Mantid::API::IMDHistoWorkspace>(ws));
vtkDataSet *ds = vtkUnstructuredGrid::New();
TSM_ASSERT_THROWS_NOTHING("Should pass", presenter.setAxisLabels(ds));
TSM_ASSERT_EQUALS("X Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForX"), "A (A)");
TSM_ASSERT_EQUALS("Y Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForY"), "B (A)");
TSM_ASSERT_EQUALS("Z Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForZ"), "C (A)");
}

void testCanSetAxisLabelsFrom4DData()
Expand All @@ -170,6 +176,12 @@ void testCanSetAxisLabelsFrom4DData()
presenter.extractMetadata(boost::dynamic_pointer_cast<Mantid::API::IMDHistoWorkspace>(ws));
vtkDataSet *ds = vtkUnstructuredGrid::New();
TSM_ASSERT_THROWS_NOTHING("Should pass", presenter.setAxisLabels(ds));
TSM_ASSERT_EQUALS("X Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForX"), "A (A)");
TSM_ASSERT_EQUALS("Y Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForY"), "B (A)");
TSM_ASSERT_EQUALS("Z Label should match exactly",
getStringFieldDataValue(ds, "AxisTitleForZ"), "C (A)");
}

};
Expand Down
14 changes: 14 additions & 0 deletions Code/Mantid/Vates/VatesAPI/test/MockObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <gmock/gmock.h>
#include <vtkFieldData.h>
#include <vtkCharArray.h>
#include <vtkStringArray.h>

using Mantid::VATES::MDRebinningView;
using Mantid::Geometry::MDHistoDimension;
Expand Down Expand Up @@ -396,6 +397,19 @@ Create a field data entry containing (as contents) the argument text.
return AnalysisDataService::Instance().retrieve("binned");
}

/**
* Get a string array from a particular field data entry in a vtkDataSet.
* @param ds : The dataset to retrieve the field data from
* @param fieldName : The requested field data entry
* @return The value of the requested field data entry
*/
std::string getStringFieldDataValue(vtkDataSet *ds, std::string fieldName)
{
vtkAbstractArray *value = ds->GetFieldData()->GetAbstractArray(fieldName.c_str());
vtkStringArray *array = vtkStringArray::SafeDownCast(value);
return static_cast<std::string>(array->GetValue(0));
}

} // namespace

#endif

0 comments on commit 7d7290d

Please sign in to comment.