2013-05-05 14:36:42 +04:00
|
|
|
/*
|
|
|
|
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>
|
2015-05-08 17:41:41 +03:00
|
|
|
#include <QDebug>
|
2013-05-05 14:36:42 +04:00
|
|
|
|
2015-05-08 17:41:41 +03:00
|
|
|
#include "propagatedownload.h"
|
2015-10-15 15:57:06 +03:00
|
|
|
#include "owncloudpropagator_p.h"
|
2015-05-08 17:41:41 +03:00
|
|
|
|
|
|
|
using namespace OCC;
|
|
|
|
namespace OCC {
|
2015-05-22 10:17:24 +03:00
|
|
|
QString OWNCLOUDSYNC_EXPORT createDownloadTmpFileName(const QString &previous);
|
2015-05-08 17:41:41 +03:00
|
|
|
}
|
2013-05-05 14:36:42 +04:00
|
|
|
|
|
|
|
class TestOwncloudPropagator : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void testUpdateErrorFromSession()
|
|
|
|
{
|
2013-10-03 16:45:00 +04:00
|
|
|
// OwncloudPropagator propagator( NULL, QLatin1String("test1"), QLatin1String("test2"), new ProgressDatabase);
|
2013-05-05 14:36:42 +04:00
|
|
|
QVERIFY( true );
|
|
|
|
}
|
2015-05-08 17:41:41 +03:00
|
|
|
|
|
|
|
void testTmpDownloadFileNameGeneration()
|
|
|
|
{
|
|
|
|
QString fn;
|
2015-05-11 16:41:56 +03:00
|
|
|
// 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";
|
2015-05-08 17:41:41 +03:00
|
|
|
for (int i = 1; i < 1000; i++) {
|
|
|
|
fn+="F";
|
|
|
|
QString tmpFileName = createDownloadTmpFileName(fn);
|
2015-05-11 16:41:56 +03:00
|
|
|
if (tmpFileName.contains('/')) {
|
|
|
|
tmpFileName = tmpFileName.mid(tmpFileName.lastIndexOf('/')+1);
|
|
|
|
}
|
2015-05-08 17:41:41 +03:00
|
|
|
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) {
|
2015-10-15 16:52:58 +03:00
|
|
|
QCOMPARE(parseEtag(test.first), QByteArray(test.second));
|
2015-10-15 15:57:06 +03:00
|
|
|
}
|
|
|
|
}
|
2013-05-05 14:36:42 +04:00
|
|
|
};
|
|
|
|
|
2016-03-30 18:58:15 +03:00
|
|
|
QTEST_MAIN(TestOwncloudPropagator)
|
|
|
|
#include "testowncloudpropagator.moc"
|