Skip to content

Commit

Permalink
Refs #9371 View and Presenter basics and Test
Browse files Browse the repository at this point in the history
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
keithnbrown committed Apr 25, 2014
1 parent db979ff commit 6aa7936
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt
Expand Up @@ -37,6 +37,8 @@ set ( SRC_FILES
src/QtWorkspaceMementoModel.cpp
src/Quasi.cpp
src/RawFileMemento.cpp
src/ReflMainView.cpp
src/ReflMainViewPresenter.cpp
src/ResNorm.cpp
src/SANSAddFiles.cpp
src/SANSDiagnostics.cpp
Expand Down Expand Up @@ -95,6 +97,8 @@ set ( INC_FILES
inc/MantidQtCustomInterfaces/QtWorkspaceMementoModel.h
inc/MantidQtCustomInterfaces/Quasi.h
inc/MantidQtCustomInterfaces/RawFileMemento.h
inc/MantidQtCustomInterfaces/ReflMainView.h
inc/MantidQtCustomInterfaces/ReflMainViewPresenter.h
inc/MantidQtCustomInterfaces/ResNorm.h
inc/MantidQtCustomInterfaces/SANSAddFiles.h
inc/MantidQtCustomInterfaces/SANSDiagnostics.h
Expand Down Expand Up @@ -187,6 +191,7 @@ set( TEST_FILES CreateMDWorkspaceAlgDialogTest.h
WorkspaceInADSTest.h
RawFileMementoTest.h
IO_MuonGroupingTest.h
ReflMainViewPresenterTest.h
)

include_directories ( inc )
Expand Down
@@ -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
@@ -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 &copy; 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 Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainView.cpp
@@ -0,0 +1,17 @@
#include "MantidQtCustomInterfaces/ReflMainView.h"
#include "MantidAPI/ITableWorkspace.h"

namespace MantidQt
{
namespace CustomInterfaces
{

ReflMainView::ReflMainView()
{
}

ReflMainView::~ReflMainView()
{
}
}
}
@@ -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()
{
}
}
}
@@ -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

0 comments on commit 6aa7936

Please sign in to comment.