2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2014-12-18 15:02:07 +01:00
|
|
|
|
|
|
|
|
#include "testnavigationwidget.h"
|
2020-10-09 13:07:55 +02:00
|
|
|
|
2014-12-18 15:02:07 +01:00
|
|
|
#include "autotestconstants.h"
|
2015-11-24 15:46:51 +01:00
|
|
|
#include "autotesticons.h"
|
2022-07-13 18:31:56 +02:00
|
|
|
#include "autotesttr.h"
|
2023-07-28 18:24:24 +02:00
|
|
|
#include "itemdatacache.h"
|
2020-10-09 13:07:55 +02:00
|
|
|
#include "testcodeparser.h"
|
|
|
|
|
#include "testframeworkmanager.h"
|
|
|
|
|
#include "testrunner.h"
|
2014-12-18 15:02:07 +01:00
|
|
|
#include "testtreeitem.h"
|
2020-10-09 13:07:55 +02:00
|
|
|
#include "testtreeitemdelegate.h"
|
|
|
|
|
#include "testtreemodel.h"
|
|
|
|
|
#include "testtreeview.h"
|
2014-12-18 15:02:07 +01:00
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
2015-02-26 16:50:39 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2014-12-18 15:02:07 +01:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
|
2017-06-15 10:43:44 +02:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
|
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/link.h>
|
2023-07-28 18:24:24 +02:00
|
|
|
#include <utils/navigationtreeview.h>
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <utils/progressindicator.h>
|
2023-05-09 13:20:04 +02:00
|
|
|
#include <utils/stylehelper.h>
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2014-12-18 15:02:07 +01:00
|
|
|
|
2015-02-26 16:50:39 +01:00
|
|
|
#include <QAction>
|
|
|
|
|
#include <QMenu>
|
2015-02-17 14:45:26 +01:00
|
|
|
#include <QTimer>
|
2014-12-18 15:02:07 +01:00
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
2023-07-28 18:24:24 +02:00
|
|
|
using namespace Core;
|
2023-01-16 15:00:15 +01:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2023-07-28 18:24:24 +02:00
|
|
|
namespace Autotest::Internal {
|
2014-12-18 15:02:07 +01:00
|
|
|
|
2023-07-28 18:24:24 +02:00
|
|
|
class TestNavigationWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TestNavigationWidget();
|
|
|
|
|
|
|
|
|
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
|
|
|
|
QList<QToolButton *> createToolButtons();
|
|
|
|
|
|
|
|
|
|
void updateExpandedStateCache();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void onItemActivated(const QModelIndex &index);
|
|
|
|
|
void onSortClicked();
|
|
|
|
|
void onFilterMenuTriggered(QAction *action);
|
|
|
|
|
void onParsingStarted();
|
|
|
|
|
void onParsingFinished();
|
|
|
|
|
void initializeFilterMenu();
|
|
|
|
|
void onRunThisTestTriggered(TestRunMode runMode);
|
|
|
|
|
void reapplyCachedExpandedState();
|
|
|
|
|
|
|
|
|
|
TestTreeModel *m_model;
|
|
|
|
|
TestTreeSortFilterModel *m_sortFilterModel;
|
|
|
|
|
TestTreeView *m_view;
|
|
|
|
|
QToolButton *m_sort;
|
|
|
|
|
QToolButton *m_filterButton;
|
|
|
|
|
QMenu *m_filterMenu;
|
|
|
|
|
bool m_sortAlphabetically;
|
|
|
|
|
Utils::ProgressIndicator *m_progressIndicator;
|
|
|
|
|
QTimer *m_progressTimer;
|
|
|
|
|
QFrame *m_missingFrameworksWidget;
|
|
|
|
|
ItemDataCache<bool> m_expandedStateCache;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TestNavigationWidget::TestNavigationWidget()
|
2014-12-18 15:02:07 +01:00
|
|
|
{
|
2022-07-13 18:31:56 +02:00
|
|
|
setWindowTitle(Tr::tr("Tests"));
|
2014-12-18 15:02:07 +01:00
|
|
|
m_model = TestTreeModel::instance();
|
|
|
|
|
m_sortFilterModel = new TestTreeSortFilterModel(m_model, m_model);
|
|
|
|
|
m_sortFilterModel->setDynamicSortFilter(true);
|
|
|
|
|
m_view = new TestTreeView(this);
|
|
|
|
|
m_view->setModel(m_sortFilterModel);
|
|
|
|
|
m_view->setSortingEnabled(true);
|
|
|
|
|
m_view->setItemDelegate(new TestTreeItemDelegate(this));
|
|
|
|
|
|
2016-06-08 12:56:25 +02:00
|
|
|
QPalette pal;
|
2023-01-16 15:00:15 +01:00
|
|
|
pal.setColor(QPalette::Window, creatorTheme()->color(Theme::InfoBarBackground));
|
|
|
|
|
pal.setColor(QPalette::WindowText, creatorTheme()->color(Theme::InfoBarText));
|
2016-06-08 12:56:25 +02:00
|
|
|
m_missingFrameworksWidget = new QFrame;
|
|
|
|
|
m_missingFrameworksWidget->setPalette(pal);
|
|
|
|
|
m_missingFrameworksWidget->setAutoFillBackground(true);
|
|
|
|
|
QHBoxLayout *hLayout = new QHBoxLayout;
|
|
|
|
|
m_missingFrameworksWidget->setLayout(hLayout);
|
2022-07-13 18:31:56 +02:00
|
|
|
hLayout->addWidget(new QLabel(Tr::tr("No active test frameworks.")));
|
2020-03-26 12:01:59 +01:00
|
|
|
const bool hasActiveFrameworks = Utils::anyOf(TestFrameworkManager::registeredFrameworks(),
|
|
|
|
|
&ITestFramework::active);
|
|
|
|
|
m_missingFrameworksWidget->setVisible(!hasActiveFrameworks);
|
2014-12-18 15:02:07 +01:00
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
2019-08-29 10:36:01 +02:00
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
2014-12-18 15:02:07 +01:00
|
|
|
layout->setSpacing(0);
|
2016-06-08 12:56:25 +02:00
|
|
|
layout->addWidget(m_missingFrameworksWidget);
|
2023-07-28 18:24:24 +02:00
|
|
|
layout->addWidget(ItemViewFind::createSearchableWrapper(m_view));
|
2014-12-18 15:02:07 +01:00
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
|
|
connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated);
|
2015-02-17 14:45:26 +01:00
|
|
|
|
2023-01-16 15:00:15 +01:00
|
|
|
m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Medium, this);
|
2015-02-17 14:45:26 +01:00
|
|
|
m_progressIndicator->attachToWidget(m_view);
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
|
|
|
|
|
m_progressTimer = new QTimer(this);
|
|
|
|
|
m_progressTimer->setSingleShot(true);
|
2016-04-01 10:20:58 +02:00
|
|
|
m_progressTimer->setInterval(1000); // don't display indicator if progress takes less than 1s
|
2015-02-17 14:45:26 +01:00
|
|
|
|
|
|
|
|
connect(m_model->parser(), &TestCodeParser::parsingStarted,
|
|
|
|
|
this, &TestNavigationWidget::onParsingStarted);
|
|
|
|
|
connect(m_model->parser(), &TestCodeParser::parsingFinished,
|
|
|
|
|
this, &TestNavigationWidget::onParsingFinished);
|
2015-07-27 13:54:27 +02:00
|
|
|
connect(m_model->parser(), &TestCodeParser::parsingFailed,
|
|
|
|
|
this, &TestNavigationWidget::onParsingFinished);
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(m_model, &TestTreeModel::updatedActiveFrameworks, this, [this](int numberOfActive) {
|
2016-06-08 12:56:25 +02:00
|
|
|
m_missingFrameworksWidget->setVisible(numberOfActive == 0);
|
|
|
|
|
});
|
2023-02-14 15:47:22 +01:00
|
|
|
ProjectExplorer::ProjectManager *sm = ProjectExplorer::ProjectManager::instance();
|
|
|
|
|
connect(sm, &ProjectExplorer::ProjectManager::startupProjectChanged,
|
2020-06-18 16:14:17 +02:00
|
|
|
this, [this](ProjectExplorer::Project * /*project*/) {
|
2020-06-17 13:04:44 +02:00
|
|
|
m_expandedStateCache.clear();
|
|
|
|
|
});
|
|
|
|
|
connect(m_model, &TestTreeModel::testTreeModelChanged,
|
|
|
|
|
this, &TestNavigationWidget::reapplyCachedExpandedState);
|
2023-01-16 15:00:15 +01:00
|
|
|
connect(m_progressTimer, &QTimer::timeout, m_progressIndicator, &ProgressIndicator::show);
|
2020-11-06 13:24:06 +01:00
|
|
|
connect(m_view, &TestTreeView::expanded, this, &TestNavigationWidget::updateExpandedStateCache);
|
|
|
|
|
connect(m_view, &TestTreeView::collapsed, this, &TestNavigationWidget::updateExpandedStateCache);
|
2014-12-18 15:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
|
|
|
|
|
{
|
2017-06-15 10:43:44 +02:00
|
|
|
const bool enabled = !ProjectExplorer::BuildManager::isBuilding()
|
|
|
|
|
&& !TestRunner::instance()->isTestRunning()
|
2016-12-12 09:35:49 +01:00
|
|
|
&& m_model->parser()->state() == TestCodeParser::Idle;
|
2015-04-16 14:04:36 +02:00
|
|
|
|
2014-12-18 15:02:07 +01:00
|
|
|
QMenu menu;
|
2017-02-13 10:05:06 +01:00
|
|
|
QAction *runThisTest = nullptr;
|
|
|
|
|
QAction *runWithoutDeploy = nullptr;
|
|
|
|
|
QAction *debugThisTest = nullptr;
|
|
|
|
|
QAction *debugWithoutDeploy = nullptr;
|
2015-04-16 14:04:36 +02:00
|
|
|
const QModelIndexList list = m_view->selectionModel()->selectedIndexes();
|
|
|
|
|
if (list.size() == 1) {
|
|
|
|
|
const QModelIndex index = list.first();
|
|
|
|
|
QRect rect(m_view->visualRect(index));
|
|
|
|
|
if (rect.contains(event->pos())) {
|
2020-10-19 13:56:19 +02:00
|
|
|
ITestTreeItem *item = static_cast<ITestTreeItem *>(
|
2016-04-08 14:58:23 +02:00
|
|
|
m_model->itemForIndex(m_sortFilterModel->mapToSource(index)));
|
|
|
|
|
if (item->canProvideTestConfiguration()) {
|
2022-07-13 18:31:56 +02:00
|
|
|
runThisTest = new QAction(Tr::tr("Run This Test"), &menu);
|
2015-04-16 14:04:36 +02:00
|
|
|
runThisTest->setEnabled(enabled);
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(runThisTest, &QAction::triggered, this, [this] {
|
2017-09-05 13:57:22 +02:00
|
|
|
onRunThisTestTriggered(TestRunMode::Run);
|
2016-06-15 12:29:24 +02:00
|
|
|
});
|
2022-07-13 18:31:56 +02:00
|
|
|
runWithoutDeploy = new QAction(Tr::tr("Run Without Deployment"), &menu);
|
2016-06-27 11:07:16 +02:00
|
|
|
runWithoutDeploy->setEnabled(enabled);
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(runWithoutDeploy, &QAction::triggered, this, [this] {
|
2017-09-05 13:57:22 +02:00
|
|
|
onRunThisTestTriggered(TestRunMode::RunWithoutDeploy);
|
2016-06-27 11:07:16 +02:00
|
|
|
});
|
2016-06-15 12:29:24 +02:00
|
|
|
}
|
2020-11-25 08:18:55 +01:00
|
|
|
auto ttitem = item->testBase()->type() == ITestBase::Framework
|
|
|
|
|
? static_cast<TestTreeItem *>(item)
|
|
|
|
|
: nullptr;
|
2020-10-19 13:56:19 +02:00
|
|
|
if (ttitem && ttitem->canProvideDebugConfiguration()) {
|
2022-07-13 18:31:56 +02:00
|
|
|
debugThisTest = new QAction(Tr::tr("Debug This Test"), &menu);
|
2016-06-15 12:29:24 +02:00
|
|
|
debugThisTest->setEnabled(enabled);
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(debugThisTest, &QAction::triggered, this, [this] {
|
2017-09-05 13:57:22 +02:00
|
|
|
onRunThisTestTriggered(TestRunMode::Debug);
|
2016-06-15 12:29:24 +02:00
|
|
|
});
|
2022-07-13 18:31:56 +02:00
|
|
|
debugWithoutDeploy = new QAction(Tr::tr("Debug Without Deployment"), &menu);
|
2016-06-27 11:07:16 +02:00
|
|
|
debugWithoutDeploy->setEnabled(enabled);
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(debugWithoutDeploy, &QAction::triggered, this, [this] {
|
2017-09-05 13:57:22 +02:00
|
|
|
onRunThisTestTriggered(TestRunMode::DebugWithoutDeploy);
|
2016-06-27 11:07:16 +02:00
|
|
|
});
|
2015-04-16 14:04:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 18:24:24 +02:00
|
|
|
QAction *runAll = ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action();
|
|
|
|
|
QAction *runSelected = ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action();
|
|
|
|
|
QAction *runAllNoDeploy = ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action();
|
|
|
|
|
QAction *runSelectedNoDeploy = ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action();
|
2022-07-13 18:31:56 +02:00
|
|
|
QAction *selectAll = new QAction(Tr::tr("Select All"), &menu);
|
|
|
|
|
QAction *deselectAll = new QAction(Tr::tr("Deselect All"), &menu);
|
2014-12-18 15:02:07 +01:00
|
|
|
// TODO remove?
|
2023-07-28 18:24:24 +02:00
|
|
|
QAction *rescan = ActionManager::command(Constants::ACTION_SCAN_ID)->action();
|
2014-12-18 15:02:07 +01:00
|
|
|
|
|
|
|
|
connect(selectAll, &QAction::triggered, m_view, &TestTreeView::selectAll);
|
|
|
|
|
connect(deselectAll, &QAction::triggered, m_view, &TestTreeView::deselectAll);
|
|
|
|
|
|
2016-06-27 11:07:16 +02:00
|
|
|
if (runThisTest) {
|
2015-04-16 14:04:36 +02:00
|
|
|
menu.addAction(runThisTest);
|
2016-06-27 11:07:16 +02:00
|
|
|
menu.addAction(runWithoutDeploy);
|
|
|
|
|
}
|
|
|
|
|
if (debugThisTest) {
|
2016-06-15 12:29:24 +02:00
|
|
|
menu.addAction(debugThisTest);
|
2016-06-27 11:07:16 +02:00
|
|
|
menu.addAction(debugWithoutDeploy);
|
|
|
|
|
}
|
2016-06-15 12:29:24 +02:00
|
|
|
if (runThisTest || debugThisTest)
|
2015-04-16 14:04:36 +02:00
|
|
|
menu.addSeparator();
|
2016-06-15 12:29:24 +02:00
|
|
|
|
2014-12-18 15:02:07 +01:00
|
|
|
menu.addAction(runAll);
|
2021-07-08 16:57:00 +02:00
|
|
|
menu.addAction(runAllNoDeploy);
|
2014-12-18 15:02:07 +01:00
|
|
|
menu.addAction(runSelected);
|
2021-07-08 16:57:00 +02:00
|
|
|
menu.addAction(runSelectedNoDeploy);
|
2014-12-18 15:02:07 +01:00
|
|
|
menu.addSeparator();
|
|
|
|
|
menu.addAction(selectAll);
|
|
|
|
|
menu.addAction(deselectAll);
|
|
|
|
|
menu.addSeparator();
|
|
|
|
|
menu.addAction(rescan);
|
|
|
|
|
|
|
|
|
|
menu.exec(mapToGlobal(event->pos()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QToolButton *> TestNavigationWidget::createToolButtons()
|
|
|
|
|
{
|
|
|
|
|
QList<QToolButton *> list;
|
|
|
|
|
|
|
|
|
|
m_filterButton = new QToolButton(m_view);
|
2016-08-03 17:55:54 +02:00
|
|
|
m_filterButton->setIcon(Utils::Icons::FILTER.icon());
|
2022-07-13 18:31:56 +02:00
|
|
|
m_filterButton->setToolTip(Tr::tr("Filter Test Tree"));
|
2023-05-09 13:20:04 +02:00
|
|
|
m_filterButton->setProperty(StyleHelper::C_NO_ARROW, true);
|
2014-12-18 15:02:07 +01:00
|
|
|
m_filterButton->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
|
m_filterMenu = new QMenu(m_filterButton);
|
|
|
|
|
initializeFilterMenu();
|
|
|
|
|
connect(m_filterMenu, &QMenu::triggered, this, &TestNavigationWidget::onFilterMenuTriggered);
|
|
|
|
|
m_filterButton->setMenu(m_filterMenu);
|
|
|
|
|
|
|
|
|
|
m_sortAlphabetically = true;
|
|
|
|
|
m_sort = new QToolButton(this);
|
2015-11-24 15:46:51 +01:00
|
|
|
m_sort->setIcon(Icons::SORT_NATURALLY.icon());
|
2022-07-13 18:31:56 +02:00
|
|
|
m_sort->setToolTip(Tr::tr("Sort Naturally"));
|
2014-12-18 15:02:07 +01:00
|
|
|
|
|
|
|
|
QToolButton *expand = new QToolButton(this);
|
2016-08-03 17:55:54 +02:00
|
|
|
expand->setIcon(Utils::Icons::EXPAND_TOOLBAR.icon());
|
2022-07-13 18:31:56 +02:00
|
|
|
expand->setToolTip(Tr::tr("Expand All"));
|
2014-12-18 15:02:07 +01:00
|
|
|
|
|
|
|
|
QToolButton *collapse = new QToolButton(this);
|
2016-08-03 17:55:54 +02:00
|
|
|
collapse->setIcon(Utils::Icons::COLLAPSE_TOOLBAR.icon());
|
2022-07-13 18:31:56 +02:00
|
|
|
collapse->setToolTip(Tr::tr("Collapse All"));
|
2014-12-18 15:02:07 +01:00
|
|
|
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(expand, &QToolButton::clicked, m_view, [this] {
|
2020-11-06 13:24:06 +01:00
|
|
|
m_view->blockSignals(true);
|
|
|
|
|
m_view->expandAll();
|
|
|
|
|
m_view->blockSignals(false);
|
|
|
|
|
updateExpandedStateCache();
|
|
|
|
|
});
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(collapse, &QToolButton::clicked, m_view, [this] {
|
2020-11-06 13:24:06 +01:00
|
|
|
m_view->blockSignals(true);
|
|
|
|
|
m_view->collapseAll();
|
|
|
|
|
m_view->blockSignals(false);
|
|
|
|
|
updateExpandedStateCache();
|
|
|
|
|
});
|
2014-12-18 15:02:07 +01:00
|
|
|
connect(m_sort, &QToolButton::clicked, this, &TestNavigationWidget::onSortClicked);
|
|
|
|
|
|
|
|
|
|
list << m_filterButton << m_sort << expand << collapse;
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 13:04:44 +02:00
|
|
|
void TestNavigationWidget::updateExpandedStateCache()
|
|
|
|
|
{
|
2020-10-19 14:46:21 +02:00
|
|
|
m_expandedStateCache.evolve(ITestBase::Framework);
|
2020-06-17 13:04:44 +02:00
|
|
|
|
2023-01-16 15:00:15 +01:00
|
|
|
for (TreeItem *rootNode : *m_model->rootItem()) {
|
|
|
|
|
rootNode->forAllChildren([this](TreeItem *child) {
|
2020-10-12 14:11:10 +02:00
|
|
|
m_expandedStateCache.insert(static_cast<ITestTreeItem *>(child),
|
2020-06-18 12:32:48 +02:00
|
|
|
m_view->isExpanded(child->index()));
|
2020-06-17 13:04:44 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-18 15:02:07 +01:00
|
|
|
void TestNavigationWidget::onItemActivated(const QModelIndex &index)
|
|
|
|
|
{
|
2023-01-16 15:00:15 +01:00
|
|
|
const Link link = index.data(LinkRole).value<Link>();
|
2021-05-25 14:48:09 +02:00
|
|
|
if (link.hasValidTarget())
|
2023-07-28 18:24:24 +02:00
|
|
|
EditorManager::openEditorAt(link);
|
2014-12-18 15:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestNavigationWidget::onSortClicked()
|
|
|
|
|
{
|
|
|
|
|
if (m_sortAlphabetically) {
|
2019-04-04 14:33:08 +02:00
|
|
|
m_sort->setIcon(Utils::Icons::SORT_ALPHABETICALLY_TOOLBAR.icon());
|
2022-07-13 18:31:56 +02:00
|
|
|
m_sort->setToolTip(Tr::tr("Sort Alphabetically"));
|
2016-04-28 16:42:14 +02:00
|
|
|
m_sortFilterModel->setSortMode(TestTreeItem::Naturally);
|
2014-12-18 15:02:07 +01:00
|
|
|
} else {
|
2015-11-24 15:46:51 +01:00
|
|
|
m_sort->setIcon(Icons::SORT_NATURALLY.icon());
|
2022-07-13 18:31:56 +02:00
|
|
|
m_sort->setToolTip(Tr::tr("Sort Naturally"));
|
2016-04-28 16:42:14 +02:00
|
|
|
m_sortFilterModel->setSortMode(TestTreeItem::Alphabetically);
|
2014-12-18 15:02:07 +01:00
|
|
|
}
|
|
|
|
|
m_sortAlphabetically = !m_sortAlphabetically;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestNavigationWidget::onFilterMenuTriggered(QAction *action)
|
|
|
|
|
{
|
|
|
|
|
m_sortFilterModel->toggleFilter(
|
|
|
|
|
TestTreeSortFilterModel::toFilterMode(action->data().value<int>()));
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-17 14:45:26 +01:00
|
|
|
void TestNavigationWidget::onParsingStarted()
|
|
|
|
|
{
|
|
|
|
|
m_progressTimer->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestNavigationWidget::onParsingFinished()
|
|
|
|
|
{
|
|
|
|
|
m_progressTimer->stop();
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-18 15:02:07 +01:00
|
|
|
void TestNavigationWidget::initializeFilterMenu()
|
|
|
|
|
{
|
|
|
|
|
QAction *action = new QAction(m_filterMenu);
|
2022-07-13 18:31:56 +02:00
|
|
|
action->setText(Tr::tr("Show Init and Cleanup Functions"));
|
2014-12-18 15:02:07 +01:00
|
|
|
action->setCheckable(true);
|
|
|
|
|
action->setChecked(false);
|
|
|
|
|
action->setData(TestTreeSortFilterModel::ShowInitAndCleanup);
|
|
|
|
|
m_filterMenu->addAction(action);
|
|
|
|
|
action = new QAction(m_filterMenu);
|
2022-07-13 18:31:56 +02:00
|
|
|
action->setText(Tr::tr("Show Data Functions"));
|
2014-12-18 15:02:07 +01:00
|
|
|
action->setCheckable(true);
|
|
|
|
|
action->setChecked(false);
|
|
|
|
|
action->setData(TestTreeSortFilterModel::ShowTestData);
|
|
|
|
|
m_filterMenu->addAction(action);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-05 13:57:22 +02:00
|
|
|
void TestNavigationWidget::onRunThisTestTriggered(TestRunMode runMode)
|
2015-04-16 14:04:36 +02:00
|
|
|
{
|
|
|
|
|
const QModelIndexList selected = m_view->selectionModel()->selectedIndexes();
|
|
|
|
|
if (selected.isEmpty())
|
|
|
|
|
return;
|
2016-06-15 12:29:24 +02:00
|
|
|
const QModelIndex &sourceIndex = m_sortFilterModel->mapToSource(selected.first());
|
2015-04-16 14:04:36 +02:00
|
|
|
if (!sourceIndex.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
2020-10-19 13:56:19 +02:00
|
|
|
ITestTreeItem *item = static_cast<ITestTreeItem *>(sourceIndex.internalPointer());
|
2017-09-09 16:46:43 +02:00
|
|
|
TestRunner::instance()->runTest(runMode, item);
|
2015-04-16 14:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-17 13:04:44 +02:00
|
|
|
void TestNavigationWidget::reapplyCachedExpandedState()
|
|
|
|
|
{
|
2020-06-18 12:32:48 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
for (TreeItem *rootNode : *m_model->rootItem()) {
|
|
|
|
|
rootNode->forAllChildren([this](TreeItem *child) {
|
2022-08-26 10:30:00 +02:00
|
|
|
std::optional<bool> cached = m_expandedStateCache.get(
|
|
|
|
|
static_cast<ITestTreeItem *>(child));
|
2020-06-18 12:32:48 +02:00
|
|
|
if (cached.has_value()) {
|
|
|
|
|
QModelIndex index = child->index();
|
|
|
|
|
if (m_view->isExpanded(index) != cached.value())
|
|
|
|
|
m_view->setExpanded(index, cached.value());
|
|
|
|
|
}
|
2020-06-17 13:04:44 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 18:24:24 +02:00
|
|
|
// TestNavigationWidgetFactory
|
|
|
|
|
|
2014-12-18 15:02:07 +01:00
|
|
|
TestNavigationWidgetFactory::TestNavigationWidgetFactory()
|
|
|
|
|
{
|
2022-07-13 18:31:56 +02:00
|
|
|
setDisplayName(Tr::tr("Tests"));
|
2014-12-18 15:02:07 +01:00
|
|
|
setId(Autotest::Constants::AUTOTEST_ID);
|
|
|
|
|
setPriority(666);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 18:24:24 +02:00
|
|
|
NavigationView TestNavigationWidgetFactory::createWidget()
|
2014-12-18 15:02:07 +01:00
|
|
|
{
|
|
|
|
|
TestNavigationWidget *treeViewWidget = new TestNavigationWidget;
|
2021-05-10 14:06:10 +02:00
|
|
|
return {treeViewWidget, treeViewWidget->createToolButtons()};
|
2014-12-18 15:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-28 18:24:24 +02:00
|
|
|
} // Autotest::Internal
|