forked from owncloud/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestowncloudpropagator.cpp
69 lines (62 loc) · 2.25 KB
/
testowncloudpropagator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
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 "owncloudpropagator_p.h"
#include "propagatedownload.h"
#include "qchar.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 += QLatin1String("F");
QString tmpFileName = createDownloadTmpFileName(fn);
if (tmpFileName.contains(QLatin1Char('/'))) {
tmpFileName = tmpFileName.mid(tmpFileName.lastIndexOf(QLatin1Char('/')) + 1);
}
QVERIFY( tmpFileName.length() > 0);
QVERIFY( tmpFileName.length() <= 254);
}
// with absolute dir
fn = QStringLiteral("/Users/guruz/ownCloud/rocks/GPL");
for (int i = 1; i < 1000; i++) {
fn += QLatin1Char('F');
QString tmpFileName = createDownloadTmpFileName(fn);
if (tmpFileName.contains(QLatin1Char('/'))) {
tmpFileName = tmpFileName.mid(tmpFileName.lastIndexOf(QLatin1Char('/')) + 1);
}
QVERIFY( tmpFileName.length() > 0);
QVERIFY( tmpFileName.length() <= 254);
}
// with relative dir
fn = QStringLiteral("rocks/GPL");
for (int i = 1; i < 1000; i++) {
fn += QLatin1String("F");
QString tmpFileName = createDownloadTmpFileName(fn);
if (tmpFileName.contains(QLatin1Char('/'))) {
tmpFileName = tmpFileName.mid(tmpFileName.lastIndexOf(QLatin1Char('/')) + 1);
}
QVERIFY( tmpFileName.length() > 0);
QVERIFY( tmpFileName.length() <= 254);
}
}
};
QTEST_APPLESS_MAIN(TestOwncloudPropagator)
#include "testowncloudpropagator.moc"