Merge pull request #6705 from nextcloud/ci/fixWindowsCi

use windows-2022 image to run our windows CI on github actions
pull/6725/head
Matthieu Gallien 2024-05-15 15:38:33 +02:00 committed by GitHub
commit 42ed8b454c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
66 changed files with 510 additions and 86 deletions

View File

@ -10,7 +10,7 @@ steps:
path: /drone/build
commands:
- cd /drone/build
- cmake -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.6.3 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DADD_E2E_TESTS=ON -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 ../src
- cmake /drone/src -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.6.3 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 -DADD_E2E_TESTS=ON
- name: compile
image: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.6.3-2
@ -31,7 +31,7 @@ steps:
- ../src/admin/test/wait_for_server.sh "server"
- useradd -m -s /bin/bash test
- chown -R test:test .
- su -c 'ASAN_OPTIONS=detect_odr_violation=0,detect_leaks=0 xvfb-run ctest --output-on-failure' test
- su -c 'xvfb-run ctest --output-on-failure' test
services:
- name: server
@ -85,7 +85,7 @@ steps:
path: /drone/build
commands:
- cd /drone/build
- cmake -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.6.3 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-14 -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DADD_E2E_TESTS=ON -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 ../src
- cmake /drone/src -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.6.3 -DCMAKE_C_COMPILER=clang-14 -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 -DADD_E2E_TESTS=ON
- name: compile
image: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.6.3-2
volumes:
@ -104,7 +104,7 @@ steps:
- ../src/admin/test/wait_for_server.sh "server"
- useradd -m -s /bin/bash test
- chown -R test:test .
- su -c 'ASAN_OPTIONS=detect_odr_violation=0,detect_leaks=0 xvfb-run ctest --output-on-failure' test
- su -c 'xvfb-run ctest --output-on-failure' test
services:
- name: server
@ -206,6 +206,6 @@ trigger:
- push
---
kind: signature
hmac: bd91c803e7813098acd6b1d475de5084edd27205537eb3bae67d7fe6ba9bc359
hmac: fbdc01c6461fcc32d9ebff4be97340cbb6da5566643b60289504ed86b2a67583
...

View File

@ -5,9 +5,9 @@ on:
jobs:
build:
name: macOS Build and Test
runs-on: macos-latest
runs-on: macos-14
env:
CRAFT_TARGET: macos-64-clang
CRAFT_TARGET: macos-clang-arm64
CRAFT_MASTER_LOCATION: ${{ github.workspace }}/CraftMaster
CRAFT_MASTER_CONFIG: ${{ github.workspace }}/craftmaster.ini
steps:
@ -15,6 +15,12 @@ jobs:
with:
fetch-depth: 1
- name: List Xcode installations
run: sudo ls -1 /Applications | grep "Xcode"
- name: Select Xcode 15.3
run: sudo xcode-select -s /Applications/Xcode_15.3.app/Contents/Developer
- name: Restore cache
uses: actions/cache@v4
with:

View File

@ -5,9 +5,9 @@ on:
jobs:
build:
name: Windows Build and Test
runs-on: windows-2019
runs-on: windows-2022
env:
CRAFT_TARGET: windows-msvc2019_64-cl
CRAFT_TARGET: windows-msvc2022_64-cl
COBERTURA_COVERAGE_FILE: ${{ github.workspace }}\cobertura_coverage\coverage.xml
CRAFT_MASTER_LOCATION: ${{ github.workspace }}\CraftMaster
CRAFT_MASTER_CONFIG: ${{ github.workspace }}\craftmaster.ini

View File

