Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #9371 View and Presenter basics and Test
The Presenter has been created which assignes a model to a view The view base calss has been written. This is abstract as the actual view we'll be using will be Qt based A test for the presenter has been written
- Loading branch information
1 parent
db979ff
commit 6aa7936
Showing
6 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ReflMainView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef MANTID_CUSTOMINTERFACES_REFLMAINVIEW_H | ||
#define MANTID_CUSTOMINTERFACES_REFLMAINVIEW_H | ||
|
||
#include "MantidAPI/ITableWorkspace.h" | ||
|
||
namespace MantidQt | ||
{ | ||
namespace CustomInterfaces | ||
{ | ||
/** @class ReflMainView | ||
ReflMainView is a | ||
Copyright © 2011-14 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://github.com/mantidproject/mantid>. | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
|
||
class DLLExport ReflMainView | ||
{ | ||
public: | ||
ReflMainView(); | ||
virtual ~ReflMainView(); | ||
virtual void showTable(Mantid::API::ITableWorkspace_sptr model) = 0; | ||
private: | ||
|
||
}; | ||
} | ||
} | ||
#endif |
45 changes: 45 additions & 0 deletions
45
Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ReflMainViewPresenter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef MANTID_CUSTOMINTERFACES_REFLMAINVIEWPRESENTER_H | ||
#define MANTID_CUSTOMINTERFACES_REFLMAINVIEWPRESENTER_H | ||
|
||
#include "MantidAPI/ITableWorkspace.h" | ||
#include "MantidQtCustomInterfaces/ReflMainView.h" | ||
|
||
namespace MantidQt | ||
{ | ||
namespace CustomInterfaces | ||
{ | ||
/** @class ReflMainViewPresenter | ||
ReflMainViewPresenter is a | ||
Copyright © 2011-14 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://github.com/mantidproject/mantid>. | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport ReflMainViewPresenter | ||
{ | ||
public: | ||
ReflMainViewPresenter(Mantid::API::ITableWorkspace_sptr model, ReflMainView* view); | ||
~ReflMainViewPresenter(); | ||
private: | ||
|
||
}; | ||
} | ||
} | ||
#endif |
17 changes: 17 additions & 0 deletions
17
Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainView.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "MantidQtCustomInterfaces/ReflMainView.h" | ||
#include "MantidAPI/ITableWorkspace.h" | ||
|
||
namespace MantidQt | ||
{ | ||
namespace CustomInterfaces | ||
{ | ||
|
||
ReflMainView::ReflMainView() | ||
{ | ||
} | ||
|
||
ReflMainView::~ReflMainView() | ||
{ | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainViewPresenter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "MantidQtCustomInterfaces/ReflMainViewPresenter.h" | ||
#include "MantidAPI/ITableWorkspace.h" | ||
#include "MantidQtCustomInterfaces/ReflMainView.h" | ||
|
||
namespace MantidQt | ||
{ | ||
namespace CustomInterfaces | ||
{ | ||
|
||
ReflMainViewPresenter::ReflMainViewPresenter(Mantid::API::ITableWorkspace_sptr model, ReflMainView* view) | ||
{ | ||
view->showTable(model); | ||
} | ||
|
||
ReflMainViewPresenter::~ReflMainViewPresenter() | ||
{ | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
Code/Mantid/MantidQt/CustomInterfaces/test/ReflMainViewPresenterTest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef CUSTOM_INTERFACES_REFLMAINVIEWPRESENTER_TEST_H_ | ||
#define CUSTOM_INTERFACES_REFLMAINVIEWPRESENTER_TEST_H_ | ||
|
||
#include <cxxtest/TestSuite.h> | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
#include <boost/make_shared.hpp> | ||
#include "MantidDataObjects/TableWorkspace.h" | ||
#include "MantidAPI/ITableWorkspace.h" | ||
#include "MantidQtCustomInterfaces/ReflMainView.h" | ||
#include "MantidQtCustomInterfaces/ReflMainViewPresenter.h" | ||
|
||
using namespace MantidQt::CustomInterfaces; | ||
using namespace testing; | ||
|
||
//===================================================================================== | ||
// Functional tests | ||
//===================================================================================== | ||
class ReflMainViewPresenterTest : public CxxTest::TestSuite | ||
{ | ||
|
||
private: | ||
|
||
class MockView : public ReflMainView | ||
{ | ||
public: | ||
MockView(){}; | ||
MOCK_METHOD1(showTable, void(Mantid::API::ITableWorkspace_sptr)); | ||
virtual ~MockView(){} | ||
}; | ||
|
||
public: | ||
|
||
void testShowModel() | ||
{ | ||
MockView mockView; | ||
EXPECT_CALL(mockView, showTable(_)).Times(1); | ||
ReflMainViewPresenter presenter(boost::make_shared<Mantid::DataObjects::TableWorkspace>(),&mockView); | ||
TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); | ||
} | ||
}; | ||
#endif |