* Wraps the QTemporaryFile for Windows. * * On Windows. the file can not be written as long as QTemporaryFile keeps it open. */
| 13 | * On Windows. the file can not be written as long as QTemporaryFile keeps it open. |
| 14 | */ |
| 15 | class TemporaryFileWrapper { |
| 16 | public: |
| 17 | ~TemporaryFileWrapper() { |
| 18 | QFile::remove(filename); |
| 19 | } |
| 20 | |
| 21 | bool exists() const { |
| 22 | return !filename.isEmpty(); |
| 23 | } |
| 24 | |
| 25 | QString name() const { |
| 26 | return filename; |
| 27 | } |
| 28 | |
| 29 | QString read() const { |
| 30 | QFile file{filename}; |
| 31 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) |
| 32 | return QString(); |
| 33 | QTextStream in(&file); |
| 34 | return in.readAll(); |
| 35 | } |
| 36 | |
| 37 | private: |
| 38 | const QString filename{getTmpFileName()}; |
| 39 | |
| 40 | static QString getTmpFileName() { |
| 41 | QTemporaryFile tempFile{}; |
| 42 | if (!tempFile.open()) { |
| 43 | return {}; |
| 44 | } |
| 45 | return tempFile.fileName() + ".txt"; |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | const InvokeResult QtTestStep::invokeStepBody() { |
| 50 | const TemporaryFileWrapper file{}; |
nothing calls this directly
no outgoing calls
no test coverage detected