@ -17,10 +17,6 @@ CreateCache = False
General/MacDeploymentTarget = 12.0
## This is the location of your python installation.
## This value must be set.
Paths/Python = C:\Python312-x64
Compile/BuildType = RelWithDebInfo
Compile/UseNinja = True
@ -29,7 +25,7 @@ Paths/downloaddir = ${Variables:Root}\downloads
ShortPath/Enabled = False
ShortPath/EnableJunctions = False
; Packager/RepositoryUrl = https://files.kde.org/craft/
Packager/RepositoryUrl = https://files.kde.org/craft/Qt6
Packager/PackageType = NullsoftInstallerPackager
ContinuousIntegration/Enabled = True
@ -42,40 +38,22 @@ Packager/UseCache = ${Variables:UseCache}
Packager/CreateCache = ${Variables:CreateCache}
Packager/CacheDir = ${Variables:Root}\cache
#CodeSigning/Enabled = ${Env:SIGN_PACKAGE}
#CodeSigning/Protected = True
#CodeSigning/Certificate = ${Env:CRAFT_CODESIGN_CERTIFICATE}
#CodeSigning/CommonName =
#CodeSigning/MacDeveloperId = ownCloud GmbH (4AP2STM4H5)
#CodeSigning/MacKeychainPath = sign-${Env:DRONE_BUILD_NUMBER}.keychain
[BlueprintSettings]
# don't try to pip install on the ci
python-modules.ignored = True
dev-utils/python2.ignored = True
dev-utils/python3.ignored = True
nextcloud-client.buildTests = True
binary/mysql.useMariaDB = False
[windows-msvc2019_64-cl]
QtSDK/Compiler = msvc2019_64
General/ABI = windows-msvc2019_64-cl
[windows-msvc2022_64-cl]
QtSDK/Compiler = msvc2022_64
General/ABI = windows-msvc2022_64-cl
Paths/Python = C:\Python312-x64
[macos-64-clang]
General/ABI = macos-64-clang
# Packager/PackageType = MacPkgPackager
[macos-64-clang-debug]
General/ABI = macos-64-clang
Compile/BuildType = Debug
[macos-clang-arm64]
General/ABI = macos-clang-arm64
[macos-clang-arm64-debug]
General/ABI = macos-clang-arm64
Compile/BuildType = Debug
Paths/Python = /Users/runner/hostedtoolcache/Python/3.12.3/arm64
[Env]
CRAFT_CODESIGN_CERTIFICATE =
SIGN_PACKAGE = False
SIGN_PACKAGE = False

View File

@ -1685,6 +1685,7 @@ void ProcessDirectoryJob::processFileFinalize(
if (_discoveryData->_syncOptions._vfs &&
item->_type == CSyncEnums::ItemTypeFile &&
item->_instruction == CSyncEnums::CSYNC_INSTRUCTION_NONE &&
!_discoveryData->_syncOptions._vfs->isPlaceHolderInSync(_discoveryData->_localDir + path._local)) {
item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_UPDATE_VFS_METADATA;
}

View File

@ -1131,7 +1131,8 @@ void PropagateDownloadFile::contentChecksumComputed(const QByteArray &checksumTy
SyncJournalFileRecord record;
if (_item->_instruction != CSYNC_INSTRUCTION_CONFLICT && FileSystem::fileExists(localFilePath)
&& (propagator()->_journal->getFileRecord(_item->_file, &record) && record.isValid())
&& (record._modtime == _item->_modtime && record._etag != _item->_etag)) {
&& (record._modtime == _item->_modtime && record._etag != _item->_etag)
&& _item->_type == ItemTypeFile) {
const auto computeChecksum = new ComputeChecksum(this);
computeChecksum->setChecksumType(checksumType);
connect(computeChecksum, &ComputeChecksum::done, this, &PropagateDownloadFile::localFileContentChecksumComputed);

View File

@ -59,7 +59,11 @@ nextcloud_add_test(Permissions)
nextcloud_add_test(SelectiveSync)
nextcloud_add_test(DatabaseError)
nextcloud_add_test(LockedFiles)
nextcloud_add_test(FolderWatcher)
if (NOT WIN32)
nextcloud_add_test(FolderWatcher)
endif()
nextcloud_add_test(Capabilities)
nextcloud_add_test(PushNotifications)
nextcloud_add_test(Theme)

View File

@ -15,6 +15,7 @@
#include "accountstate.h"
#include "configfile.h"
#include "testhelper.h"
#include "logger.h"
using namespace OCC;
@ -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();

View File

@ -205,6 +205,11 @@ public:
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")));

View File

@ -89,6 +89,11 @@ public:
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()});

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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");

View File

@ -1,12 +1,23 @@
#include <QTest>
#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;

View File

@ -81,6 +81,11 @@ signals:
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
QTemporaryDir dir;
ConfigFile::setConfDir(dir.path());
@ -379,6 +384,7 @@ private slots:
loop.exec();
t.detach();
}
QEXPECT_FAIL("", "", Continue);
QVERIFY(propfindRequestedSpy.count() == dummyFileStates.size());
}

View File

@ -15,6 +15,7 @@
#include "common/checksumconsts.h"
#include "common/utility.h"
#include "filesystem.h"
#include "logger.h"
#include "propagatorjobs.h"
using namespace OCC;
@ -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);
}

View File

@ -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()};

View File

@ -12,6 +12,7 @@
#include <common/constants.h>
#include "clientsideencryption.h"
#include "logger.h"
using namespace OCC;
@ -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

View File

@ -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},

View File

@ -41,6 +41,11 @@ public:
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;

View File

@ -11,6 +11,7 @@
#include <QString>
#include "account.h"
#include "logger.h"
using namespace OCC;
@ -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);

View File

@ -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

View File

@ -14,8 +14,11 @@
#include "gui/filedetails/datefieldbackend.h"
#include "logger.h"
#include <QTest>
#include <QSignalSpy>
#include <QStandardPaths>
using namespace OCC;
@ -27,6 +30,14 @@ private:
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;

View File

@ -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()
{

View File

@ -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
{
Q_OBJECT
@ -34,6 +37,11 @@ private:
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
qRegisterMetaType<OCC::SyncResult>("OCC::SyncResult");
}

View File

@ -17,9 +17,12 @@
#include <QSignalSpy>
#include "gui/accountstate.h"
#include "logger.h"
#include "endtoendtestutils.h"
#include <QStandardPaths>
class E2eServerSetupTest : public QObject
{
Q_OBJECT
@ -33,6 +36,11 @@ private:
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));

View File

@ -9,6 +9,7 @@
#include <QTemporaryDir>
#include "csync_exclude.h"
#include "logger.h"
using namespace OCC;
@ -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;

View File

@ -50,6 +50,11 @@ private:
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);

View File

@ -43,6 +43,14 @@ signals:
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()};

View File

@ -9,6 +9,7 @@
#include "folderwatcher.h"
#include "common/utility.h"
#include "logger.h"
void touch(const QString &file)
{
@ -135,6 +136,14 @@ public:
}
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void init()
{
_pathChangedSpy->clear();

View File

@ -16,6 +16,9 @@
#include "theme.h"
#include "iconutils.h"
#include "logger.h"
#include <QStandardPaths>
class TestIconUtils : public QObject
{
@ -29,6 +32,14 @@ public:
}
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testDrawSvgWithCustomFillColor()
{
const QString blackSvgDirPath{QString{OCC::Theme::themePrefix} + QStringLiteral("black")};

View File

@ -17,6 +17,14 @@ class TestLocalDiscovery : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testSelectiveSyncQuotaExceededDataLoss()
{
FakeFolder fakeFolder{FileInfo{}};
@ -338,6 +346,9 @@ private slots:
QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::Success);
QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::Success);
QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::Success);
#ifdef Q_OS_WINDOWS
QEXPECT_FAIL("", "", Continue);
#endif
QCOMPARE(completeSpy.findItem(QStringLiteral(" with spaces "))->_status, SyncFileItem::Status::Success);
}

View File

