From 74a8a673cb1b2bcff0ffe0acadcad122e4be086e Mon Sep 17 00:00:00 2001 From: Applin Date: Fri, 20 Sep 2024 13:27:01 +0100 Subject: [PATCH] Update Spectroscopy test suites --- qt/widgets/common/src/UserInputValidator.cpp | 1 + .../test/DataValidationHelperTest.h | 42 +++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/qt/widgets/common/src/UserInputValidator.cpp b/qt/widgets/common/src/UserInputValidator.cpp index b42be880d393..2db5df7772bf 100644 --- a/qt/widgets/common/src/UserInputValidator.cpp +++ b/qt/widgets/common/src/UserInputValidator.cpp @@ -139,6 +139,7 @@ bool UserInputValidator::checkFileFinderWidgetIsValid(const QString &name, const * @param name :: the "name" of the widget so as to be recognised by the user. * @param widget :: the widget to check * @param silent True if an error should not be added to the validator. + * @param autoLoad True if the data should be reloaded if it is not in the ADS. * @returns True if the input was valid */ bool UserInputValidator::checkDataSelectorIsValid(const QString &name, DataSelector *widget, bool const silent, diff --git a/qt/widgets/spectroscopy/test/DataValidationHelperTest.h b/qt/widgets/spectroscopy/test/DataValidationHelperTest.h index cc148f2b2b6b..46d5ff96a40a 100644 --- a/qt/widgets/spectroscopy/test/DataValidationHelperTest.h +++ b/qt/widgets/spectroscopy/test/DataValidationHelperTest.h @@ -61,8 +61,8 @@ GNU_DIAG_OFF_SUGGEST_OVERRIDE class MockDataSelector : public DataSelector { public: /// Public Methods - MOCK_CONST_METHOD0(getCurrentDataName, QString()); - MOCK_METHOD0(isValid, bool()); + MOCK_CONST_METHOD1(getCurrentDataName, QString(bool const)); + MOCK_METHOD1(isValid, bool(bool const)); }; GNU_DIAG_ON_SUGGEST_OVERRIDE @@ -193,54 +193,54 @@ class DataValidationHelperTest : public CxxTest::TestSuite { private: template void assertTheDataIsCheckedOneTime(Functor const &functor, DataType const &primaryType) { - ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME))); - ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true)); + ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME))); + ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true)); - EXPECT_CALL(*m_dataSelector, getCurrentDataName()).Times(1); - EXPECT_CALL(*m_dataSelector, isValid()).Times(1); + EXPECT_CALL(*m_dataSelector, getCurrentDataName(true)).Times(1); + EXPECT_CALL(*m_dataSelector, isValid(true)).Times(1); - (void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, false); + (void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, false, true); } template void assertTheDataIsCheckedNTimes(Functor const &functor, int nTimes, DataType const &primaryType, std::vector const &otherTypes) { - ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME))); - ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true)); + ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME))); + ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true)); - EXPECT_CALL(*m_dataSelector, getCurrentDataName()).Times(nTimes); - EXPECT_CALL(*m_dataSelector, isValid()).Times(nTimes); + EXPECT_CALL(*m_dataSelector, getCurrentDataName(true)).Times(nTimes); + EXPECT_CALL(*m_dataSelector, isValid(true)).Times(nTimes); - (void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, otherTypes, false); + (void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, otherTypes, false, true); } template void assertThatTheDataIsValid(std::string const &workspaceName, std::string const &errorLabel, Functor const &functor) { - ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(workspaceName))); - ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true)); + ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(workspaceName))); + ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true)); - TS_ASSERT(functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false)); + TS_ASSERT(functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false, true)); TS_ASSERT(m_uiv->generateErrorMessage().empty()); } template void assertThatTheDataIsInvalid(std::string const &workspaceName, std::string const &errorLabel, Functor const &functor) { - ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(workspaceName))); - ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true)); + ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(workspaceName))); + ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true)); - TS_ASSERT(!functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false)); + TS_ASSERT(!functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false, true)); TS_ASSERT(!m_uiv->generateErrorMessage().empty()); } template void assertErrorMessage(std::string const &workspaceName, std::string const &errorLabel, Functor const &functor, std::string const &errorMessage) { - ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(workspaceName))); - ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true)); + ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(workspaceName))); + ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true)); - (void)functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false); + (void)functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false, true); TS_ASSERT_EQUALS(m_uiv->generateErrorMessage(), errorMessage); }