forked from qt-creator/qt-creator
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user