Skip to content

Commit

Permalink
Refs #6541. Adding SQW loading presenter test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reuter committed Feb 21, 2013
1 parent 6a97be0 commit a158b34
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion Code/Mantid/Vates/VatesAPI/test/SQWLoadingPresenterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,44 @@ void testGetWorkspaceTypeName()
TSM_ASSERT_EQUALS("Characterisation Test Failed", "", presenter.getWorkspaceTypeName());
}

void testAxisLabels()
{
using namespace testing;
//Setup view
MockMDLoadingView* view = new MockMDLoadingView;
EXPECT_CALL(*view, getRecursionDepth()).Times(AtLeast(1));
EXPECT_CALL(*view, getLoadInMemory()).Times(AtLeast(1)).WillRepeatedly(Return(true)); // View setup to request loading in memory.
EXPECT_CALL(*view, getTime()).Times(AtLeast(1));
EXPECT_CALL(*view, updateAlgorithmProgress(_,_)).Times(AnyNumber());

//Setup rendering factory
MockvtkDataSetFactory factory;
EXPECT_CALL(factory, initialize(_)).Times(1);
EXPECT_CALL(factory, create(_)).WillOnce(testing::Return(vtkUnstructuredGrid::New()));
EXPECT_CALL(factory, setRecursionDepth(_)).Times(1);

//Setup progress updates objects
MockProgressAction mockLoadingProgressAction;
MockProgressAction mockDrawingProgressAction;
//Expectation checks that progress should be >= 0 and <= 100 and called at least once!
EXPECT_CALL(mockLoadingProgressAction, eventRaised(AllOf(Le(100),Ge(0)))).Times(AtLeast(1));

//Create the presenter and runit!
SQWLoadingPresenter presenter(view, getSuitableFileNamePath());
presenter.executeLoadMetadata();
vtkDataSet* product = presenter.execute(&factory, mockLoadingProgressAction, mockDrawingProgressAction);
TSM_ASSERT_THROWS_NOTHING("Should pass", presenter.setAxisLabels(product));
TSM_ASSERT_EQUALS("X Label should match exactly",
getStringFieldDataValue(product, "AxisTitleForX"),
"qx (A^-1)");
TSM_ASSERT_EQUALS("Y Label should match exactly",
getStringFieldDataValue(product, "AxisTitleForY"),
"qy (A^-1)");
TSM_ASSERT_EQUALS("Z Label should match exactly",
getStringFieldDataValue(product, "AxisTitleForZ"),
"qz (A^-1)");
}

};

#endif
#endif

0 comments on commit a158b34

Please sign in to comment.