diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-07-17 13:50:38 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-08-08 12:12:31 +0200 |
commit | 2665a1249bd666b260455b43462dcebcefaa3ff4 (patch) | |
tree | 92ce5a0c0387e22ab4701eb6f59dabee04220122 /src/plugins/cpptools/cppmodelmanager_test.cpp | |
parent | 7583039b87c2908d40017ba1c245fed0b471c0f9 (diff) | |
download | qt-creator-2665a1249bd666b260455b43462dcebcefaa3ff4.tar.gz |
CppTools: Do not garbage collect files in the working copy
...except the configuration file if no projects are open. For this case
there is no need to keep the configuration file around.
Task-number: QTCREATORBUG-9829
Change-Id: I51b01b30c17cbc1ced491ef2c47c338dae6ed983
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager_test.cpp')
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager_test.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp index 7e649a9c01..1fb02ba5ed 100644 --- a/src/plugins/cpptools/cppmodelmanager_test.cpp +++ b/src/plugins/cpptools/cppmodelmanager_test.cpp @@ -551,3 +551,38 @@ void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed() QVERIFY(!mm->workingCopy().contains(file)); QVERIFY(!mm->snapshot().contains(file)); } + +/// Check: Files that are open in the editor are not garbage collected. +void CppToolsPlugin::test_modelmanager_dont_gc_opened_files() +{ + ModelManagerTestHelper helper; + + TestDataDirectory testDataDirectory(QLatin1String("testdata_guiproject1")); + const QString file = testDataDirectory.file(QLatin1String("main.cpp")); + + Core::EditorManager *em = Core::EditorManager::instance(); + CppModelManager *mm = CppModelManager::instance(); + + // Open a file in the editor + QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0); + Core::IEditor *editor = em->openEditor(file); + QVERIFY(editor); + QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 1); + QVERIFY(mm->isCppEditor(editor)); + + // Check: File is in the working copy and snapshot + QVERIFY(mm->workingCopy().contains(file)); + QVERIFY(mm->snapshot().contains(file)); + + // Run the garbage collector + mm->GC(); + + // Check: File is still there + QVERIFY(mm->workingCopy().contains(file)); + QVERIFY(mm->snapshot().contains(file)); + + // Close editor + em->closeEditors(QList<Core::IEditor*>() << editor); + helper.waitForFinishedGc(); + QVERIFY(mm->snapshot().isEmpty()); +} |