2
* <one line to give the library's name and an idea of what it does.>
3
* Copyright (C) 2014 Vishesh Handa <me@vhanda.in>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "fileindexingjobtest.h"
22
#include "../../fileindexingjob.h"
27
using namespace Baloo;
29
void FileIndexingJobTest::init()
31
// Set the correct path
32
QByteArray path = qgetenv("PATH");
33
path = QByteArray(BALOO_TEMP_PATH) + ":" + path;
35
setenv("PATH", path.constData(), 1);
36
unsetenv("BALOO_EXTRACTOR_FAIL_FILE");
39
void FileIndexingJobTest::testFileFail()
42
for (int i = 0; i<40; i++) {
46
putenv("BALOO_EXTRACTOR_FAIL_FILE=5");
47
FileIndexingJob* job = new FileIndexingJob(files);
49
QSignalSpy spy(job, SIGNAL(indexingFailed(uint)));
52
QCOMPARE(spy.count(), 1);
53
QCOMPARE(spy.at(0).size(), 1);
54
QCOMPARE(spy.at(0).first().toUInt(), (uint)5);
57
void FileIndexingJobTest::testMultiFileFail()
60
for (int i = 0; i<40; i++) {
64
putenv("BALOO_EXTRACTOR_FAIL_FILE=5,18,19");
65
FileIndexingJob* job = new FileIndexingJob(files);
67
QSignalSpy spy(job, SIGNAL(indexingFailed(uint)));
70
QCOMPARE(spy.count(), 3);
71
QCOMPARE(spy.at(0).size(), 1);
72
QCOMPARE(spy.at(0).first().toUInt(), (uint)5);
73
QCOMPARE(spy.at(1).size(), 1);
74
QCOMPARE(spy.at(1).first().toUInt(), (uint)18);
75
QCOMPARE(spy.at(2).size(), 1);
76
QCOMPARE(spy.at(2).first().toUInt(), (uint)19);
79
void FileIndexingJobTest::testNormalExecution()
82
files << 1 << 2 << 3 << 4 << 5 << 6;
84
FileIndexingJob* job = new FileIndexingJob(files);
86
QSignalSpy spy1(job, SIGNAL(indexingFailed(uint)));
87
QSignalSpy spy2(job, SIGNAL(finished(KJob*)));
90
QCOMPARE(spy1.count(), 0);
91
QCOMPARE(spy2.count(), 1);
94
QTEST_MAIN(FileIndexingJobTest);