ALCBaselineFittingPresenter inherits from a QObject
robertapplin opened this issue · 0 comments
Describe the outcome that is desired.
The Muon ALC interface is comprised of three pages. Each page as a separate MVP pattern. One of the pages is known as baseline fitting, and uses the classes ALCBaselineFittingView
, ALCBaselineFittingModel
and ALCBaselineFittingPresenter
.
The ALCBaselineFittingPresenter class inherits from a QObject (meaning Qt is being used in the presenter). We do not want the Presenter to use Qt because it makes it difficult to test the presenter and violates the separation of concerns. All Qt code should be isolated to the View.
The Presenter being a QObject suggests that there are signals from the view being connected to slots in the presenter. To avoid making these cross-boundary connections, you can subscribe a non-owning raw pointer of the presenter to the view. The view can then call a method in the presenter whenever an even occurs.
To make it possible to mock the View in our tests for the presenter, we probably want to make use of an interface class. This allows us to swap out the view easily in our tests with a "MockView". It appears the interface class for the view DOES exist, however it inherits from a QObject - which negates the whole point of having an interface class! The interface class for the view should not inherit from a QObject.
Describe any solutions you are considering
We want to remove all Qt code from the Presenter. To do this we should:
- Subscribe the presenter to the view, and use callbacks to the presenter whenever an event occurs
- Use an interface class for the view, so that we can easily mock the view in the future
Testing instructions
You can use the testing instructions in this issue for an overview on how to use the Muon ALC interface:
#25879
Acceptance criteria
- The Presenter contains no Qt code
- The View inherits from an "Interface class" which is NOT a QObject