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
c1032547
Commit
c1032547
authored
Jan 10, 2020
by
Anthony Lim
Browse files
refs #26878 Basic ALFView tests
parent
5f253098
Changes
7
Hide whitespace changes
Inline
Side-by-side
qt/scientific_interfaces/Direct/ALFCustomInstrumentModel.cpp
View file @
c1032547
...
...
@@ -56,7 +56,7 @@ ALFCustomInstrumentModel::loadData(const std::string &name) {
m_numberOfTubesInAverage
=
0
;
}
else
{
// reset to the previous data
message
=
"Not the corrct instrument, expected "
+
m_instrumentName
;
message
=
"Not the corr
e
ct instrument, expected "
+
m_instrumentName
;
remove
();
}
if
(
bools
[
"IsValidInstrument"
]
&&
!
bools
[
"IsItDSpace"
])
{
...
...
qt/scientific_interfaces/Direct/ALFCustomInstrumentModel.h
View file @
c1032547
...
...
@@ -16,7 +16,7 @@
namespace
MantidQt
{
namespace
CustomInterfaces
{
class
ALFCustomInstrumentModel
class
DLLExport
ALFCustomInstrumentModel
:
public
MantidWidgets
::
BaseCustomInstrumentModel
{
public:
...
...
qt/scientific_interfaces/Direct/ALFCustomInstrumentPresenter.h
View file @
c1032547
...
...
@@ -19,7 +19,7 @@
namespace
MantidQt
{
namespace
CustomInterfaces
{
class
MANTIDQT_DIRECT_DLL
ALFCustomInstrumentPresenter
class
MANTIDQT_DIRECT_DLL
ALFCustomInstrumentPresenter
:
public
MantidWidgets
::
BaseCustomInstrumentPresenter
{
Q_OBJECT
...
...
qt/scientific_interfaces/Direct/CMakeLists.txt
View file @
c1032547
...
...
@@ -83,4 +83,4 @@ mtd_add_qt_library(TARGET_NAME MantidScientificInterfacesDirect
LINUX_INSTALL_RPATH
"
\$
ORIGIN/../../
${
LIB_DIR
}
;
\$
ORIGIN/../../plugins/qt5/"
)
# Testing target
#
add_subdirectory(test)
add_subdirectory
(
test
)
qt/scientific_interfaces/Direct/test/ALFCustomInstrumentModelTest.h
0 → 100644
View file @
c1032547
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_ALFCUSTOMINSTRUMENTMODELTEST_H_
#define MANTIDQT_ALFCUSTOMINSTRUMENTMODELTEST_H_
#include
<cxxtest/TestSuite.h>
#include
"ALFCustomInstrumentModel.h"
#include
"MantidAPI/AlgorithmManager.h"
#include
"MantidAPI/AnalysisDataService.h"
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/MatrixWorkspace_fwd.h"
#include
<string>
#include
<utility>
using
namespace
Mantid
::
API
;
using
namespace
MantidQt
::
CustomInterfaces
;
namespace
{
const
std
::
string
notALFFile
=
"ZOOM00006113.nxs"
;
}
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
();
}
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
();
}
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");
}
void
test_loadDataNotALF
(){
std
::
pair
<
int
,
std
::
string
>
loadResult
=
m_model
->
loadData
(
notALFFile
);
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");
}
void
test_isDataValid
(){
return
;
}
void
test_isDataValidNotALF
(){
auto
alg
=
AlgorithmManager
::
Instance
().
create
(
"Load"
);
alg
->
initialize
();
alg
->
setProperty
(
"Filename"
,
notALFFile
);
alg
->
setProperty
(
"OutputWorkspace"
,
"ALF_tmp"
);
alg
->
execute
();
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_isDataValidDSpace
(){
return
;
}
void
test_transformData
(){
return
;
}
void
test_storeSingleTube
(){
return
;
}
void
test_averageTube
(){
return
;
}
void
test_hasTubeBeenExtracted
(){
return
;
}
void
test_extractTubeCondition
(){
return
;
}
void
test_extractTubeConditionNotTube
(){
return
;
}
void
test_extractTubeConditionNoPlot
(){
return
;
}
void
test_averageTubeCondition
(){
return
;
}
void
test_averageTubeConditionNotTube
(){
return
;
}
void
test_averageTubeConditionNoPlot
(){
return
;
}
void
test_averageTubeConditionNothingToAverage
(){
return
;
}
void
test_defaultFunction
(){
return
;
}
private:
ALFCustomInstrumentModel
*
m_model
;
};
#endif
/* MANTIDQT_ALFCUSTOMINSTRUMENTMODELTEST_H_ */
qt/scientific_interfaces/Direct/test/ALFCustomInstrumentPresenterTest.h
0 → 100644
View file @
c1032547
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_ALFCUSTOMINSTRUMENTPRESENTERTEST_H_
#define MANTIDQT_ALFCUSTOMINSTRUMENTPRESENTERTEST_H_
#include
<cxxtest/TestSuite.h>
#include
"ALFCustomInstrumentModel.h"
#include
"MantidAPI/AnalysisDataService.h"
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/MatrixWorkspace_fwd.h"
using
namespace
Mantid
::
API
;
using
namespace
MantidQt
::
CustomInterfaces
;
// need to add mock objects..
class
ALFCustomInstrumentPresenterTest
:
public
CxxTest
::
TestSuite
{
public:
/// WorkflowAlgorithms do not appear in the FrameworkManager without this line
ALFCustomInstrumentPresenterTest
()
{
FrameworkManager
::
Instance
();
}
static
ALFCustomInstrumentPresenterTest
*
createSuite
()
{
return
new
ALFCustomInstrumentPresenterTest
();
}
static
void
destroySuite
(
ALFCustomInstrumentPresenterTest
*
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_view = new ALFCustomInstrumentView("ALF", this);
//m_presenter = new ALFCustomInstrumentPResenter(m_view, m_model);
}
void
tearDown
()
override
{
AnalysisDataService
::
Instance
().
clear
();
delete
m_model
;
//m_ads.reset();
//m_workspace.reset();
//m_model.reset();
}
void
test_that_the_model_is_instantiated_and_can_hold_a_workspace
()
{
return
;
//SpectraLegacy const spectra = DiscontinuousSpectra<std::size_t>("0-1");
//m_model->addWorkspace(m_workspace, spectra);
//TS_ASSERT_EQUALS(m_model->numberOfWorkspaces(), 1);
}
private:
//MatrixWorkspace_sptr m_workspace;
//std::unique_ptr<SetUpADSWithWorkspace> m_ads;
ALFCustomInstrumentModel
*
m_model
;
//ALFCustomInstrumentView *m_view;
//ALFCustomInstrumentPresenter *m_presenter;
};
#endif
/* MANTIDQT_ALFCUSTOMINSTRUMENTPRESENTERTEST_H_ */
qt/scientific_interfaces/Direct/test/CMakeLists.txt
0 → 100644
View file @
c1032547
# Testing
set
(
TEST_FILES
ALFCustomInstrumentModelTest.h
ALFCustomInstrumentPresenterTest.h
)
mtd_add_qt_tests
(
TARGET_NAME MantidQtInterfacesDirectTest
QT_VERSION 4
SRC
${
TEST_FILES
}
INCLUDE_DIRS
../../../../Framework/CurveFitting/inc
../../../../Framework/DataObjects/inc
../../../../Framework/TestHelpers/inc
../
TEST_HELPER_SRCS
../../../../Framework/TestHelpers/src/ComponentCreationHelper.cpp
#../../../../Framework/TestHelpers/src/IndirectFitDataCreationHelper.cpp
../../../../Framework/TestHelpers/src/InstrumentCreationHelper.cpp
../../../../Framework/TestHelpers/src/WorkspaceCreationHelper.cpp
../../../../Framework/TestHelpers/src/TearDownWorld.cpp
#../IndirectDataValidationHelper.cpp
LINK_LIBS
CurveFitting
DataObjects
${
TCMALLOC_LIBRARIES_LINKTIME
}
${
CORE_MANTIDLIBS
}
${
POCO_LIBRARIES
}
${
Boost_LIBRARIES
}
${
PYTHON_LIBRARIES
}
${
OPENGL_gl_LIBRARY
}
${
OPENGL_glu_LIBRARY
}
QT4_LINK_LIBS
Qt4::QtOpenGL
Qwt5
MTD_QT_LINK_LIBS
MantidScientificInterfacesDirect
MantidQtWidgetsCommon
MantidQtWidgetsInstrumentView
MantidQtWidgetsPlotting
PARENT_DEPENDENCIES
GUITests
)
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