forked from qt-creator/qt-creator
AutoTest: Access plugin singleton through static functions
It's the more common pattern nowadays, and cheaper. Change-Id: If6217b2a820fbfa6f088fd9349225f5f8488f593 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -87,14 +87,9 @@ AutotestPlugin::~AutotestPlugin()
|
||||
delete m_frameworkManager;
|
||||
}
|
||||
|
||||
AutotestPlugin *AutotestPlugin::instance()
|
||||
QSharedPointer<TestSettings> AutotestPlugin::settings()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
QSharedPointer<TestSettings> AutotestPlugin::settings() const
|
||||
{
|
||||
return m_settings;
|
||||
return s_instance->m_settings;
|
||||
}
|
||||
|
||||
void AutotestPlugin::initializeMenuEntries()
|
||||
|
||||
@@ -47,14 +47,12 @@ public:
|
||||
AutotestPlugin();
|
||||
~AutotestPlugin();
|
||||
|
||||
static AutotestPlugin *instance();
|
||||
|
||||
QSharedPointer<TestSettings> settings() const;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) override;
|
||||
void extensionsInitialized() override;
|
||||
ShutdownFlag aboutToShutdown() override;
|
||||
void updateMenuItemsEnabledState();
|
||||
|
||||
static QSharedPointer<TestSettings> settings();
|
||||
static void updateMenuItemsEnabledState();
|
||||
|
||||
private:
|
||||
bool checkLicense();
|
||||
|
||||
@@ -77,7 +77,7 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::instance()->settings()->processArgs) {
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
arguments << filterInterfering(runnable().commandLineArguments.split(
|
||||
' ', QString::SkipEmptyParts), omitted);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) co
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::instance()->settings()->processArgs) {
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
arguments.append(QTestUtils::filterInterfering(
|
||||
runnable().commandLineArguments.split(' ', QString::SkipEmptyParts),
|
||||
omitted, false));
|
||||
|
||||
@@ -64,7 +64,7 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted)
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::instance()->settings()->processArgs) {
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
arguments.append(QTestUtils::filterInterfering
|
||||
(runnable().commandLineArguments.split(' ', QString::SkipEmptyParts),
|
||||
omitted, true));
|
||||
|
||||
@@ -174,7 +174,7 @@ void TestCodeParser::updateTestTree(ITestParser *parser)
|
||||
|
||||
static QStringList filterFiles(const QString &projectDir, const QStringList &files)
|
||||
{
|
||||
const QSharedPointer<TestSettings> &settings = AutotestPlugin::instance()->settings();
|
||||
const QSharedPointer<TestSettings> &settings = AutotestPlugin::settings();
|
||||
const QSet<QString> &filters = settings->whiteListFilters.toSet(); // avoid duplicates
|
||||
if (!settings->filterScan || filters.isEmpty())
|
||||
return files;
|
||||
|
||||
@@ -168,7 +168,7 @@ QSharedPointer<IFrameworkSettings> TestFrameworkManager::settingsForTestFramewor
|
||||
|
||||
void TestFrameworkManager::synchronizeSettings(QSettings *s)
|
||||
{
|
||||
AutotestPlugin::instance()->settings()->fromSettings(s);
|
||||
AutotestPlugin::settings()->fromSettings(s);
|
||||
for (const Core::Id &id : m_frameworkSettings.keys()) {
|
||||
QSharedPointer<IFrameworkSettings> fSettings = settingsForTestFramework(id);
|
||||
if (!fSettings.isNull())
|
||||
|
||||
@@ -105,8 +105,7 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
if (selected) {
|
||||
output.replace('\n', QChar::LineSeparator);
|
||||
|
||||
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
||||
&& output.length() > outputLimit)
|
||||
if (AutotestPlugin::settings()->limitResultOutput && output.length() > outputLimit)
|
||||
output = output.left(outputLimit).append("...");
|
||||
|
||||
recalculateTextLayout(index, output, painter->font(), positions.textAreaWidth());
|
||||
@@ -163,8 +162,7 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
|
||||
QString output = testResult->outputString(selected);
|
||||
output.replace('\n', QChar::LineSeparator);
|
||||
|
||||
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
||||
&& output.length() > outputLimit)
|
||||
if (AutotestPlugin::settings()->limitResultOutput && output.length() > outputLimit)
|
||||
output = output.left(outputLimit).append("...");
|
||||
|
||||
recalculateTextLayout(index, output, opt.font, positions.textAreaWidth());
|
||||
|
||||
@@ -268,7 +268,7 @@ void TestResultsPane::clearContents()
|
||||
setIconBadgeNumber(0);
|
||||
navigateStateChanged();
|
||||
m_summaryWidget->setVisible(false);
|
||||
m_autoScroll = AutotestPlugin::instance()->settings()->autoScroll;
|
||||
m_autoScroll = AutotestPlugin::settings()->autoScroll;
|
||||
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
||||
m_textOutput->clear();
|
||||
@@ -413,7 +413,7 @@ void TestResultsPane::onRunSelectedTriggered()
|
||||
|
||||
void TestResultsPane::initializeFilterMenu()
|
||||
{
|
||||
const bool omitIntern = AutotestPlugin::instance()->settings()->omitInternalMssg;
|
||||
const bool omitIntern = AutotestPlugin::settings()->omitInternalMssg;
|
||||
// FilterModel has all messages enabled by default
|
||||
if (omitIntern)
|
||||
m_filterModel->toggleTestResultType(Result::MessageInternal);
|
||||
@@ -490,7 +490,7 @@ void TestResultsPane::onTestRunStarted()
|
||||
{
|
||||
m_testRunning = true;
|
||||
m_stopTestRun->setEnabled(true);
|
||||
AutotestPlugin::instance()->updateMenuItemsEnabledState();
|
||||
AutotestPlugin::updateMenuItemsEnabledState();
|
||||
m_summaryWidget->setVisible(false);
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ void TestResultsPane::onTestRunFinished()
|
||||
m_testRunning = false;
|
||||
m_stopTestRun->setEnabled(false);
|
||||
|
||||
AutotestPlugin::instance()->updateMenuItemsEnabledState();
|
||||
AutotestPlugin::updateMenuItemsEnabledState();
|
||||
updateSummaryLabel();
|
||||
m_summaryWidget->setVisible(true);
|
||||
m_model->removeCurrentTestMessage();
|
||||
|
||||
@@ -393,7 +393,7 @@ void TestRunner::runTests()
|
||||
}
|
||||
|
||||
QFuture<TestResultPtr> future = Utils::runAsync(&performTestRun, m_selectedTests,
|
||||
*AutotestPlugin::instance()->settings());
|
||||
*AutotestPlugin::settings());
|
||||
m_futureWatcher.setFuture(future);
|
||||
Core::ProgressManager::addTask(future, tr("Running Tests"), Autotest::Constants::TASK_INDEX);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user