Skip to content

Commit 74a8a67

Browse files
committed
Update Spectroscopy test suites
1 parent 71301ea commit 74a8a67

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

qt/widgets/common/src/UserInputValidator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ bool UserInputValidator::checkFileFinderWidgetIsValid(const QString &name, const
139139
* @param name :: the "name" of the widget so as to be recognised by the user.
140140
* @param widget :: the widget to check
141141
* @param silent True if an error should not be added to the validator.
142+
* @param autoLoad True if the data should be reloaded if it is not in the ADS.
142143
* @returns True if the input was valid
143144
*/
144145
bool UserInputValidator::checkDataSelectorIsValid(const QString &name, DataSelector *widget, bool const silent,

qt/widgets/spectroscopy/test/DataValidationHelperTest.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ GNU_DIAG_OFF_SUGGEST_OVERRIDE
6161
class MockDataSelector : public DataSelector {
6262
public:
6363
/// Public Methods
64-
MOCK_CONST_METHOD0(getCurrentDataName, QString());
65-
MOCK_METHOD0(isValid, bool());
64+
MOCK_CONST_METHOD1(getCurrentDataName, QString(bool const));
65+
MOCK_METHOD1(isValid, bool(bool const));
6666
};
6767

6868
GNU_DIAG_ON_SUGGEST_OVERRIDE
@@ -193,54 +193,54 @@ class DataValidationHelperTest : public CxxTest::TestSuite {
193193

194194
private:
195195
template <typename Functor> void assertTheDataIsCheckedOneTime(Functor const &functor, DataType const &primaryType) {
196-
ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME)));
197-
ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true));
196+
ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME)));
197+
ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true));
198198

199-
EXPECT_CALL(*m_dataSelector, getCurrentDataName()).Times(1);
200-
EXPECT_CALL(*m_dataSelector, isValid()).Times(1);
199+
EXPECT_CALL(*m_dataSelector, getCurrentDataName(true)).Times(1);
200+
EXPECT_CALL(*m_dataSelector, isValid(true)).Times(1);
201201

202-
(void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, false);
202+
(void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, false, true);
203203
}
204204

205205
template <typename Functor>
206206
void assertTheDataIsCheckedNTimes(Functor const &functor, int nTimes, DataType const &primaryType,
207207
std::vector<DataType> const &otherTypes) {
208-
ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME)));
209-
ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true));
208+
ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(WORKSPACE_NAME)));
209+
ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true));
210210

211-
EXPECT_CALL(*m_dataSelector, getCurrentDataName()).Times(nTimes);
212-
EXPECT_CALL(*m_dataSelector, isValid()).Times(nTimes);
211+
EXPECT_CALL(*m_dataSelector, getCurrentDataName(true)).Times(nTimes);
212+
EXPECT_CALL(*m_dataSelector, isValid(true)).Times(nTimes);
213213

214-
(void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, otherTypes, false);
214+
(void)functor(m_uiv.get(), m_dataSelector.get(), ERROR_LABEL, primaryType, otherTypes, false, true);
215215
}
216216

217217
template <typename Functor>
218218
void assertThatTheDataIsValid(std::string const &workspaceName, std::string const &errorLabel,
219219
Functor const &functor) {
220-
ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(workspaceName)));
221-
ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true));
220+
ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(workspaceName)));
221+
ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true));
222222

223-
TS_ASSERT(functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false));
223+
TS_ASSERT(functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false, true));
224224
TS_ASSERT(m_uiv->generateErrorMessage().empty());
225225
}
226226

227227
template <typename Functor>
228228
void assertThatTheDataIsInvalid(std::string const &workspaceName, std::string const &errorLabel,
229229
Functor const &functor) {
230-
ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(workspaceName)));
231-
ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true));
230+
ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(workspaceName)));
231+
ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true));
232232

233-
TS_ASSERT(!functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false));
233+
TS_ASSERT(!functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false, true));
234234
TS_ASSERT(!m_uiv->generateErrorMessage().empty());
235235
}
236236

237237
template <typename Functor>
238238
void assertErrorMessage(std::string const &workspaceName, std::string const &errorLabel, Functor const &functor,
239239
std::string const &errorMessage) {
240-
ON_CALL(*m_dataSelector, getCurrentDataName()).WillByDefault(Return(QString::fromStdString(workspaceName)));
241-
ON_CALL(*m_dataSelector, isValid()).WillByDefault(Return(true));
240+
ON_CALL(*m_dataSelector, getCurrentDataName(true)).WillByDefault(Return(QString::fromStdString(workspaceName)));
241+
ON_CALL(*m_dataSelector, isValid(true)).WillByDefault(Return(true));
242242

243-
(void)functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false);
243+
(void)functor(m_uiv.get(), m_dataSelector.get(), errorLabel, false, true);
244244

245245
TS_ASSERT_EQUALS(m_uiv->generateErrorMessage(), errorMessage);
246246
}

0 commit comments

Comments
 (0)