diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-07-16 16:20:46 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-07-17 14:54:10 +0200 |
commit | c84e3a27d61f2b4e407751760d0e3dacfc4640c8 (patch) | |
tree | 9b31af56224a5bb5f6de0f6b0a3eb138a23293bc /src/plugins/cpptools/cppmodelmanager_test.cpp | |
parent | bc4fa63f8489c9c82fd82f12b4acf368e71aa388 (diff) | |
download | qt-creator-c84e3a27d61f2b4e407751760d0e3dacfc4640c8.tar.gz |
CppTools: Garbage collect if the last CppEditor is closed
Task-number: QTCREATORBUG-9828
Change-Id: Ie0ef9757cedb772702e49542b58d5b589506aa9e
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 | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp index 305b16b2c2..7bd128d209 100644 --- a/src/plugins/cpptools/cppmodelmanager_test.cpp +++ b/src/plugins/cpptools/cppmodelmanager_test.cpp @@ -32,6 +32,7 @@ #include "cpppreprocessor.h" #include "modelmanagertesthelper.h" +#include <coreplugin/editormanager/editormanager.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/session.h> @@ -413,3 +414,33 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles() sm->removeProject(project); ModelManagerTestHelper::verifyClean(); } + +/// QTCREATORBUG-9828: Locator shows symbols of closed files +/// Check: The garbage collector should be run if the last CppEditor is closed. +void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed() +{ + 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)); + QVERIFY(mm->workingCopy().contains(file)); + + // Check: File is in the snapshot + QVERIFY(mm->snapshot().contains(file)); + + // Close file/editor + const QList<Core::IEditor*> editorsToClose = QList<Core::IEditor*>() << editor; + em->closeEditors(editorsToClose, /*askAboutModifiedEditors=*/ false); + + // Check: File is removed from the snapshpt + QVERIFY(!mm->workingCopy().contains(file)); + QVERIFY(!mm->snapshot().contains(file)); +} |