Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
d70eb89c
Commit
d70eb89c
authored
Feb 04, 2020
by
Anthony Lim
Browse files
refs #26878 ALF view model tests completed
parent
c1032547
Changes
6
Hide whitespace changes
Inline
Side-by-side
qt/scientific_interfaces/Direct/ALFCustomInstrumentModel.cpp
View file @
d70eb89c
...
...
@@ -34,18 +34,26 @@ ALFCustomInstrumentModel::ALFCustomInstrumentModel()
}
/*
* Loads data for use in ALFView
* Loads data, normalise to current and then converts to d spacing
* Runs load data alg
* @param name:: string name for ALF data
* @return std::pair<int,std::string>:: the run number and status
*/
std
::
pair
<
int
,
std
::
string
>
ALFCustomInstrumentModel
::
loadData
(
const
std
::
string
&
name
)
{
void
ALFCustomInstrumentModel
::
loadAlg
(
const
std
::
string
&
name
)
{
auto
alg
=
AlgorithmManager
::
Instance
().
create
(
"Load"
);
alg
->
initialize
();
alg
->
setProperty
(
"Filename"
,
name
);
alg
->
setProperty
(
"OutputWorkspace"
,
m_tmpName
);
// write to tmp ws
alg
->
execute
();
}
/*
* Loads data for use in ALFView
* Loads data, normalise to current and then converts to d spacing
* @param name:: string name for ALF data
* @return std::pair<int,std::string>:: the run number and status
*/
std
::
pair
<
int
,
std
::
string
>
ALFCustomInstrumentModel
::
loadData
(
const
std
::
string
&
name
)
{
loadAlg
(
name
);
auto
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
m_tmpName
);
int
runNumber
=
ws
->
getRunNumber
();
...
...
@@ -73,17 +81,17 @@ std::map<std::string, bool> ALFCustomInstrumentModel::isDataValid() {
auto
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
m_tmpName
);
bool
isItALF
=
false
;
bool
isItDSpace
=
false
;
if
(
ws
->
getInstrument
()
->
getName
()
==
m_instrumentName
)
{
isItALF
=
true
;
}
auto
axis
=
ws
->
getAxis
(
0
);
auto
unit
=
axis
->
unit
()
->
unitID
();
if
(
unit
==
"dSpacing"
)
{
isItDSpace
=
true
;
bool
isItDSpace
=
true
;
if
(
unit
!=
"dSpacing"
){
isItDSpace
=
false
;
}
return
{{
"IsValidInstrument"
,
isItALF
},
{
"IsItDSpace"
,
isItDSpace
}};
return
{{
"IsValidInstrument"
,
isItALF
},
{
"IsItDSpace"
,
isItDSpace
}
,
{
unit
,
true
}
};
}
/*
...
...
qt/scientific_interfaces/Direct/ALFCustomInstrumentModel.h
View file @
d70eb89c
...
...
@@ -22,9 +22,11 @@ class DLLExport ALFCustomInstrumentModel
public:
ALFCustomInstrumentModel
();
virtual
~
ALFCustomInstrumentModel
(){};
// virtual so we can patch them later
virtual
void
loadAlg
(
const
std
::
string
&
name
);
virtual
void
transformData
();
std
::
pair
<
int
,
std
::
string
>
loadData
(
const
std
::
string
&
name
)
override
;
std
::
map
<
std
::
string
,
bool
>
isDataValid
();
void
transformData
();
void
storeSingleTube
(
const
std
::
string
&
name
);
void
averageTube
();
bool
hasTubeBeenExtracted
(
const
std
::
string
&
name
);
...
...
qt/scientific_interfaces/Direct/ALFCustomInstrumentPresenter.h
View file @
d70eb89c
...
...
@@ -40,13 +40,13 @@ protected:
void
loadSideEffects
()
override
;
std
::
pair
<
instrumentSetUp
,
instrumentObserverOptions
>
setupALFInstrument
();
private:
public:
void
setUpInstrumentAnalysisSplitter
()
override
;
void
extractSingleTube
();
void
averageTube
();
private:
ALFCustomInstrumentView
*
m_view
;
ALFCustomInstrumentModel
*
m_model
;
MantidWidgets
::
PlotFitAnalysisPanePresenter
*
m_analysisPane
;
...
...
qt/scientific_interfaces/Direct/test/ALFCustomInstrumentModelTest.h
View file @
d70eb89c
...
...
@@ -8,26 +8,69 @@
#define MANTIDQT_ALFCUSTOMINSTRUMENTMODELTEST_H_
#include
<cxxtest/TestSuite.h>
#include
<gmock/gmock.h>
#include
"ALFCustomInstrumentModel.h"
#include
"MantidAPI/AlgorithmManager.h"
#include
"MantidAPI/AnalysisDataService.h"
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/MatrixWorkspace_fwd.h"
#include
"MantidTestHelpers/WorkspaceCreationHelper.h"
#include
"MantidGeometry/Instrument.h"
#include
"MantidAPI/NumericAxis.h"
#include
<string>
#include
<utility>
using
namespace
Mantid
::
API
;
using
namespace
MantidQt
::
CustomInterfaces
;
using
namespace
testing
;
using
Mantid
::
Geometry
::
Instrument
;
namespace
{
const
std
::
string
notALFFile
=
"ZOOM00006113.nxs"
;
}
class
ALFModelTest
:
public
ALFCustomInstrumentModel
{
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
;};
int
getLoadCount
(){
return
m_loadCount
;};
int
getTransformCount
(){
return
m_transformCount
;};
private:
int
m_loadCount
;
int
m_transformCount
;
};
class
mockData
{
public:
mockData
(
const
std
::
string
&
name
,
const
std
::
string
&
instName
,
const
int
&
run
,
const
bool
TOF
)
:
m_name
(
name
){
std
::
set
<
long
int
>
masks
;
auto
ws
=
WorkspaceCreationHelper
::
create2DWorkspaceWithValuesAndXerror
(
1
,
10
,
false
,
0.1
,
0.2
,
0.01
,
0.3
,
masks
);
//set instrument
boost
::
shared_ptr
<
Instrument
>
inst
=
boost
::
make_shared
<
Instrument
>
();
inst
->
setName
(
instName
);
//set run
ws
->
mutableRun
().
addProperty
(
"run_number"
,
run
,
true
);
// set units
ws
->
setInstrument
(
inst
);
auto
axis
=
ws
->
getAxis
(
0
);
if
(
TOF
){
axis
->
setUnit
(
"TOF"
);}
else
{
axis
->
setUnit
(
"dSpacing"
);}
AnalysisDataService
::
Instance
().
addOrReplace
(
m_name
,
ws
);
}
~
mockData
(){
AnalysisDataService
::
Instance
().
remove
(
m_name
);
}
private:
std
::
string
m_name
;
};
class
ALFCustomInstrumentModelTest
:
public
CxxTest
::
TestSuite
{
public:
/// WorkflowAlgorithms do not appear in the FrameworkManager without this line
ALFCustomInstrumentModelTest
()
{
FrameworkManager
::
Instance
();
}
static
ALFCustomInstrumentModelTest
*
createSuite
()
{
return
new
ALFCustomInstrumentModelTest
();
}
...
...
@@ -35,59 +78,70 @@ public:
static
void
destroySuite
(
ALFCustomInstrumentModelTest
*
suite
)
{
delete
suite
;
}
void
setUp
()
override
{
//m_workspace = createWorkspace(4, 3);
//m_ads = std::make_unique<SetUpADSWithWorkspace>("Name", m_workspace);
m_model
=
new
ALFCustomInstrumentModel
();
m_model
=
new
ALFModelTest
();
}
void
tearDown
()
override
{
AnalysisDataService
::
Instance
().
clear
();
delete
m_model
;
//m_ads.reset();
//m_workspace.reset();
//m_model.reset();
}
void
test_loadData
()
{
return
;
//auto loadResult = m_model->loadData("ALF");
//TS_ASSERT_EQUALS(loadResult.first, 1);
//TS_ASSERT_EQUALS(loadResult.second, "success");
auto
data
=
mockData
(
"ALF_tmp"
,
"ALF"
,
6113
,
true
);
TS_ASSERT_EQUALS
(
m_model
->
getLoadCount
(),
0
);
std
::
pair
<
int
,
std
::
string
>
loadResult
=
m_model
->
loadData
(
notALFFile
);
TS_ASSERT_EQUALS
(
m_model
->
getLoadCount
(),
1
);
TS_ASSERT_EQUALS
(
m_model
->
getTransformCount
(),
1
);
TS_ASSERT_EQUALS
(
loadResult
.
first
,
6113
);
TS_ASSERT_EQUALS
(
loadResult
.
second
,
"success"
);
}
void
test_loadDataNotALF
(){
std
::
pair
<
int
,
std
::
string
>
loadResult
=
m_model
->
loadData
(
notALFFile
);
auto
data
=
mockData
(
"ALF_tmp"
,
"EMU"
,
6113
,
true
);
TS_ASSERT_EQUALS
(
m_model
->
getLoadCount
(),
0
);
std
::
pair
<
int
,
std
::
string
>
loadResult
=
m_model
->
loadData
(
notALFFile
);
TS_ASSERT_EQUALS
(
m_model
->
getLoadCount
(),
1
);
TS_ASSERT_EQUALS
(
m_model
->
getTransformCount
(),
0
);
TS_ASSERT_EQUALS
(
loadResult
.
first
,
6113
);
TS_ASSERT_EQUALS
(
loadResult
.
second
,
"Not the correct instrument, expected ALF"
);
}
void
test_loadDataDSpace
(){
//auto loadResult = m_model->loadData("ALF");
//TS_ASSERT_EQUALS(loadResult.first, 1);
//TS_ASSERT_EQUALS(loadResult.second, "success");
}
auto
data
=
mockData
(
"ALF_tmp"
,
"ALF"
,
6113
,
false
);
TS_ASSERT_EQUALS
(
m_model
->
getLoadCount
(),
0
);
void
test_isDataValid
(){
return
;
std
::
pair
<
int
,
std
::
string
>
loadResult
=
m_model
->
loadData
(
notALFFile
);
TS_ASSERT_EQUALS
(
m_model
->
getLoadCount
(),
1
);
TS_ASSERT_EQUALS
(
m_model
->
getTransformCount
(),
0
);
TS_ASSERT_EQUALS
(
loadResult
.
first
,
6113
);
TS_ASSERT_EQUALS
(
loadResult
.
second
,
"success"
);
}
void
test_isDataValid
NotALF
(){
auto
alg
=
AlgorithmManager
::
Instance
().
create
(
"Load"
);
alg
->
initi
ali
ze
();
alg
->
setProperty
(
"Filename"
,
notALFFile
);
alg
->
setProperty
(
"OutputWorkspace"
,
"ALF_tmp"
);
alg
->
execute
();
void
test_isDataValid
(){
auto
data
=
mockData
(
"ALF_tmp"
,
"ALF"
,
6113
,
true
);
std
::
map
<
std
::
string
,
bool
>
isDataValid
=
m_model
->
isDataV
ali
d
();
TS_ASSERT
(
isDataValid
[
"IsValidInstrument"
])
TS_ASSERT
(
!
isDataValid
[
"IsItDSpace"
])
std
::
map
<
std
::
string
,
bool
>
result
=
m_model
->
isDataValid
();
TS_ASSERT
(
!
result
[
"IsValidInstrument"
])
TS_ASSERT
(
!
result
[
"IsItDspace"
])
// clean up
AnalysisDataService
::
Instance
().
remove
(
"ALF_tmp"
);
}
void
test_isDataValidNotALF
(){
auto
data
=
mockData
(
"ALF_tmp"
,
"EMU"
,
6113
,
true
);
std
::
map
<
std
::
string
,
bool
>
isDataValid
=
m_model
->
isDataValid
();
TS_ASSERT
(
!
isDataValid
[
"IsValidInstrument"
])
TS_ASSERT
(
!
isDataValid
[
"IsItDSpace"
])
}
void
test_isDataValidDSpace
(){
return
;
auto
data
=
mockData
(
"ALF_tmp"
,
"ALF"
,
6113
,
false
);
std
::
map
<
std
::
string
,
bool
>
isDataValid
=
m_model
->
isDataValid
();
TS_ASSERT
(
isDataValid
[
"IsValidInstrument"
]);
TS_ASSERT
(
isDataValid
[
"IsItDSpace"
]);
}
void
test_transformData
(){
...
...
@@ -95,50 +149,180 @@ public:
}
void
test_storeSingleTube
(){
return
;
auto
data
=
mockData
(
"CURVES"
,
"ALF"
,
6113
,
false
);
m_model
->
storeSingleTube
(
"test"
);
auto
outputWS
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
"extractedTubes_test"
);
TS_ASSERT_DELTA
(
outputWS
->
readX
(
0
)[
0
],
-
22.9
,
0.1
);
TS_ASSERT_EQUALS
(
outputWS
->
readY
(
0
)[
0
],
0.2
);
TS_ASSERT_DELTA
(
outputWS
->
readX
(
0
)[
9
],
492.7
,
0.1
);
TS_ASSERT_EQUALS
(
outputWS
->
readY
(
0
)[
9
],
0.2
);
AnalysisDataService
::
Instance
().
remove
(
"extractedTubes_test"
);
}
void
test_averageTube
(){
return
;
int
run
=
6113
;
auto
data
=
mockData
(
"CURVES"
,
"ALF"
,
run
,
false
);
m_model
->
setCurrentRun
(
run
);
m_model
->
extractSingleTube
();
// check original y values
auto
tmpWS
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
"extractedTubes_ALF6113"
);
TS_ASSERT_EQUALS
(
tmpWS
->
readY
(
0
)[
1
],
0.2
);
TS_ASSERT_EQUALS
(
tmpWS
->
readY
(
0
)[
9
],
0.2
);
// create another ws to add
std
::
set
<
long
int
>
masks
;
auto
ws
=
WorkspaceCreationHelper
::
create2DWorkspaceWithValuesAndXerror
(
1
,
10
,
false
,
1.1
,
2.2
,
0.01
,
0.3
,
masks
);
boost
::
shared_ptr
<
Instrument
>
inst
=
boost
::
make_shared
<
Instrument
>
();
inst
->
setName
(
"ALF"
);
ws
->
mutableRun
().
addProperty
(
"run_number"
,
run
,
true
);
ws
->
setInstrument
(
inst
);
auto
axis
=
ws
->
getAxis
(
0
);
axis
->
setUnit
(
"dSpacing"
);
AnalysisDataService
::
Instance
().
addOrReplace
(
"CURVES"
,
ws
);
// check second WS y values
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
1
],
2.2
,
0.001
);
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
9
],
2.2
,
0.001
);
m_model
->
averageTube
();
// check averages: (2.2+0.2)/2 = 2.4/2 = 1.2
auto
outputWS
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
"extractedTubes_ALF6113"
);
TS_ASSERT_DELTA
(
outputWS
->
readX
(
0
)[
1
],
34.4
,
0.1
);
TS_ASSERT_DELTA
(
outputWS
->
readY
(
0
)[
1
],
1.2
,
0.01
);
TS_ASSERT_DELTA
(
outputWS
->
readX
(
0
)[
9
],
492.7
,
0.1
);
TS_ASSERT_DELTA
(
outputWS
->
readY
(
0
)[
9
],
1.2
,
0.01
);
// create another ws to add
auto
ws3
=
WorkspaceCreationHelper
::
create2DWorkspaceWithValuesAndXerror
(
1
,
10
,
false
,
1.1
,
3.2
,
0.01
,
0.3
,
masks
);
inst
=
boost
::
make_shared
<
Instrument
>
();
inst
->
setName
(
"ALF"
);
ws3
->
mutableRun
().
addProperty
(
"run_number"
,
run
,
true
);
ws3
->
setInstrument
(
inst
);
axis
=
ws3
->
getAxis
(
0
);
axis
->
setUnit
(
"dSpacing"
);
AnalysisDataService
::
Instance
().
addOrReplace
(
"CURVES"
,
ws3
);
// check second WS y values
TS_ASSERT_DELTA
(
ws3
->
readY
(
0
)[
1
],
3.2
,
0.001
);
TS_ASSERT_DELTA
(
ws3
->
readY
(
0
)[
9
],
3.2
,
0.001
);
m_model
->
averageTube
();
// check averages: (2.2+0.2+3.2)/2 = 5.6/3 = 1.8666
outputWS
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
"extractedTubes_ALF6113"
);
TS_ASSERT_DELTA
(
outputWS
->
readX
(
0
)[
1
],
34.4
,
0.1
);
TS_ASSERT_DELTA
(
outputWS
->
readY
(
0
)[
1
],
1.86
,
0.01
);
TS_ASSERT_DELTA
(
outputWS
->
readX
(
0
)[
9
],
492.7
,
0.1
);
TS_ASSERT_DELTA
(
outputWS
->
readY
(
0
)[
9
],
1.86
,
0.01
);
AnalysisDataService
::
Instance
().
remove
(
"extractedTubes_ALF6113"
);
}
void
test_hasTubeBeenExtracted
(){
return
;
const
std
::
string
name
=
"test"
;
// not extracted -> false
TS_ASSERT
(
!
m_model
->
hasTubeBeenExtracted
(
name
));
// create data to store
auto
data
=
mockData
(
"CURVES"
,
"ALF"
,
6113
,
false
);
m_model
->
storeSingleTube
(
name
);
// stored data -> true
TS_ASSERT
(
m_model
->
hasTubeBeenExtracted
(
name
));
}
void
test_extractTubeCondition
(){
return
;
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
true
},
{
"hasCurve"
,
true
},{
"isTube"
,
true
}};
TS_ASSERT
(
m_model
->
extractTubeConditon
(
conditions
));
}
void
test_extractTubeConditionNotTube
(){
return
;
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
true
},
{
"hasCurve"
,
true
},{
"isTube"
,
false
}};
TS_ASSERT
(
!
m_model
->
extractTubeConditon
(
conditions
));
}
void
test_extractTubeConditionNoPlot
(){
return
;
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
false
},
{
"hasCurve"
,
true
},{
"isTube"
,
true
}};
TS_ASSERT
(
m_model
->
extractTubeConditon
(
conditions
));
}
void
test_extractTubeConditionNoCurve
(){
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
true
},
{
"hasCurve"
,
false
},{
"isTube"
,
true
}};
TS_ASSERT
(
m_model
->
extractTubeConditon
(
conditions
));
}
void
test_extractTubeConditionNoPlotOrCurve
(){
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
false
},
{
"hasCurve"
,
false
},{
"isTube"
,
true
}};
TS_ASSERT
(
!
m_model
->
extractTubeConditon
(
conditions
));
}
void
test_averageTubeCondition
(){
return
;
}
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
true
},
{
"hasCurve"
,
true
},{
"isTube"
,
true
}};
int
run
=
6113
;
auto
data
=
mockData
(
"CURVES"
,
"ALF"
,
run
,
false
);
m_model
->
setCurrentRun
(
run
);
m_model
->
extractSingleTube
();
TS_ASSERT
(
m_model
->
averageTubeConditon
(
conditions
));
AnalysisDataService
::
Instance
().
remove
(
"extractedTubes_ALF6113"
);
}
void
test_averageTubeConditionNotTube
(){
return
;
}
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
true
},
{
"hasCurve"
,
true
},{
"isTube"
,
false
}};
int
run
=
6113
;
auto
data
=
mockData
(
"CURVES"
,
"ALF"
,
run
,
false
);
m_model
->
setCurrentRun
(
run
);
m_model
->
extractSingleTube
();
TS_ASSERT
(
!
m_model
->
averageTubeConditon
(
conditions
));
AnalysisDataService
::
Instance
().
remove
(
"extractedTubes_ALF6113"
);
}
void
test_averageTubeConditionNoPlot
(){
return
;
}
void
test_averageTubeConditionNothingToAverage
(){
return
;
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
false
},
{
"hasCurve"
,
false
},{
"isTube"
,
true
}};
int
run
=
6113
;
auto
data
=
mockData
(
"CURVES"
,
"ALF"
,
run
,
false
);
m_model
->
setCurrentRun
(
run
);
m_model
->
extractSingleTube
();
TS_ASSERT
(
!
m_model
->
averageTubeConditon
(
conditions
));
AnalysisDataService
::
Instance
().
remove
(
"extractedTubes_ALF6113"
);
}
void
test_defaultFunction
(){
return
;
void
test_averageTubeConditionNothingToAverage
(){
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
true
},
{
"hasCurve"
,
true
},{
"isTube"
,
true
}};
int
run
=
6113
;
// the extraced ws will exist but average will be 0 -> change runs
auto
data
=
mockData
(
"extractedTubes_ALF6113"
,
"ALF"
,
run
,
false
);
m_model
->
setCurrentRun
(
run
);
TS_ASSERT
(
!
m_model
->
averageTubeConditon
(
conditions
));
}
void
test_averageTubeConditionNoWSToAverage
(){
std
::
map
<
std
::
string
,
bool
>
conditions
=
{
{
"plotStored"
,
true
},
{
"hasCurve"
,
true
},{
"isTube"
,
true
}};
int
run
=
6113
;
auto
data
=
mockData
(
"CURVES"
,
"ALF"
,
run
,
false
);
m_model
->
setCurrentRun
(
run
);
m_model
->
extractSingleTube
();
// the extraced ws will not exist but average will be 1
AnalysisDataService
::
Instance
().
remove
(
"extractedTubes_ALF6113"
);
TS_ASSERT
(
!
m_model
->
averageTubeConditon
(
conditions
));
}
void
test_defaultFunction
(){
auto
function
=
m_model
->
getDefaultFunction
();
TS_ASSERT_DELTA
(
function
->
getParameter
(
"f0.A0"
),
0.0
,
0.01
);
TS_ASSERT_DELTA
(
function
->
getParameter
(
"f1.Height"
),
3.0
,
0.01
);
TS_ASSERT_DELTA
(
function
->
getParameter
(
"f1.PeakCentre"
),
0.0
,
0.01
);
TS_ASSERT_DELTA
(
function
->
getParameter
(
"f1.Sigma"
),
1.0
,
0.01
);
}
private:
ALF
CustomInstrument
Model
*
m_model
;
ALFModel
Test
*
m_model
;
};
#endif
/* MANTIDQT_ALFCUSTOMINSTRUMENTMODELTEST_H_ */
qt/scientific_interfaces/Direct/test/ALFCustomInstrumentPresenterTest.h
View file @
d70eb89c
...
...
@@ -8,17 +8,58 @@
#define MANTIDQT_ALFCUSTOMINSTRUMENTPRESENTERTEST_H_
#include
<cxxtest/TestSuite.h>
#include
<gmock/gmock.h>
#include
"ALFCustomInstrumentModel.h"
#include
"ALFCustomInstrumentView.h"
#include
"ALFCustomInstrumentPresenter.h"
#include
"MantidQtWidgets/InstrumentView/PlotFitAnalysisPanePresenter.h"
#include
"MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h"
#include
"MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h"
#include
"MantidAPI/AlgorithmManager.h"
#include
"MantidAPI/AnalysisDataService.h"
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/MatrixWorkspace_fwd.h"
#include
"MantidTestHelpers/WorkspaceCreationHelper.h"
#include
"MantidGeometry/Instrument.h"
#include
<string>
#include
<utility>
using
namespace
Mantid
::
API
;
using
namespace
MantidQt
::
CustomInterfaces
;
using
namespace
testing
;
using
Mantid
::
Geometry
::
Instrument
;
// need to add mock objects..
class
ALFModelTest
:
public
ALFCustomInstrumentModel
{
public:
MOCK_METHOD0
(
extractSingleTube
,
void
());
MOCK_METHOD0
(
averageTube
,
void
());
};
class
ALFViewTest
:
public
ALFCustomInstrumentView
{
public:
MOCK_METHOD1
(
addSpectrum
,
void
(
std
::
string
name
));
};
class
paneTest
:
public
MantidQt
::
MantidWidgets
::
PlotFitAnalysisPanePresenter
{
public:
// define init
//using #mantidQt....;
//paneTest(view, model){};
MOCK_METHOD1
(
addSpectrum
,
void
(
const
std
::
string
&
name
));
};
class
paneViewTest
:
public
MantidQt
::
MantidWidgets
::
PlotFitAnalysisPaneView
{
void
test
(){};
};
class
paneModelTest
:
public
MantidQt
::
MantidWidgets
::
PlotFitAnalysisPaneModel
{
void
empty
(){};
};
class
ALFCustomInstrumentPresenterTest
:
public
CxxTest
::
TestSuite
{
public:
...
...
@@ -32,14 +73,20 @@ public:
void
setUp
()
override
{
//m_workspace = createWorkspace(4, 3);
//m_ads = std::make_unique<SetUpADSWithWorkspace>("Name", m_workspace);
m_model
=
new
ALFCustomInstrumentModel
();
//m_view = new ALFCustomInstrumentView("ALF", this);
//m_presenter = new ALFCustomInstrumentPResenter(m_view, m_model);
// m_model = new NiceMock<ALFModelTest>();
// m_view = new NiceMock<ALFViewTest>();
// auto paneView = new NiceMock<paneViewTest>();
// auto paneModel = new NiceMock<paneModelTest>();
// m_pane = new NiceMock<paneTest>(paneView, paneModel);
// m_presenter = new ALFCustomInstrumentPresenter(m_view, m_model,m_pane);
}
void
tearDown
()
override
{
AnalysisDataService
::
Instance
().
clear
();
delete
m_model
;
//delete m_model;
//delete m_view;
//delete m_presenter;
//delete m_pane;
//m_ads.reset();
//m_workspace.reset();
//m_model.reset();
...
...
@@ -52,12 +99,19 @@ public:
//TS_ASSERT_EQUALS(m_model->numberOfWorkspaces(), 1);
}
void
test_extractSingleTube
(){
// m_presenter->extractSingleTube();
//EXPECT_CALL(*m_model, averageTube()).Times(1);
}
private:
//MatrixWorkspace_sptr m_workspace;
//std::unique_ptr<SetUpADSWithWorkspace> m_ads;
ALFCustomInstrumentModel
*
m_model
;
ALFModelTest
*
m_model
;
ALFViewTest
*
m_view
;
paneTest
*
m_pane
;
//ALFCustomInstrumentView *m_view;
//
ALFCustomInstrumentPresenter *m_presenter;
ALFCustomInstrumentPresenter
*
m_presenter
;
};
#endif
/* MANTIDQT_ALFCUSTOMINSTRUMENTPRESENTERTEST_H_ */
qt/scientific_interfaces/Direct/test/CMakeLists.txt
View file @
d70eb89c
...
...
@@ -25,6 +25,8 @@ mtd_add_qt_tests(
CurveFitting
DataObjects
${
TCMALLOC_LIBRARIES_LINKTIME
}
${
GMOCK_LIBRARIES
}
${
GTEST_LIBRARIES
}
${
CORE_MANTIDLIBS
}
${
POCO_LIBRARIES
}
${
Boost_LIBRARIES
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment