Commit 515e5729 authored by Anthony Lim's avatar Anthony Lim
Browse files

refs #26878 ALF View tests now compile

parent 5cbd3f0f
......@@ -170,7 +170,7 @@ bool ALFCustomInstrumentModel::hasTubeBeenExtracted(const std::string &name) {
return AnalysisDataService::Instance().doesExist(EXTRACTEDWS + name);
}
bool ALFCustomInstrumentModel::extractTubeConditon(
bool ALFCustomInstrumentModel::extractTubeCondition(
std::map<std::string, bool> tabBools) {
try {
......@@ -182,7 +182,7 @@ bool ALFCustomInstrumentModel::extractTubeConditon(
}
}
bool ALFCustomInstrumentModel::averageTubeConditon(
bool ALFCustomInstrumentModel::averageTubeCondition(
std::map<std::string, bool> tabBools) {
try {
......
......@@ -27,16 +27,16 @@ public:
virtual void storeSingleTube(const std::string &name)=0;
virtual void averageTube()=0;
virtual bool hasTubeBeenExtracted(const std::string &name)=0;
virtual bool extractTubeConditon(std::map<std::string, bool> tabBools) = 0;
virtual bool averageTubeConditon(std::map<std::string, bool> tabBools) = 0;
virtual void extractSingleTube() = 0;
virtual std::string WSName() = 0;
virtual Mantid::API::CompositeFunction_sptr getDefaultFunction() = 0;
virtual bool extractTubeCondition(std::map<std::string, bool> tabBools)=0;
virtual bool averageTubeCondition(std::map<std::string, bool> tabBools)=0;
virtual void extractSingleTube()=0;
virtual std::string WSName()=0;
virtual Mantid::API::CompositeFunction_sptr getDefaultFunction()=0;
};
class DLLExport ALFCustomInstrumentModel
: public virtual IALFCustomInstrumentModel{
: public IALFCustomInstrumentModel{
public:
ALFCustomInstrumentModel();
......@@ -49,8 +49,8 @@ public:
void storeSingleTube(const std::string &name) override;
void averageTube() override;
bool hasTubeBeenExtracted(const std::string &name) override;
bool extractTubeConditon(std::map<std::string, bool> tabBools) override;
bool averageTubeConditon(std::map<std::string, bool> tabBools) override;
bool extractTubeCondition(std::map<std::string, bool> tabBools) override;
bool averageTubeCondition(std::map<std::string, bool> tabBools) override;
void extractSingleTube() override;
std::string WSName() override;
Mantid::API::CompositeFunction_sptr getDefaultFunction() override;
......
......@@ -17,7 +17,7 @@ namespace MantidQt {
namespace CustomInterfaces {
ALFCustomInstrumentPresenter::ALFCustomInstrumentPresenter(
IALFCustomInstrumentView *view, ALFCustomInstrumentModel *model,
IALFCustomInstrumentView *view, IALFCustomInstrumentModel *model,
MantidWidgets::IPlotFitAnalysisPanePresenter *analysisPane)
: BaseCustomInstrumentPresenter(view, model, analysisPane),
m_view(view), m_model(model), m_analysisPane(analysisPane),
......@@ -65,14 +65,14 @@ ALFCustomInstrumentPresenter::setupALFInstrument() {
// set up custom context menu conditions
std::function<bool(std::map<std::string, bool>)> extractConditionBinder =
std::bind(&ALFCustomInstrumentModel::extractTubeConditon, m_model,
std::bind(&IALFCustomInstrumentModel::extractTubeCondition, m_model,
std::placeholders::_1);
std::function<bool(std::map<std::string, bool>)> averageTubeConditonBinder =
std::bind(&ALFCustomInstrumentModel::averageTubeConditon, m_model,
std::function<bool(std::map<std::string, bool>)> averageTubeConditionBinder =
std::bind(&IALFCustomInstrumentModel::averageTubeCondition, m_model,
std::placeholders::_1);
binders.emplace_back(extractConditionBinder);
binders.emplace_back(averageTubeConditonBinder);
binders.emplace_back(averageTubeConditionBinder);
setUpContextConditions = std::make_pair(m_model->dataFileName(), binders);
......
......@@ -25,12 +25,11 @@ class MANTIDQT_DIRECT_DLL ALFCustomInstrumentPresenter
public:
ALFCustomInstrumentPresenter(
IALFCustomInstrumentView *view, ALFCustomInstrumentModel *model,
IALFCustomInstrumentView *view, IALFCustomInstrumentModel *model,
MantidWidgets::IPlotFitAnalysisPanePresenter *analysisPane);
~ALFCustomInstrumentPresenter() {
delete m_extractSingleTubeObserver;
delete m_averageTubeObserver;
delete m_model;
m_analysisPane->destructor();
};
......@@ -48,7 +47,7 @@ public:
private:
IALFCustomInstrumentView *m_view;
ALFCustomInstrumentModel *m_model;
IALFCustomInstrumentModel *m_model;
MantidWidgets::IPlotFitAnalysisPanePresenter *m_analysisPane;
VoidObserver *m_extractSingleTubeObserver;
VoidObserver *m_averageTubeObserver;
......
......@@ -31,12 +31,13 @@ namespace{
const std::string notALFFile = "ZOOM00006113.nxs";
}
class ALFModelTest : public ALFCustomInstrumentModel{
class partALFModelTest : public ALFCustomInstrumentModel{
public:
ALFModelTest():m_loadCount(0),m_transformCount(0){};
~ALFModelTest(){};
void loadAlg(const std::string &name) override final {(void) name;m_loadCount+=1;};
void transformData() override final {m_transformCount+=1;};
partALFModelTest():m_loadCount(0),m_transformCount(0){};
virtual ~partALFModelTest(){};
void loadAlg(const std::string &name) override final {(void) name;m_loadCount+=1;};
MOCK_METHOD0(transformData, void());
//void transformData() override final {m_transformCount+=1;};
int getLoadCount(){return m_loadCount;};
int getTransformCount(){return m_transformCount;};
private:
......@@ -78,7 +79,7 @@ public:
static void destroySuite(ALFCustomInstrumentModelTest *suite) { delete suite; }
void setUp() override {
m_model = new ALFModelTest();
m_model = new partALFModelTest();
}
void tearDown() override {
......@@ -238,24 +239,24 @@ public:
void test_extractTubeCondition(){
std::map<std::string, bool> conditions = { {"plotStored", true}, {"hasCurve",true},{"isTube", true}};
TS_ASSERT(m_model->extractTubeConditon(conditions));
TS_ASSERT(m_model->extractTubeCondition(conditions));
}
void test_extractTubeConditionNotTube(){
std::map<std::string, bool> conditions = { {"plotStored", true}, {"hasCurve",true},{"isTube", false}};
TS_ASSERT(!m_model->extractTubeConditon(conditions));
TS_ASSERT(!m_model->extractTubeCondition(conditions));
}
void test_extractTubeConditionNoPlot(){
std::map<std::string, bool> conditions = { {"plotStored", false}, {"hasCurve",true},{"isTube", true}};
TS_ASSERT(m_model->extractTubeConditon(conditions));
TS_ASSERT(m_model->extractTubeCondition(conditions));
}
void test_extractTubeConditionNoCurve(){
std::map<std::string, bool> conditions = { {"plotStored", true}, {"hasCurve",false},{"isTube", true}};
TS_ASSERT(m_model->extractTubeConditon(conditions));
TS_ASSERT(m_model->extractTubeCondition(conditions));
}
void test_extractTubeConditionNoPlotOrCurve(){
std::map<std::string, bool> conditions = { {"plotStored", false}, {"hasCurve",false},{"isTube", true}};
TS_ASSERT(!m_model->extractTubeConditon(conditions));
TS_ASSERT(!m_model->extractTubeCondition(conditions));
}
void test_averageTubeCondition(){
......@@ -265,7 +266,7 @@ public:
m_model->setCurrentRun(run);
m_model->extractSingleTube();
TS_ASSERT(m_model->averageTubeConditon(conditions));
TS_ASSERT(m_model->averageTubeCondition(conditions));
AnalysisDataService::Instance().remove("extractedTubes_ALF6113");
}
void test_averageTubeConditionNotTube(){
......@@ -275,7 +276,7 @@ public:
m_model->setCurrentRun(run);
m_model->extractSingleTube();
TS_ASSERT(!m_model->averageTubeConditon(conditions));
TS_ASSERT(!m_model->averageTubeCondition(conditions));
AnalysisDataService::Instance().remove("extractedTubes_ALF6113");
}
......@@ -286,7 +287,7 @@ public:
m_model->setCurrentRun(run);
m_model->extractSingleTube();
TS_ASSERT(!m_model->averageTubeConditon(conditions));
TS_ASSERT(!m_model->averageTubeCondition(conditions));
AnalysisDataService::Instance().remove("extractedTubes_ALF6113");
}
......@@ -297,7 +298,7 @@ public:
auto data = mockData("extractedTubes_ALF6113","ALF",run,false);
m_model->setCurrentRun(run);
TS_ASSERT(!m_model->averageTubeConditon(conditions));
TS_ASSERT(!m_model->averageTubeCondition(conditions));
}
void test_averageTubeConditionNoWSToAverage(){
......@@ -309,7 +310,7 @@ public:
// the extraced ws will not exist but average will be 1
AnalysisDataService::Instance().remove("extractedTubes_ALF6113");
TS_ASSERT(!m_model->averageTubeConditon(conditions));
TS_ASSERT(!m_model->averageTubeCondition(conditions));
}
void test_defaultFunction(){
......@@ -322,7 +323,7 @@ public:
}
private:
ALFModelTest *m_model;
partALFModelTest *m_model;
};
#endif /* MANTIDQT_ALFCUSTOMINSTRUMENTMODELTEST_H_ */
......@@ -35,38 +35,37 @@ using namespace testing;
using Mantid::Geometry::Instrument;
using namespace MantidQt::MantidWidgets;
class ALFModelTest : public ALFCustomInstrumentModel{
//// need to add mock objects..
class FullALFModelTest : public IALFCustomInstrumentModel{
public:
ALFModelTest():m_loadCount(0),m_transformCount(0){};
~ALFModelTest(){};
void loadAlg(const std::string &name) override{(void) name;m_loadCount+=1;};
void transformData() override {m_transformCount+=1;};
FullALFModelTest(){};
~FullALFModelTest(){};
MOCK_METHOD1(loadAlg, void(const std::string &name));
MOCK_METHOD0(transformData, void());
MOCK_METHOD0(isDataValid, std::map<std::string, bool>());
MOCK_METHOD1(storeSingleTube, void(const std::string &name));
MOCK_METHOD0(averageTube,void());
MOCK_METHOD1(hasTubeBeenExtracted, bool(const std::string &name));
MOCK_METHOD1(extractTubeCondition, bool(std::map<std::string, bool> tabBools));
MOCK_METHOD1(averageTubeCondition, bool(std::map<std::string, bool> tabBools));
MOCK_METHOD0(extractSingleTube, void());
MOCK_METHOD0(averageTube, void());
int getLoadCount(){return m_loadCount;};
int getTransformCount(){return m_transformCount;};
private:
int m_loadCount;
int m_transformCount;
MOCK_METHOD0(WSName, std::string());
MOCK_METHOD0(getDefaultFunction, Mantid::API::CompositeFunction_sptr());
MOCK_METHOD0(loadEmptyInstrument, void());
MOCK_METHOD1(loadData, std::pair<int, std::string>(const std::string &name));
MOCK_METHOD1(setCurrentRun, void(int &run));
MOCK_METHOD0(getCurrentRun, int());
MOCK_METHOD0(rename, void());
MOCK_METHOD0(remove, void());
MOCK_METHOD0(dataFileName, std::string());
MOCK_METHOD0(currentRun, int());
MOCK_METHOD1(isErrorCode, bool(const int run));
MOCK_METHOD0(getInstrument, const std::string());
MOCK_METHOD0(getTmpName, const std::string());
MOCK_METHOD0(getWSName, const std::string());
};
//// need to add mock objects..
//class ALFModelTest : public ALFCustomInstrumentModel{
//public:
// ALFModelTest(){};
// ~ALFModelTest(){};
// MOCK_METHOD1(loadAlg, void(const std::string &name));
// MOCK_METHOD0(TransgormData, void());
// MOCK_METHOD1(loadData,
// MOCK_METHOD1
// MOCK_METHOD1
// MOCK_METHOD1
// MOCK_METHOD1
// MOCK_METHOD0(extractSingleTube, void());
// MOCK_METHOD0(averageTube, void());
//};
//
//class ALFViewTest : public IALFCustomInstrumentView, public IBaseCustomInstrumentView{
class ALFViewTest : public IALFCustomInstrumentView{//, public IBaseCustomInstrumentView{
......@@ -133,7 +132,7 @@ public:
void setUp() override {
//m_workspace = createWorkspace(4, 3);
//m_ads = std::make_unique<SetUpADSWithWorkspace>("Name", m_workspace);
m_model = new NiceMock<ALFModelTest>();
m_model = new NiceMock<FullALFModelTest>();
m_view = new NiceMock<ALFViewTest>("ALF");
m_paneView = new NiceMock<paneViewTest>();
m_paneModel = new NiceMock<paneModelTest>();
......@@ -171,7 +170,7 @@ public:
private:
//MatrixWorkspace_sptr m_workspace;
//std::unique_ptr<SetUpADSWithWorkspace> m_ads;
NiceMock<ALFModelTest> *m_model;
NiceMock<FullALFModelTest> *m_model;
NiceMock<ALFViewTest> *m_view;
NiceMock<paneViewTest> *m_paneView;
NiceMock<paneModelTest> *m_paneModel;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment