Skip to content

Commit

Permalink
Upload: Added tests and fixes one existing
Browse files Browse the repository at this point in the history
Signed-off-by: Juergen Kellerer <juergen@k123.eu>
  • Loading branch information
jkellerer committed Aug 7, 2022
1 parent e489341 commit 67be42c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
41 changes: 41 additions & 0 deletions test/testnextcloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QtTest>
#include <QDebug>

#include "account.h"
#include "propagatedownload.h"
#include "owncloudpropagator_p.h"

Expand Down Expand Up @@ -76,6 +77,46 @@ private slots:
QCOMPARE(parseEtag(test.first), QByteArray(test.second));
}
}

void testRespectsLowestPossibleChunkSize()
{
QSet<QString> __blacklist;
OwncloudPropagator propagator(OCC::Account::create(), "", "", nullptr, __blacklist);
auto opts = propagator.syncOptions();

opts._minChunkSize =
opts._initialChunkSize =
opts._maxChunkSize = 0;

propagator.setSyncOptions(opts);

opts = propagator.syncOptions();
QVERIFY( opts._minChunkSize == 512 * 1024 );
QVERIFY( opts._initialChunkSize == 512 * 1024 );
QVERIFY( opts._maxChunkSize == 512 * 1024 );
}

void testLimitsMaxChunkSizeByAccount()
{
QSet<QString> __blacklist;
OwncloudPropagator propagator(OCC::Account::create(), "", "", nullptr, __blacklist);
auto opts = propagator.syncOptions();

SyncOptions defaultOpts;
QVERIFY( opts._minChunkSize == defaultOpts._minChunkSize );
QVERIFY( opts._minChunkSize < defaultOpts._maxChunkSize );
QVERIFY( opts._minChunkSize < defaultOpts._initialChunkSize );
QVERIFY( opts._initialChunkSize == defaultOpts._initialChunkSize );
QVERIFY( opts._maxChunkSize == defaultOpts._maxChunkSize );

propagator.account()->setMaxRequestSizeIfLower(defaultOpts._minChunkSize);
propagator.setSyncOptions(opts);

opts = propagator.syncOptions();
QVERIFY( opts._minChunkSize == defaultOpts._minChunkSize );
QVERIFY( opts._initialChunkSize == defaultOpts._minChunkSize );
QVERIFY( opts._maxChunkSize == defaultOpts._minChunkSize );
}
};

QTEST_APPLESS_MAIN(TestNextcloudPropagator)
Expand Down
9 changes: 5 additions & 4 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,10 @@ private slots:
{
FakeFolder fakeFolder{ FileInfo{} };
SyncOptions options;
options._initialChunkSize = 10;
options._maxChunkSize = 10;
options._minChunkSize = 10;
options._initialChunkSize =
options._maxChunkSize =
options._minChunkSize = 1000 * 1000;

fakeFolder.syncEngine().setSyncOptions(options);

QObject parent;
Expand All @@ -833,7 +834,7 @@ private slots:
return nullptr;
});

fakeFolder.localModifier().insert("file", 100, 'W');
fakeFolder.localModifier().insert("file", 10 * options._maxChunkSize, 'W');
QTimer::singleShot(100, &fakeFolder.syncEngine(), [&]() { fakeFolder.syncEngine().abort(); });
QVERIFY(!fakeFolder.syncOnce());

Expand Down

0 comments on commit 67be42c

Please sign in to comment.