mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
f427955512
Remove all configure_files: - Move all tests to cpp files - Use the QTEST_MAIN macro instead of a generated main.cpp - Include test*.moc in the cpp to let CMAKE_AUTOMOC call moc - Pass info through add_definitions instead of generating oc_bin.h with them This makes sure that build errors points to the original test source file instead of the generated one in the build directory to be able to jump and fix errors directly from the IDE's error pane.
82 lines
2.5 KiB
C++
82 lines
2.5 KiB
C++
/*
|
|
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"
|
|
#include "owncloudpropagator_p.h"
|
|
|
|
using namespace OCC;
|
|
namespace OCC {
|
|
QString OWNCLOUDSYNC_EXPORT createDownloadTmpFileName(const QString &previous);
|
|
}
|
|
|
|
class TestOwncloudPropagator : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void testUpdateErrorFromSession()
|
|
{
|
|
// OwncloudPropagator 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);
|
|
}
|
|
}
|
|
|
|
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));
|
|
}
|
|
}
|
|
};
|
|
|
|
QTEST_MAIN(TestOwncloudPropagator)
|
|
#include "testowncloudpropagator.moc"
|