CppEditor/CppTools: Introduce Test{Case,Document}

Move common functionality of the 12 test classes into base classes.

Change-Id: If64d3cec876807ac6f991151189860a99b8ff4ca
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-12-16 16:02:45 +01:00
parent 5aa8a63f90
commit 5c8df5fa4e
25 changed files with 814 additions and 659 deletions

View File

@@ -27,9 +27,10 @@
**
****************************************************************************/
#include "cpptoolsplugin.h"
#include "cpppreprocessor.h"
#include "cpptoolseditorsupport.h"
#include "cpptoolsplugin.h"
#include "cpptoolstestcase.h"
#include "modelmanagertesthelper.h"
#include <coreplugin/editormanager/editormanager.h>
@@ -181,19 +182,15 @@ public:
return isFetchOk;
}
void writeContents(const QByteArray &contents) const
bool writeContents(const QByteArray &contents) const
{
Utils::FileSaver fileSaver(m_filePath);
fileSaver.write(contents);
fileSaver.finalize();
return CppTools::Tests::TestCase::writeFile(m_filePath, contents);
}
private:
void restoreContents() const
{
Utils::FileSaver fileSaver(m_filePath);
fileSaver.write(m_originalFileContents);
fileSaver.finalize();
CppTools::Tests::TestCase::writeFile(m_filePath, m_originalFileContents);
}
QByteArray m_originalFileContents;
@@ -554,7 +551,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
QByteArray originalContents;
QVERIFY(fileChangerAndRestorer.readContents(&originalContents));
const QByteArray newFileContentes = originalContents + "\nint addedOtherGlobal;";
fileChangerAndRestorer.writeContents(newFileContentes);
QVERIFY(fileChangerAndRestorer.writeContents(newFileContentes));
// Add or remove source file. The configuration stays the same.
part->files.clear();