TestResult: Devirtualize the class - part 1 of 5

The goal is to make the TestResult a value type without a need
to create these objects on heap.

Introduce a ResultHooks class that will replace all 5 virtual
methods.

Step 1 - implement outputStringHook.

Reorder constructor arguments of TestResult's subclasses so that
the first 2 args are always: id and name.

Change-Id: Iae93e5a348328414f057d1471afad8020b3c1171
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Jarek Kobus
2023-01-13 17:31:35 +01:00
parent e592e0e83f
commit d03c4f77c9
12 changed files with 158 additions and 144 deletions

View File

@@ -8,14 +8,18 @@
namespace Autotest {
TestResult::TestResult(const QString &id, const QString &name)
TestResult::TestResult(const QString &id, const QString &name, const ResultHooks &hooks)
: m_id(id)
, m_name(name)
, m_hooks(hooks)
{
}
const QString TestResult::outputString(bool selected) const
{
if (m_hooks.outputString)
return m_hooks.outputString(*this, selected);
if (m_result == ResultType::Application)
return m_id;
return selected ? m_description : m_description.split('\n').first();