Commit e85794b7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

implement clear method

parent 47f41e3b
......@@ -51,6 +51,44 @@ void CreatePhishingUrlDataBaseJobTest::initTestcase()
qRegisterMetaType<WebEngineViewer::UpdateDataBaseInfo>();
}
void CreatePhishingUrlDataBaseJobTest::shouldClearUpdateDataBaseInfo()
{
WebEngineViewer::UpdateDataBaseInfo info;
WebEngineViewer::UpdateDataBaseInfo info2;
QCOMPARE(info, info2);
info.clear();
QCOMPARE(info, info2);
WebEngineViewer::UpdateDataBaseInfo value;
QVector<WebEngineViewer::Addition> additionList;
WebEngineViewer::Addition tmp;
tmp.prefixSize = 4;
tmp.hashString = QByteArrayLiteral("rnGLoQ==");
additionList.append(tmp);
QVector<WebEngineViewer::Removal> removalList;
WebEngineViewer::Removal tmpRemoval;
tmpRemoval.indexes = QList<int>() << 0 << 2 << 4;
removalList.append(tmpRemoval);
value.minimumWaitDuration = QStringLiteral("593.440s");
value.threatType = QStringLiteral("MALWARE");
value.threatEntryType = QStringLiteral("URL");
value.responseType = QStringLiteral("PARTIAL_UPDATE");
value.platformType = QStringLiteral("WINDOWS");
value.newClientState = QStringLiteral("ChAIBRADGAEiAzAwMSiAEDABEAFGpqhd");
value.sha256 = QStringLiteral("YSgoRtsRlgHDqDA3LAhM1gegEpEzs1TjzU33vqsR8iM=");
value.additionList = additionList;
value.removalList = removalList;
info = value;
QCOMPARE(info, value);
info2 = info;
QCOMPARE(info, info2);
info2.clear();
info.clear();
QCOMPARE(info, info2);
}
void CreatePhishingUrlDataBaseJobTest::shouldCreateRequest_data()
{
QTest::addColumn<QString>("databasestate");
......
......@@ -35,6 +35,8 @@ private Q_SLOTS:
void shouldParseResult_data();
void shouldParseResult();
void initTestcase();
void shouldClearUpdateDataBaseInfo();
};
#endif // CREATEPHISHINGURLDATABASEJOBTEST_H
......@@ -324,6 +324,20 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
deleteLater();
}
void UpdateDataBaseInfo::clear()
{
additionList.clear();
removalList.clear();
minimumWaitDuration.clear();
threatType.clear();
threatEntryType.clear();
responseType.clear();
platformType.clear();
newClientState.clear();
sha256.clear();
}
bool UpdateDataBaseInfo::operator==(const UpdateDataBaseInfo &other) const {
const bool val = (additionList == other.additionList) &&
(removalList == other.removalList) &&
......
......@@ -67,6 +67,7 @@ struct UpdateDataBaseInfo {
QString platformType;
QString newClientState;
QString sha256;
void clear();
bool operator==(const UpdateDataBaseInfo &other) const;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment