nextcloud-desktop/test/testnextcloudpropagator.cpp

83 lines
2.5 KiB
C++
Raw Normal View History

/*
This software is in the public domain, furnished "as is", without technical
support, and with no warranty, express or implied, as to its usefulness for
any purpose.
*/
#include <QtTest>
#include <QDebug>
#include "propagatedownload.h"
2018-10-12 16:56:26 +03:00
#include "owncloudpropagator_p.h"
using namespace OCC;
namespace OCC {
2015-05-22 10:17:24 +03:00
QString OWNCLOUDSYNC_EXPORT createDownloadTmpFileName(const QString &previous);
}
2018-10-12 15:52:18 +03:00
class TestNextcloudPropagator : public QObject
{
Q_OBJECT
private slots:
void testUpdateErrorFromSession()
{
2018-10-12 15:52:18 +03:00
// NextcloudPropagator propagator( NULL, QLatin1String("test1"), QLatin1String("test2"), new ProgressDatabase);
QVERIFY( true );
}
void testTmpDownloadFileNameGeneration()
{
QString fn;
// without dir
for (int i = 1; i <= 1000; i++) {
fn+="F";
QString tmpFileName = createDownloadTmpFileName(fn);
if (tmpFileName.contains('/')) {
tmpFileName = tmpFileName.mid(tmpFileName.lastIndexOf('/')+1);
}
QVERIFY( tmpFileName.length() > 0);
QVERIFY( tmpFileName.length() <= 254);
}
// with absolute dir
fn = "/Users/guruz/ownCloud/rocks/GPL";
for (int i = 1; i < 1000; i++) {
fn+="F";
QString tmpFileName = createDownloadTmpFileName(fn);
if (tmpFileName.contains('/')) {
tmpFileName = tmpFileName.mid(tmpFileName.lastIndexOf('/')+1);
}
QVERIFY( tmpFileName.length() > 0);
QVERIFY( tmpFileName.length() <= 254);
}
// with relative dir
fn = "rocks/GPL";
for (int i = 1; i < 1000; i++) {
fn+="F";
QString tmpFileName = createDownloadTmpFileName(fn);
if (tmpFileName.contains('/')) {
tmpFileName = tmpFileName.mid(tmpFileName.lastIndexOf('/')+1);
}
QVERIFY( tmpFileName.length() > 0);
QVERIFY( tmpFileName.length() <= 254);
}
}
2015-10-15 15:57:06 +03:00
void testParseEtag()
{
typedef QPair<const char*, const char*> Test;
QList<Test> tests;
tests.append(Test("\"abcd\"", "abcd"));
tests.append(Test("\"\"", ""));
tests.append(Test("\"fii\"-gzip", "fii"));
tests.append(Test("W/\"foo\"", "foo"));
foreach (const auto& test, tests) {
QCOMPARE(parseEtag(test.first), QByteArray(test.second));
2015-10-15 15:57:06 +03:00
}
}
};
2018-10-12 15:52:18 +03:00
QTEST_APPLESS_MAIN(TestNextcloudPropagator)
#include "testnextcloudpropagator.moc"