ALFCustomInstrumentPresenterTest.h 3.7 KB
Newer Older
Anthony Lim's avatar
Anthony Lim committed
1
2
3
4
5
6
7
8
9
10
// 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>
11
#include <gmock/gmock.h>
Anthony Lim's avatar
Anthony Lim committed
12
13

#include "ALFCustomInstrumentModel.h"
14
15
16
17
18
#include "ALFCustomInstrumentView.h"
#include "ALFCustomInstrumentPresenter.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPanePresenter.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h"
Anthony Lim's avatar
Anthony Lim committed
19

20
#include "MantidAPI/AlgorithmManager.h"
Anthony Lim's avatar
Anthony Lim committed
21
22
23
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/MatrixWorkspace_fwd.h"
24
25
26
27
28
29
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidGeometry/Instrument.h"


#include <string>
#include <utility>
Anthony Lim's avatar
Anthony Lim committed
30
31
32

using namespace Mantid::API;
using namespace MantidQt::CustomInterfaces;
33
34
35
using namespace testing;
using Mantid::Geometry::Instrument;

Anthony Lim's avatar
Anthony Lim committed
36
37

// need to add mock objects..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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(){};
};
Anthony Lim's avatar
Anthony Lim committed
63
64
65
66
67
68
69
70
71
72
73
74
75

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);
76
77
78
79
80
81
 // 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);
Anthony Lim's avatar
Anthony Lim committed
82
83
84
85
  }

  void tearDown() override {
    AnalysisDataService::Instance().clear();
86
87
88
89
    //delete m_model;
    //delete m_view;
    //delete m_presenter;
    //delete m_pane;
Anthony Lim's avatar
Anthony Lim committed
90
91
92
93
94
95
96
97
98
99
100
101
    //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);
  }
102
103
104
105
106
  void test_extractSingleTube(){
 // m_presenter->extractSingleTube();
  //EXPECT_CALL(*m_model, averageTube()).Times(1);
}

Anthony Lim's avatar
Anthony Lim committed
107
108
109
private:
  //MatrixWorkspace_sptr m_workspace;
  //std::unique_ptr<SetUpADSWithWorkspace> m_ads;
110
111
112
  ALFModelTest *m_model;
  ALFViewTest *m_view;
  paneTest *m_pane;
Anthony Lim's avatar
Anthony Lim committed
113
  //ALFCustomInstrumentView *m_view;
114
  ALFCustomInstrumentPresenter *m_presenter;
Anthony Lim's avatar
Anthony Lim committed
115
116
117
};

#endif /* MANTIDQT_ALFCUSTOMINSTRUMENTPRESENTERTEST_H_ */