diff --git a/tests/fuzzer/Fuzzer.cpp b/tests/fuzzer/Fuzzer.cpp index b4c559ed..a24327ef 100644 --- a/tests/fuzzer/Fuzzer.cpp +++ b/tests/fuzzer/Fuzzer.cpp @@ -83,9 +83,9 @@ void Fuzzer::runTest(const Test &test) createLayout(test.initialLayout); int index = 0; for (const auto &op : test.operations) { - qDebug() << "Running" << op->description(); index++; op->execute(); + qDebug() << "Ran" << op->description(); QTest::qWait(m_operationDelayMS); DockRegistry::self()->checkSanityAll(); } diff --git a/tests/fuzzer/Operations.cpp b/tests/fuzzer/Operations.cpp index 1ae0e899..3b1ca13c 100644 --- a/tests/fuzzer/Operations.cpp +++ b/tests/fuzzer/Operations.cpp @@ -154,11 +154,6 @@ CloseViaDockWidgetAPI::CloseViaDockWidgetAPI(Fuzzer *fuzzer) { } -QString CloseViaDockWidgetAPI::description() const -{ - return QStringLiteral("Closing %1").arg(dockStr(m_dockWidgetName)); -} - void CloseViaDockWidgetAPI::generateRandomParams() { if (DockWidgetBase *dw = m_fuzzer->getRandomDockWidget()) @@ -173,6 +168,7 @@ bool CloseViaDockWidgetAPI::hasParams() const void CloseViaDockWidgetAPI::execute_impl() { + m_description = QStringLiteral("Closing %1").arg(dockStr(m_dockWidgetName)); DockWidgetBase *dw = dockByName(dockStr(m_dockWidgetName)); auto fw = qobject_cast(dw->window()); dw->close(); @@ -198,11 +194,6 @@ HideViaDockWidgetAPI::HideViaDockWidgetAPI(Fuzzer *fuzzer) { } -QString HideViaDockWidgetAPI::description() const -{ - return QStringLiteral("Hidding %1").arg(dockStr(m_dockWidgetName)); -} - void HideViaDockWidgetAPI::generateRandomParams() { if (DockWidgetBase *dw = m_fuzzer->getRandomDockWidget()) @@ -217,6 +208,7 @@ bool HideViaDockWidgetAPI::hasParams() const void HideViaDockWidgetAPI::execute_impl() { + m_description = QStringLiteral("Hidding %1").arg(dockStr(m_dockWidgetName)); DockWidgetBase *dw = dockByName(dockStr(m_dockWidgetName)); auto fw = qobject_cast(dw->window()); dw->close(); @@ -242,11 +234,6 @@ ShowViaDockWidgetAPI::ShowViaDockWidgetAPI(Fuzzer *fuzzer) { } -QString ShowViaDockWidgetAPI::description() const -{ - return QStringLiteral("Showing %1").arg(dockStr(m_dockWidgetName)); -} - void ShowViaDockWidgetAPI::generateRandomParams() { if (DockWidgetBase *dw = m_fuzzer->getRandomDockWidget()) @@ -261,6 +248,7 @@ bool ShowViaDockWidgetAPI::hasParams() const void ShowViaDockWidgetAPI::execute_impl() { + m_description = QStringLiteral("Showing %1").arg(dockStr(m_dockWidgetName)); DockWidgetBase *dw = dockByName(m_dockWidgetName); dw->show(); } @@ -283,17 +271,6 @@ AddDockWidget::AddDockWidget(Fuzzer *fuzzer) { } -QString AddDockWidget::description() const -{ - if (!hasParams()) - return QStringLiteral("null"); - - if (m_params->relativeToName.isEmpty()) - return QStringLiteral("AddDockWidget %1 to %2").arg(dockStr(m_params->dockWidgetName)).arg(KDDockWidgets::locationStr(m_params->location)); - else - return QStringLiteral("AddDockWidget %1 to %2, relative to %3").arg(dockStr(m_params->dockWidgetName)).arg(KDDockWidgets::locationStr(m_params->location)).arg(dockStr(m_params->relativeToName)); -} - void AddDockWidget::generateRandomParams() { m_params = m_fuzzer->getRandomAddDockWidgetParams(); @@ -306,6 +283,11 @@ bool AddDockWidget::hasParams() const void AddDockWidget::execute_impl() { + if (m_params->relativeToName.isEmpty()) + m_description = QStringLiteral("AddDockWidget %1 to %2").arg(dockStr(m_params->dockWidgetName)).arg(KDDockWidgets::locationStr(m_params->location)); + else + m_description = QStringLiteral("AddDockWidget %1 to %2, relative to %3").arg(dockStr(m_params->dockWidgetName)).arg(KDDockWidgets::locationStr(m_params->location)).arg(dockStr(m_params->relativeToName)); + auto fw = qobject_cast(m_params->dockWidget()->window()); m_params->mainWindow()->addDockWidget(m_params->dockWidget(), m_params->location, m_params->relativeTo(), m_params->addingOption); @@ -329,14 +311,6 @@ AddDockWidgetAsTab::AddDockWidgetAsTab(Fuzzer *fuzzer) { } -QString AddDockWidgetAsTab::description() const -{ - if (!hasParams()) - return QStringLiteral("null"); - - return QStringLiteral("AddDockWidgetAsTab %1 onto %2").arg(dockStr(m_dockWidgetToAddName), dockStr(m_dockWidgetName)); -} - void AddDockWidgetAsTab::generateRandomParams() { DockWidgetBase *dw = m_fuzzer->getRandomDockWidget(); @@ -368,6 +342,7 @@ bool AddDockWidgetAsTab::hasParams() const void AddDockWidgetAsTab::execute_impl() { + m_description = QStringLiteral("AddDockWidgetAsTab %1 onto %2").arg(dockStr(m_dockWidgetToAddName), dockStr(m_dockWidgetName)); DockWidgetBase *dw = dockByName(m_dockWidgetName); DockWidgetBase *dw2 = dockByName(m_dockWidgetToAddName); diff --git a/tests/fuzzer/Operations.h b/tests/fuzzer/Operations.h index 74d9bb69..8177294f 100644 --- a/tests/fuzzer/Operations.h +++ b/tests/fuzzer/Operations.h @@ -70,7 +70,7 @@ public: static OperationBase::Ptr newOperation(Fuzzer *fuzzer, OperationType); OperationType type() const { return m_operationType; } - virtual QString description() const = 0; + QString description() const { return m_description; } protected: virtual bool hasParams() const = 0; @@ -85,6 +85,7 @@ protected: const OperationType m_operationType; Fuzzer *const m_fuzzer; int m_sleepMS = 0; + QString m_description; }; class CloseViaDockWidgetAPI : public OperationBase @@ -93,7 +94,6 @@ public: explicit CloseViaDockWidgetAPI(Fuzzer *); protected: - QString description() const override; void generateRandomParams() override; bool hasParams() const override; void execute_impl() override; @@ -108,7 +108,6 @@ public: explicit HideViaDockWidgetAPI(Fuzzer *); protected: - QString description() const override; void generateRandomParams() override; bool hasParams() const override; void execute_impl() override; @@ -123,7 +122,6 @@ public: explicit ShowViaDockWidgetAPI(Fuzzer *); protected: - QString description() const override; void generateRandomParams() override; bool hasParams() const override; void execute_impl() override; @@ -138,7 +136,6 @@ public: explicit AddDockWidget(Fuzzer *); protected: - QString description() const override; void generateRandomParams() override; bool hasParams() const override; void execute_impl() override; @@ -154,7 +151,6 @@ public: explicit AddDockWidgetAsTab(Fuzzer *); protected: - QString description() const override; void generateRandomParams() override; bool hasParams() const override; void execute_impl() override; diff --git a/tests/fuzzer/testcases/3.json b/tests/fuzzer/testcases/3.json index cd547081..b6b54043 100644 --- a/tests/fuzzer/testcases/3.json +++ b/tests/fuzzer/testcases/3.json @@ -104,7 +104,7 @@ }, "operations": [ { - "comment": "AddDockWidget DockWidget-2-[hidden] to left", + "comment": "AddDockWidget DockWidget-2 to left", "params": { "addingOption": 0, "dockWidgetName": "DockWidget-2", @@ -124,7 +124,7 @@ "type": 4 }, { - "comment": "AddDockWidgetAsTab DockWidget-3-[hidden] onto DockWidget-2-[hidden]", + "comment": "AddDockWidgetAsTab DockWidget-3 onto DockWidget-2", "params": { "dockWidgetName": "DockWidget-2", "dockWidgetToAddName": "DockWidget-3" @@ -143,7 +143,7 @@ "type": 4 }, { - "comment": "AddDockWidgetAsTab DockWidget-5-[hidden] onto DockWidget-3-[hidden]", + "comment": "AddDockWidgetAsTab DockWidget-5 onto DockWidget-3", "params": { "dockWidgetName": "DockWidget-3", "dockWidgetToAddName": "DockWidget-5" @@ -151,7 +151,7 @@ "type": 5 }, { - "comment": "AddDockWidgetAsTab DockWidget-4 onto DockWidget-5-[hidden]", + "comment": "AddDockWidgetAsTab DockWidget-4 onto DockWidget-5", "params": { "dockWidgetName": "DockWidget-5", "dockWidgetToAddName": "DockWidget-4" @@ -159,7 +159,7 @@ "type": 5 }, { - "comment": "AddDockWidgetAsTab DockWidget-2-[hidden] onto DockWidget-4", + "comment": "AddDockWidgetAsTab DockWidget-2 onto DockWidget-4", "params": { "dockWidgetName": "DockWidget-4", "dockWidgetToAddName": "DockWidget-2"