Skip to content

Commit

Permalink
better automated tests log
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed May 2, 2024
1 parent 56b1e0d commit d1dd966
Show file tree
Hide file tree
Showing 59 changed files with 415 additions and 6 deletions.
9 changes: 9 additions & 0 deletions test/testaccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "accountstate.h"
#include "configfile.h"
#include "testhelper.h"
#include "logger.h"

using namespace OCC;

Expand All @@ -23,6 +24,14 @@ class TestAccount: public QObject
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testAccountDavPath_unitialized_noCrash()
{
AccountPtr account = Account::create();
Expand Down
5 changes: 5 additions & 0 deletions test/testactivitydata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ class TestActivityData : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

account = OCC::Account::create();
account->setCredentials(new FakeCredentials{fakeQnam.data()});
account->setUrl(QUrl(("http://example.de")));
Expand Down
5 changes: 5 additions & 0 deletions test/testactivitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class TestActivityListModel : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

fakeQnam.reset(new FakeQNAM({}));
account = OCC::Account::create();
account->setCredentials(new FakeCredentials{fakeQnam.data()});
Expand Down
7 changes: 7 additions & 0 deletions test/testallfilesdeleted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class TestAllFilesDeleted : public QObject
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testAllFilesDeletedKeep_data()
{
Expand Down
7 changes: 7 additions & 0 deletions test/testasyncop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class TestAsyncOp : public QObject
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void asyncUploadOperations()
{
Expand Down
8 changes: 8 additions & 0 deletions test/testblacklist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ class TestBlacklist : public QObject
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testBlacklistBasic_data()
{
QTest::addColumn<bool>("remote");
Expand Down
11 changes: 11 additions & 0 deletions test/testcapabilities.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
#include <QTest>

Check failure on line 1 in test/testcapabilities.cpp

View workflow job for this annotation

GitHub Actions / build

test/testcapabilities.cpp:1:10 [clang-diagnostic-error]

'QTest' file not found

#include "capabilities.h"
#include "logger.h"

#include <QStandardPaths>

class TestCapabilities : public QObject
{
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testPushNotificationsAvailable_pushNotificationsForActivitiesAvailable_returnTrue()
{
QStringList typeList;
Expand Down
5 changes: 5 additions & 0 deletions test/testcfapishellextensionsipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class TestCfApiShellExtensionsIPC : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

QTemporaryDir dir;
ConfigFile::setConfDir(dir.path());

Expand Down
10 changes: 8 additions & 2 deletions test/testchecksumvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "common/checksumconsts.h"
#include "common/utility.h"
#include "filesystem.h"
#include "logger.h"
#include "propagatorjobs.h"

using namespace OCC;
Expand Down Expand Up @@ -72,9 +73,14 @@ using namespace OCC::Utility;
return sumShell;
}

private slots:
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

void initTestCase() {
_testfile = _root.path()+"/csFile";
Utility::writeRandomFile( _testfile);
}
Expand Down
8 changes: 8 additions & 0 deletions test/testchunkingng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ class TestChunkingNG : public QObject
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testChunkV2Restrictions()
{
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
Expand Down
9 changes: 9 additions & 0 deletions test/testclientsideencryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <common/constants.h>

#include "clientsideencryption.h"
#include "logger.h"

using namespace OCC;

Expand All @@ -25,6 +26,14 @@ class TestClientSideEncryption : public QObject
}

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void shouldEncryptPrivateKeys()
{
// GIVEN
Expand Down
5 changes: 5 additions & 0 deletions test/testclientsideencryptionv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class TestClientSideEncryptionV2 : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

QVariantMap fakeCapabilities;
fakeCapabilities[QStringLiteral("end-to-end-encryption")] = QVariantMap{
{QStringLiteral("enabled"), true},
Expand Down
5 changes: 5 additions & 0 deletions test/testclientstatusreporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class TestClientStatusReporting : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

OCC::ClientStatusReportingNetwork::clientStatusReportingTrySendTimerInterval = 1000;
OCC::ClientStatusReportingNetwork::repordSendIntervalMs = 2000;

Expand Down
9 changes: 9 additions & 0 deletions test/testconcaturl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QString>

#include "account.h"
#include "logger.h"

using namespace OCC;

Expand Down Expand Up @@ -43,6 +44,14 @@ class TestConcatUrl: public QObject
{
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testFolder()
{
QFETCH(QString, base);
Expand Down
8 changes: 8 additions & 0 deletions test/testdatabaseerror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class TestDatabaseError : public QObject
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testDatabaseError() {
/* This test will make many iteration, at each iteration, the iᵗʰ database access will fail.
* The test ensure that if there is a failure, the next sync recovers. And if there was
Expand Down
11 changes: 11 additions & 0 deletions test/testdatefieldbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@

#include "gui/filedetails/datefieldbackend.h"

#include "logger.h"

#include <QTest>
#include <QSignalSpy>
#include <QStandardPaths>

using namespace OCC;

Expand All @@ -27,6 +30,14 @@ class TestDateFieldBackend : public QObject
static constexpr auto dateStringFormat = "dd/MM/yyyy";

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testDefaultBehaviour()
{
Quick::DateFieldBackend backend;
Expand Down
7 changes: 7 additions & 0 deletions test/testdownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class TestDownload : public QObject
Q_OBJECT

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testResume()
{
Expand Down
8 changes: 8 additions & 0 deletions test/teste2efiletransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
#include "gui/accountstate.h"
#include "gui/folderman.h"
#include "common/utility.h"
#include "logger.h"

#include "endtoendtestutils.h"

#include <QStandardPaths>

class E2eFileTransferTest : public QObject

Check warning on line 28 in test/teste2efiletransfer.cpp

View workflow job for this annotation

GitHub Actions / build

test/teste2efiletransfer.cpp:28:7 [cppcoreguidelines-pro-type-member-init]

constructor does not initialize these fields:
{
Q_OBJECT
Expand All @@ -34,6 +37,11 @@ class E2eFileTransferTest : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

qRegisterMetaType<OCC::SyncResult>("OCC::SyncResult");
}

Expand Down
8 changes: 8 additions & 0 deletions test/teste2eserversetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
#include <QSignalSpy>

#include "gui/accountstate.h"
#include "logger.h"

#include "endtoendtestutils.h"

#include <QStandardPaths>

class E2eServerSetupTest : public QObject

Check warning on line 26 in test/teste2eserversetup.cpp

View workflow job for this annotation

GitHub Actions / build

test/teste2eserversetup.cpp:26:7 [cppcoreguidelines-pro-type-member-init]

constructor does not initialize these fields:
{
Q_OBJECT
Expand All @@ -33,6 +36,11 @@ class E2eServerSetupTest : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

QSignalSpy accountReady(&_helper, &EndToEndTestHelper::accountReady);
_helper.startAccountConfig();
QVERIFY(accountReady.wait(3000));
Expand Down
9 changes: 9 additions & 0 deletions test/testexcludedfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QTemporaryDir>

#include "csync_exclude.h"
#include "logger.h"

using namespace OCC;

Expand Down Expand Up @@ -64,6 +65,14 @@ static auto check_dir_traversal(const char *path)


private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testFun()
{
ExcludedFiles excluded;
Expand Down
5 changes: 5 additions & 0 deletions test/testfiletagmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class TestFileTagModel : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);

_fakeQnam.reset(new FakeQNAM({}));
_fakeQnam->setOverride([this](QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice * const device) {
Q_UNUSED(device);
Expand Down
8 changes: 8 additions & 0 deletions test/testfolderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class TestFolderMan: public QObject
void incomingShareDeleted();

private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);

QStandardPaths::setTestModeEnabled(true);
}

void testDeleteEncryptedFiles()
{
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
Expand Down
Loading

0 comments on commit d1dd966

Please sign in to comment.