Commit d58c6172 authored by Anthony Lim's avatar Anthony Lim
Browse files

refs #26878 Basic ALFView tests

parent ecd23e81
......@@ -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 correct instrument, expected " + m_instrumentName;
remove();
}
if (bools["IsValidInstrument"] && !bools["IsItDSpace"]) {
......
......@@ -17,7 +17,7 @@
namespace MantidQt {
namespace CustomInterfaces {
class ALFCustomInstrumentModel
class DLLExport ALFCustomInstrumentModel
: public MantidWidgets::BaseCustomInstrumentModel {
public:
......
......@@ -20,7 +20,7 @@
namespace MantidQt {
namespace CustomInterfaces {
class MANTIDQT_DIRECT_DLL ALFCustomInstrumentPresenter
class MANTIDQT_DIRECT_DLL ALFCustomInstrumentPresenter
: public MantidWidgets::BaseCustomInstrumentPresenter {
Q_OBJECT
......
......@@ -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)
// 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_ */
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 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_ */
# 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)
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