| 267 | } |
| 268 | |
| 269 | void TestProjectLoad::raceJob() |
| 270 | { |
| 271 | // our goal here is to try to reproduce https://bugs.kde.org/show_bug.cgi?id=260741 |
| 272 | // my idea is that this can be triggered by the following: |
| 273 | // - list dir foo/bar containing lots of files |
| 274 | // - remove dir foo while listjob is still running |
| 275 | TestProject p = makeProject(); |
| 276 | QDir dir(p.dir->path()); |
| 277 | QVERIFY(dir.mkpath(QStringLiteral("test/zzzzz"))); |
| 278 | for(int i = 0; i < 1000; ++i) { |
| 279 | createFile(QString(p.dir->path() + "/test/zzzzz/%1").arg(i)); |
| 280 | createFile(QString(p.dir->path() + "/test/%1").arg(i)); |
| 281 | } |
| 282 | |
| 283 | ICore::self()->projectController()->openProject(p.file); |
| 284 | QTRY_COMPARE(ICore::self()->projectController()->projectCount(), 1); |
| 285 | IProject *project = ICore::self()->projectController()->projectAt(0); |
| 286 | QCOMPARE(project->projectFile().toUrl(), p.file); |
| 287 | ProjectFolderItem* root = project->projectItem(); |
| 288 | QCOMPARE(root->project(), project); |
| 289 | QVERIFY(root->model()); |
| 290 | QCOMPARE(root->rowCount(), 1); |
| 291 | ProjectBaseItem* testItem = root->child(0); |
| 292 | QVERIFY(testItem->folder()); |
| 293 | QCOMPARE(testItem->baseName(), QStringLiteral("test")); |
| 294 | QCOMPARE(testItem->rowCount(), 1001); |
| 295 | int last = testItem->children().size() - 1; |
| 296 | ProjectBaseItem* asdfItem = testItem->children().at(last); |
| 297 | QVERIFY(asdfItem->folder()); |
| 298 | |
| 299 | // reload to trigger new list job |
| 300 | project->projectFileManager()->reload(testItem->folder()); |
| 301 | // move dir |
| 302 | QVERIFY(dir.rename(QStringLiteral("test"), QStringLiteral("test2"))); |
| 303 | // move sub dir |
| 304 | QVERIFY(dir.rename(QStringLiteral("test2/zzzzz"), QStringLiteral("test2/bla"))); |
| 305 | |
| 306 | QTRY_COMPARE(root->rowCount() == 1 ? root->child(0)->baseName() : QString(), QStringLiteral("test2")); |
| 307 | |
| 308 | // reload full model and then move dir |
| 309 | project->reloadModel(); |
| 310 | QVERIFY(dir.rename(QStringLiteral("test2"), QStringLiteral("test3"))); |
| 311 | |
| 312 | // note: this actually invalidates the root, so query that again |
| 313 | root = project->projectItem(); |
| 314 | QVERIFY(root); |
| 315 | |
| 316 | QTRY_COMPARE(root->rowCount() == 1 ? root->child(0)->baseName() : QString(), QStringLiteral("test3")); |
| 317 | } |
| 318 | |
| 319 | void TestProjectLoad::addDuringImport() |
| 320 | { |
nothing calls this directly
no test coverage detected