Commit 8c187f38 authored by Laurent Montel's avatar Laurent Montel 😁

Minor optimization

parent eaad8e44
......@@ -46,9 +46,9 @@ void CheckPhishingUrlCacheTest::shouldAddValue_data()
{
QTest::addColumn<QUrl>("url");
QTest::addColumn<bool>("validurl");
QTest::addColumn<double>("seconds");
QTest::addColumn<uint>("seconds");
QTest::addColumn<WebEngineViewer::CheckPhishingUrlCache::UrlStatus>("status");
double currentValue = QDateTime::currentDateTime().toTime_t();
uint currentValue = QDateTime::currentDateTimeUtc().toTime_t();
QTest::newRow("valid") << QUrl(QStringLiteral("http://www.kde.org")) << true << currentValue << WebEngineViewer::CheckPhishingUrlCache::UrlOk;
QTest::newRow("malware1validcache") << QUrl(QStringLiteral("http://www.kde.org")) << false << (currentValue + 2000) << WebEngineViewer::CheckPhishingUrlCache::MalWare;
QTest::newRow("malware1invalidcache") << QUrl(QStringLiteral("http://www.kde.org")) << false << (currentValue - 2000) << WebEngineViewer::CheckPhishingUrlCache::Unknown;
......@@ -58,7 +58,7 @@ void CheckPhishingUrlCacheTest::shouldAddValue()
{
QFETCH(QUrl, url);
QFETCH(bool, validurl);
QFETCH(double, seconds);
QFETCH(uint, seconds);
QFETCH(WebEngineViewer::CheckPhishingUrlCache::UrlStatus, status);
WebEngineViewer::CheckPhishingUrlCache cache;
......@@ -72,7 +72,7 @@ void CheckPhishingUrlCacheTest::shouldStoreValues()
WebEngineViewer::CheckPhishingUrlCache cache;
QUrl url = QUrl(QStringLiteral("http://www.kde.org"));
double currentValue = QDateTime::currentDateTime().toTime_t();
uint currentValue = QDateTime::currentDateTimeUtc().toTime_t();
cache.addCheckingUrlResult(url, false, currentValue + 2000);
//Add malware
......
......@@ -54,14 +54,14 @@ void CheckPhishingUrlUtilTest::shouldCacheIsStillValid_data()
{
QTest::addColumn<double>("second");
QTest::addColumn<bool>("valid");
double currentTime = QDateTime::currentDateTime().toTime_t();
uint currentTime = QDateTime::currentDateTimeUtc().toTime_t();
QTest::newRow("valid") << (currentTime + 2000) << true;
QTest::newRow("invalid") << (currentTime - 2000) << false;
}
void CheckPhishingUrlUtilTest::shouldCacheIsStillValid()
{
QFETCH(double, second);
QFETCH(uint, second);
QFETCH(bool, valid);
QCOMPARE(WebEngineViewer::CheckPhishingUrlUtil::cachedValueStillValid(second), valid);
}
......
......@@ -43,9 +43,9 @@ void HashCacheManagerTest::shouldBeUnknowByDefault()
void HashCacheManagerTest::shouldAddValue_data()
{
QTest::addColumn<QByteArray>("hash");
QTest::addColumn<double>("seconds");
QTest::addColumn<uint>("seconds");
QTest::addColumn<WebEngineViewer::HashCacheManager::UrlStatus>("status");
double currentValue = QDateTime::currentDateTime().toTime_t();
uint currentValue = QDateTime::currentDateTimeUtc().toTime_t();
QTest::newRow("valid") << QByteArrayLiteral("foo") << (currentValue + 2000) << WebEngineViewer::HashCacheManager::UrlOk;
QTest::newRow("malware1validcache") << QByteArrayLiteral("bla") << (currentValue + 2000) << WebEngineViewer::HashCacheManager::MalWare;
QTest::newRow("malware1invalidcache") << QByteArrayLiteral("blu") << (currentValue - 2000) << WebEngineViewer::HashCacheManager::Unknown;
......@@ -54,7 +54,7 @@ void HashCacheManagerTest::shouldAddValue_data()
void HashCacheManagerTest::shouldAddValue()
{
QFETCH(QByteArray, hash);
QFETCH(double, seconds);
QFETCH(uint, seconds);
QFETCH(WebEngineViewer::HashCacheManager::UrlStatus, status);
WebEngineViewer::HashCacheManager cache;
......
......@@ -96,7 +96,7 @@ void BackOffModeManagerPrivate::load()
isInOffMode = grp.readEntry("Enabled", false);
if (isInOffMode) {
const uint delay = grp.readEntry("Delay", 0);
const uint now = QDateTime::currentDateTime().toTime_t();
const uint now = QDateTime::currentDateTimeUtc().toTime_t();
if (delay > now) {
const int diff = (delay - now);
updateTimer(diff);
......
......@@ -82,7 +82,7 @@ uint CheckPhishingUrlUtil::refreshingCacheAfterThisTime(double seconds)
bool CheckPhishingUrlUtil::cachedValueStillValid(uint seconds)
{
return QDateTime::currentDateTime().toTime_t() < seconds;
return QDateTime::currentDateTimeUtc().toTime_t() < seconds;
}
int CheckPhishingUrlUtil::generateRandomSecondValue(int numberOfFailed)
......
......@@ -159,7 +159,7 @@ void LocalDataBaseManager::initialize()
if (!QFileInfo::exists(databaseFullPath())) {
downloadFullDataBase();
} else {
const uint now = QDateTime::currentDateTime().toTime_t();
const uint now = QDateTime::currentDateTimeUtc().toTime_t();
//qDebug() << " now "<< now << " d->mSecondToStartRefreshing "<<d->mSecondToStartRefreshing << " now > d->mSecondToStartRefreshing" << (now > d->mSecondToStartRefreshing);
if ((d->mSecondToStartRefreshing != 0) && (d->mSecondToStartRefreshing > now)) {
qCWarning(WEBENGINEVIEWER_LOG) << " It's not necessary to check database now";
......@@ -176,7 +176,7 @@ void LocalDataBaseManager::initialize()
void LocalDataBaseManager::slotCheckDataBase()
{
const uint now = QDateTime::currentDateTime().toTime_t();
const uint now = QDateTime::currentDateTimeUtc().toTime_t();
if (d->mDataBaseOk && !d->mDownloadProgress && (d->mSecondToStartRefreshing < now)) {
downloadPartialDataBase();
}
......
Markdown is supported
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