AutoTest: Fix auto expansion of Qt test results

..especially when using data driven tests. In this case
we add an intermediate before the first data tag result
which apparently never got automatically expanded.

Change-Id: I282a57444b8014877c7a0e9f67c11c05ba1d06a5
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2023-06-27 10:48:31 +02:00
parent a207943f59
commit d1f20a0506

View File

@@ -4,6 +4,7 @@
#include "testresultmodel.h"
#include "autotesticons.h"
#include "testresultspane.h"
#include "testrunner.h"
#include "testsettings.h"
#include "testtreeitem.h"
@@ -14,6 +15,7 @@
#include <QFontMetrics>
#include <QIcon>
#include <QToolButton>
using namespace Utils;
@@ -184,6 +186,17 @@ TestResultItem *TestResultItem::createAndAddIntermediateFor(const TestResultItem
result.setResult(ResultType::TestStart);
TestResultItem *intermediate = new TestResultItem(result);
appendChild(intermediate);
// FIXME: make the expand button's state easier accessible
auto widgets = TestResultsPane::instance()->toolBarWidgets();
if (!widgets.empty()) {
if (QToolButton *expand = qobject_cast<QToolButton *>(widgets.at(0))) {
if (expand->isChecked()) {
QMetaObject::invokeMethod(TestResultsPane::instance(),
[intermediate] { intermediate->expand(); },
Qt::QueuedConnection);
}
}
}
return intermediate;
}