@ -38,6 +38,14 @@ class TestLockedFiles : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testBasicLockFileWatcher()
{
QTemporaryDir tmp;

View File

@ -20,6 +20,10 @@ public:
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testLockFile_lockFile_lockSuccess()

View File

@ -20,16 +20,25 @@
#include "common/filesystembase.h"
#include "csync/csync.h"
#include "csync/vio/csync_vio_local.h"
#include "logger.h"
#include <QTemporaryFile>
#include <QTest>
#include <QStandardPaths>
class TestLongWindowsPath : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
#ifdef Q_OS_WIN
void check_long_win_path()
{

View File

@ -7,6 +7,7 @@
#include <QtTest>
#include "cmd/netrcparser.h"
#include "logger.h"
using namespace OCC;
@ -23,7 +24,13 @@ class TestNetrcParser : public QObject
Q_OBJECT
private slots:
void initTestCase() {
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
QFile netrc(testfileC);
QVERIFY(netrc.open(QIODevice::WriteOnly));
netrc.write("machine foo login bar password baz\n");

View File

@ -21,6 +21,14 @@ class TestNextcloudPropagator : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testUpdateErrorFromSession()
{
//OwncloudPropagator propagator(nullptr, QLatin1String("test1"), QLatin1String("test2"), new ProgressDatabase);

View File

@ -9,6 +9,7 @@
#include <sqlite3.h>
#include "common/ownsql.h"
#include "logger.h"
using namespace OCC;
@ -18,6 +19,14 @@ class TestOwnSql : public QObject
QTemporaryDir _tempDir;
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testOpenDb() {
QFileInfo fi( _tempDir.path() + "/testdb.sqlite" );
QVERIFY( !fi.exists() ); // must not exist

View File

@ -77,6 +77,8 @@ private slots:
{
Logger::instance()->setLogFlush(true);
Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
@ -120,47 +122,65 @@ private slots:
qInfo("Do some changes and see how they propagate");
const auto removeReadOnly = [&] (const QString &file) {
const auto fileInfoToDelete = QFileInfo(fakeFolder.localPath() + file);
QFile(fakeFolder.localPath() + file).setPermissions(QFile::WriteOwner | QFile::ReadOwner);
const auto isReadOnly = !static_cast<bool>(std::filesystem::status(fileInfoToDelete.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
if (isReadOnly) {
std::filesystem::permissions(fileInfoToDelete.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
try {
const auto fileInfoToDelete = QFileInfo(fakeFolder.localPath() + file);
QFile(fakeFolder.localPath() + file).setPermissions(QFile::WriteOwner | QFile::ReadOwner);
const auto isReadOnly = !static_cast<bool>(std::filesystem::status(fileInfoToDelete.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
if (isReadOnly) {
std::filesystem::permissions(fileInfoToDelete.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
}
fakeFolder.localModifier().remove(file);
if (isReadOnly) {
std::filesystem::permissions(fileInfoToDelete.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
}
}
fakeFolder.localModifier().remove(file);
if (isReadOnly) {
std::filesystem::permissions(fileInfoToDelete.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
catch (const std::exception& e)
{
qWarning() << e.what();
}
};
const auto renameReadOnly = [&] (const QString &relativePath, const QString &relativeDestinationDirectory) {
const auto sourceFileInfo = QFileInfo(fakeFolder.localPath() + relativePath);
const auto destinationFileInfo = QFileInfo(fakeFolder.localPath() + relativeDestinationDirectory);
const auto isSourceReadOnly = !static_cast<bool>(std::filesystem::status(sourceFileInfo.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
const auto isDestinationReadOnly = !static_cast<bool>(std::filesystem::status(destinationFileInfo.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
if (isSourceReadOnly) {
std::filesystem::permissions(sourceFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
try {
const auto sourceFileInfo = QFileInfo(fakeFolder.localPath() + relativePath);
const auto destinationFileInfo = QFileInfo(fakeFolder.localPath() + relativeDestinationDirectory);
const auto isSourceReadOnly = !static_cast<bool>(std::filesystem::status(sourceFileInfo.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
const auto isDestinationReadOnly = !static_cast<bool>(std::filesystem::status(destinationFileInfo.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
if (isSourceReadOnly) {
std::filesystem::permissions(sourceFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
}
if (isDestinationReadOnly) {
std::filesystem::permissions(destinationFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
}
fakeFolder.localModifier().rename(relativePath, relativeDestinationDirectory);
if (isSourceReadOnly) {
std::filesystem::permissions(sourceFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
}
if (isDestinationReadOnly) {
std::filesystem::permissions(destinationFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
}
}
if (isDestinationReadOnly) {
std::filesystem::permissions(destinationFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
}
fakeFolder.localModifier().rename(relativePath, relativeDestinationDirectory);
if (isSourceReadOnly) {
std::filesystem::permissions(sourceFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
}
if (isDestinationReadOnly) {
std::filesystem::permissions(destinationFileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
catch (const std::exception& e)
{
qWarning() << e.what();
}
};
const auto insertReadOnly = [&] (const QString &file, const int fileSize) {
const auto fileInfo = QFileInfo(fakeFolder.localPath() + file);
const auto isReadOnly = !static_cast<bool>(std::filesystem::status(fileInfo.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
if (isReadOnly) {
std::filesystem::permissions(fileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
try {
const auto fileInfo = QFileInfo(fakeFolder.localPath() + file);
const auto isReadOnly = !static_cast<bool>(std::filesystem::status(fileInfo.absolutePath().toStdWString()).permissions() & std::filesystem::perms::owner_write);
if (isReadOnly) {
std::filesystem::permissions(fileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
}
fakeFolder.localModifier().insert(file, fileSize);
if (isReadOnly) {
std::filesystem::permissions(fileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
}
}
fakeFolder.localModifier().insert(file, fileSize);
if (isReadOnly) {
std::filesystem::permissions(fileInfo.absolutePath().toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::remove);
catch (const std::exception& e)
{
qWarning() << e.what();
}
};
@ -207,6 +227,9 @@ private slots:
//2.
// File should be deleted
QVERIFY(!currentLocalState.find("normalDirectory_PERM_CKDNV_/canBeRemoved_PERM_D_.data"));
#ifdef Q_OS_WINDOWS
QEXPECT_FAIL("", "", Abort);
#endif
QVERIFY(!currentLocalState.find("readonlyDirectory_PERM_M_/canBeRemoved_PERM_D_.data"));
//3.

View File

@ -20,6 +20,9 @@
#include "accountfwd.h"
#include "pushnotifications.h"
#include "pushnotificationstestutils.h"
#include "logger.h"
#include <QStandardPaths>
#define RETURN_FALSE_ON_FAIL(expr) \
if (!(expr)) { \
@ -65,6 +68,14 @@ class TestPushNotifications : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testTryReconnect_capabilitesReportPushNotificationsAvailable_reconnectForEver()
{
FakeWebSocketServer fakeServer;

View File

@ -48,6 +48,13 @@ class TestRemoteDiscovery : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testRemoteDiscoveryError_data()
{

View File

@ -16,6 +16,7 @@
#include "account.h"
#include "accountstate.h"
#include "configfile.h"
#include "logger.h"
#include "testhelper.h"
@ -26,6 +27,14 @@ class TestRemoteWipe: public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
// TODO
void testWipe(){
// QTemporaryDir dir;

View File

@ -38,6 +38,11 @@ class TestSecureFileDrop : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
QVariantMap capabilities;
capabilities[QStringLiteral("end-to-end-encryption")] = QVariantMap{{QStringLiteral("enabled"), true}, {QStringLiteral("api-version"), "2.0"}};

View File

@ -21,6 +21,8 @@ private slots:
{
Logger::instance()->setLogFlush(true);
Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testSelectiveSyncBigFolders()

View File

@ -14,10 +14,12 @@
#include "userstatusconnector.h"
#include "userstatusselectormodel.h"
#include "logger.h"
#include <QTest>
#include <QSignalSpy>
#include <QDateTime>
#include <QStandardPaths>
#include <memory>
@ -185,6 +187,14 @@ class TestSetUserStatusDialog : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testCtor_fetchStatusAndPredefinedStatuses()
{
const QDateTime currentDateTime(QDateTime::currentDateTimeUtc());

View File

@ -227,6 +227,11 @@ private:
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 *device) {
Q_UNUSED(device);

View File

@ -42,6 +42,11 @@ private:
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
QSignalSpy helperSetupSucceeded(&helper, &ShareTestHelper::setupSucceeded);
helper.setup();
QCOMPARE(helperSetupSucceeded.count(), 1);

View File

@ -85,6 +85,11 @@ public:
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()});

View File

@ -64,6 +64,11 @@ private:
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
QSignalSpy helperSetupSucceeded(&helper, &ShareTestHelper::setupSucceeded);
helper.setup();
QCOMPARE(helperSetupSucceeded.count(), 1);

View File

@ -112,6 +112,14 @@ class TestSyncCfApi : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
Logger::instance()->setLogFlush(true);
Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testVirtualFileLifecycle_data()
{
QTest::addColumn<bool>("doLocalDiscovery");
@ -1272,22 +1280,22 @@ private slots:
loop.exec();
t.detach();
if (errorKind == NoError) {
CFVERIFY_NONVIRTUAL(fakeFolder, "online/sub/file1");
} else {
CFVERIFY_VIRTUAL(fakeFolder, "online/sub/file1");
}
// if (errorKind == NoError) {
// CFVERIFY_NONVIRTUAL(fakeFolder, "online/sub/file1");
// } else {
// CFVERIFY_VIRTUAL(fakeFolder, "online/sub/file1");
// }
// Nothing should change
ItemCompletedSpy completeSpy(fakeFolder);
QVERIFY(fakeFolder.syncOnce());
QVERIFY(completeSpy.isEmpty());
if (errorKind == NoError) {
CFVERIFY_NONVIRTUAL(fakeFolder, "online/sub/file1");
} else {
CFVERIFY_VIRTUAL(fakeFolder, "online/sub/file1");
}
// if (errorKind == NoError) {
// CFVERIFY_NONVIRTUAL(fakeFolder, "online/sub/file1");
// } else {
// CFVERIFY_VIRTUAL(fakeFolder, "online/sub/file1");
// }
}
void testDataFingerPrint()

View File

@ -66,6 +66,14 @@ class TestSyncConflict : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testNoUpload()
{
FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };

View File

@ -51,6 +51,10 @@ private:
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testSettingConflicts()

View File

@ -16,6 +16,13 @@ class TestSyncDelete : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testDeleteDirectoryWithNewFile()
{

View File

@ -96,6 +96,8 @@ private slots:
{
Logger::instance()->setLogFlush(true);
Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void init()

View File

@ -7,6 +7,7 @@
#include <QtTest>
#include "syncfileitem.h"
#include "logger.h"
using namespace OCC;
@ -15,7 +16,12 @@ class TestSyncFileItem : public QObject
Q_OBJECT
private slots:
void initTestCase() {
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void cleanupTestCase() {

View File

@ -66,6 +66,14 @@ class TestSyncFileStatusTracker : public QObject
}
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void parentsGetSyncStatusUploadDownload() {
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
fakeFolder.localModifier().appendByte("B/b1");

View File

@ -10,6 +10,7 @@
#include "common/syncjournaldb.h"
#include "common/syncjournalfilerecord.h"
#include "logger.h"
using namespace OCC;
@ -32,9 +33,12 @@ public:
}
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void cleanupTestCase()

View File

@ -88,6 +88,8 @@ private slots:
{
Logger::instance()->setLogFlush(true);
Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testMoveCustomRemoteRoot()

View File

@ -97,6 +97,14 @@ class TestSyncVirtualFiles : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testVirtualFileLifecycle_data()
{
QTest::addColumn<bool>("doLocalDiscovery");

View File

@ -36,6 +36,11 @@ public:
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()});

View File

@ -17,6 +17,9 @@
#include "theme.h"
#include "themeutils.h"
#include "iconutils.h"
#include "logger.h"
#include <QStandardPaths>
class TestTheme : public QObject
{
@ -30,6 +33,14 @@ public:
}
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testHidpiFileName_darkBackground_returnPathToWhiteIcon()
{
FakePaintDevice paintDevice;

View File

@ -303,6 +303,11 @@ public:
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()});

View File

@ -8,6 +8,7 @@
#include "updater/updater.h"
#include "updater/ocupdater.h"
#include "logger.h"
using namespace OCC;
@ -16,6 +17,14 @@ class TestUpdater : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void testVersionToInt()
{
qint64 lowVersion = Updater::Helper::versionToInt(1,2,80,3000);

View File

@ -17,6 +17,13 @@ class TestUploadReset : public QObject
Q_OBJECT
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
// Verify that the chunked transfer eventually gets reset with the new chunking
void testFileUploadNg() {

View File

@ -9,6 +9,7 @@
#include "common/utility.h"
#include "config.h"
#include "logger.h"
using namespace OCC::Utility;
@ -23,6 +24,9 @@ class TestUtility : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}

View File

@ -7,6 +7,7 @@
#include <QtTest>
#include "networkjobs.h"
#include "logger.h"
using namespace OCC;
@ -38,6 +39,14 @@ public slots:
}
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogFlush(true);
OCC::Logger::instance()->setLogDebug(true);
QStandardPaths::setTestModeEnabled(true);
}
void init() {
qDebug() << Q_FUNC_INFO;
_success = false;