diff --git a/debugger/CMakeLists.txt b/debugger/CMakeLists.txt index ba8ab8cff8..ad91f8282e 100644 --- a/debugger/CMakeLists.txt +++ b/debugger/CMakeLists.txt @@ -1,64 +1,66 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kdevplatform\") set(KDevPlatformDebugger_LIB_SRCS interfaces/idebugsession.cpp interfaces/iframestackmodel.cpp interfaces/ibreakpointcontroller.cpp interfaces/ivariablecontroller.cpp util/treeitem.cpp util/treemodel.cpp util/treeview.cpp util/pathmappings.cpp util/debug.cpp breakpoint/breakpoint.cpp breakpoint/breakpointmodel.cpp breakpoint/breakpointwidget.cpp breakpoint/breakpointdetails.cpp variable/variablewidget.cpp variable/variablecollection.cpp variable/variabletooltip.cpp variable/variablesortmodel.cpp framestack/framestackmodel.cpp framestack/framestackwidget.cpp ) kdevplatform_add_library(KDevPlatformDebugger SOURCES ${KDevPlatformDebugger_LIB_SRCS}) target_link_libraries(KDevPlatformDebugger LINK_PUBLIC KDev::Interfaces KDev::Util LINK_PRIVATE Qt5::Core KF5::Notifications KF5::TextEditor KDev::Sublime ) install(FILES interfaces/idebugsession.h interfaces/ibreakpointcontroller.h interfaces/ivariablecontroller.h interfaces/iframestackmodel.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/debugger/interfaces COMPONENT Devel ) install(FILES util/treemodel.h util/treeitem.h util/treeview.h util/pathmappings.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/debugger/util COMPONENT Devel ) install(FILES breakpoint/breakpointwidget.h breakpoint/breakpointdetails.h breakpoint/breakpoint.h breakpoint/breakpointmodel.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/debugger/breakpoint COMPONENT Devel ) install(FILES variable/variablecollection.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/debugger/variable COMPONENT Devel ) install(FILES framestack/framestackmodel.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/debugger/framestack COMPONENT Devel ) + +add_subdirectory(tests) diff --git a/debugger/interfaces/ivariablecontroller.cpp b/debugger/interfaces/ivariablecontroller.cpp index 270ca242e4..55d9d091c6 100644 --- a/debugger/interfaces/ivariablecontroller.cpp +++ b/debugger/interfaces/ivariablecontroller.cpp @@ -1,129 +1,132 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2009 Niko Sams * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "ivariablecontroller.h" #include "idebugsession.h" #include "../../interfaces/icore.h" #include "../../interfaces/idebugcontroller.h" #include "../variable/variablecollection.h" #include "util/debug.h" #include "iframestackmodel.h" namespace KDevelop { IVariableController::IVariableController(IDebugSession* parent) : QObject(parent), m_activeThread(-1), m_activeFrame(-1) { connect(parent, &IDebugSession::stateChanged, this, &IVariableController::stateChanged); } VariableCollection* IVariableController::variableCollection() { if (!ICore::self()) return 0; return ICore::self()->debugController()->variableCollection(); } IDebugSession* IVariableController::session() const { return static_cast(parent()); } void IVariableController::stateChanged(IDebugSession::DebuggerState state) { if (!ICore::self() || ICore::self()->shuttingDown()) { return; } if (state == IDebugSession::ActiveState) { //variables are now outdated, update them m_activeThread = -1; m_activeFrame = -1; } else if (state == IDebugSession::EndedState || state == IDebugSession::NotStartedState) { // Remove all locals. foreach (Locals *l, variableCollection()->allLocals()) { l->deleteChildren(); l->setHasMore(false); } for (int i=0; i < variableCollection()->watches()->childCount(); ++i) { Variable *var = qobject_cast(variableCollection()->watches()->child(i)); if (var) { var->setInScope(false); } } } } void IVariableController::updateIfFrameOrThreadChanged() { IFrameStackModel *sm = session()->frameStackModel(); if (sm->currentThread() != m_activeThread || sm->currentFrame() != m_activeFrame) { - m_activeThread = sm->currentThread(); - m_activeFrame = sm->currentFrame(); variableCollection()->root()->resetChanged(); update(); } } void IVariableController::handleEvent(IDebugSession::event_t event) { if (!variableCollection()) return; switch (event) { case IDebugSession::thread_or_frame_changed: qCDebug(DEBUGGER) << m_autoUpdate; if (!(m_autoUpdate & UpdateLocals)) { foreach (Locals *l, variableCollection()->allLocals()) { if (!l->isExpanded() && !l->childCount()) { l->setHasMore(true); } } } if (m_autoUpdate != UpdateNone) { updateIfFrameOrThreadChanged(); } + + // update our cache of active thread/frame regardless of m_autoUpdate + // to keep them synced when user currently hides the variable list + m_activeThread = session()->frameStackModel()->currentThread(); + m_activeFrame = session()->frameStackModel()->currentFrame(); break; default: break; } } void IVariableController::setAutoUpdate(QFlags autoUpdate) { IDebugSession::DebuggerState state = session()->state(); m_autoUpdate = autoUpdate; qCDebug(DEBUGGER) << m_autoUpdate; if (m_autoUpdate != UpdateNone && state == IDebugSession::PausedState) { update(); } } QFlags IVariableController::autoUpdate() { return m_autoUpdate; } } diff --git a/debugger/tests/CMakeLists.txt b/debugger/tests/CMakeLists.txt new file mode 100644 index 0000000000..f9d7503b70 --- /dev/null +++ b/debugger/tests/CMakeLists.txt @@ -0,0 +1,7 @@ +ecm_add_test(test_ivariablecontroller LINK_LIBRARIES + Qt5::Core + Qt5::Test + KDev::Tests + KDev::Debugger +) + diff --git a/debugger/tests/test_ivariablecontroller.cpp b/debugger/tests/test_ivariablecontroller.cpp new file mode 100644 index 0000000000..1f8fc050bb --- /dev/null +++ b/debugger/tests/test_ivariablecontroller.cpp @@ -0,0 +1,94 @@ +/* + * KDevelop Debugger Support + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "test_ivariablecontroller.h" + +#include +#include +#include +#include +#include +#include + +#include + +QTEST_MAIN(KDevelop::TestIVariableController); + +using namespace KDevelop; + +TestIVariableController::TestIVariableController(QObject* parent) + : QObject(parent) + , m_debugSession(nullptr) +{ +} + +void TestIVariableController::initTestCase() +{ + AutoTestShell::init(); + TestCore::initialize(Core::NoUi); + m_debugSession = new TestDebugSession(); + // Simulate an already started and paused debug session + m_debugSession->runToCursor(); +} + +void KDevelop::TestIVariableController::updateRightAfterEnableAutoUpdate_data() +{ + QTest::addColumn("startAt"); + QTest::addColumn("switchTo"); + QTest::addColumn("jumpTo"); + + QTest::newRow("jump to somewhere else") << 1 << 0 << 2; + QTest::newRow("jump back") << 1 << 0 << 1; +} + +void TestIVariableController::updateRightAfterEnableAutoUpdate() +{ + QFETCH(int, startAt); + QFETCH(int, switchTo); + QFETCH(int, jumpTo); + + auto frameStackModel = m_debugSession->frameStackModel(); + auto variableController = qobject_cast(m_debugSession->variableController()); + if (!variableController) { + return; + } + + frameStackModel->setCurrentThread(0); + frameStackModel->setCurrentFrame(startAt); + + int oldCounter = variableController->updatedTimes(); + + variableController->setAutoUpdate(IVariableController::UpdateNone); + frameStackModel->setCurrentFrame(switchTo); // no update + variableController->setAutoUpdate(IVariableController::UpdateLocals); // trigger update + // switch back to frame we were at before disable auto update + frameStackModel->setCurrentFrame(jumpTo); // trigger another update + + int updatedTimes = variableController->updatedTimes() - oldCounter; + QCOMPARE(updatedTimes, 2); +} + +void TestIVariableController::cleanupTestCase() +{ + delete m_debugSession; + TestCore::shutdown(); +} diff --git a/debugger/tests/test_ivariablecontroller.h b/debugger/tests/test_ivariablecontroller.h new file mode 100644 index 0000000000..4f7d44f2f4 --- /dev/null +++ b/debugger/tests/test_ivariablecontroller.h @@ -0,0 +1,53 @@ +/* + * KDevelop Debugger Support + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#ifndef KDEVPLATFORM_TEST_IVARIABLECONTROLLER_H +#define KDEVPLATFORM_TEST_IVARIABLECONTROLLER_H + +#include + +namespace KDevelop +{ +class TestDebugSession; + +class TestIVariableController : public QObject +{ +Q_OBJECT +public: + explicit TestIVariableController(QObject* parent = nullptr); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + + /** + * Test for bug 333759. see https://bugs.kde.org/show_bug.cgi?id=333759 + */ + void updateRightAfterEnableAutoUpdate(); + void updateRightAfterEnableAutoUpdate_data(); + +private: + TestDebugSession *m_debugSession; +}; + +} +#endif // KDEVPLATFORM_TEST_IVARIABLECONTROLLER_H diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc6632b8e8..961d0cea96 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,53 +1,62 @@ set(kdevtests_LIB_SRCS autotestshell.cpp kdevsignalspy.cpp testcore.cpp testproject.cpp testfile.cpp testlanguagecontroller.cpp testhelpers.cpp testplugincontroller.cpp + testdebugsession.cpp + testvariablecontroller.cpp + testbreakpointcontroller.cpp + testframestackmodel.cpp modeltest.cpp json/delayedoutput.cpp json/declarationvalidator.cpp json/testsuite.cpp ) kdevplatform_add_library(KDevPlatformTests SOURCES ${kdevtests_LIB_SRCS}) target_link_libraries(KDevPlatformTests LINK_PUBLIC KDev::Shell KDev::Language KDev::Project + KDev::Debugger ) target_link_libraries(KDevPlatformTests LINK_PRIVATE Qt5::Core Qt5::Test ) install(FILES autotestshell.h kdevsignalspy.h modeltest.h testcore.h testproject.h testfile.h testlanguagecontroller.h testhelpers.h testplugincontroller.h + testdebugsession.h + testvariablecontroller.h + testbreakpointcontroller.h + testframestackmodel.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/tests/ COMPONENT Devel ) install(FILES json/declarationvalidator.h json/delayedoutput.h json/jsontesthelpers.h json/testsuite.h json/testsuite.cpp json/jsondeclarationtests.h json/jsonducontexttests.h json/jsontypetests.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/tests/json COMPONENT Devel ) diff --git a/tests/testbreakpointcontroller.cpp b/tests/testbreakpointcontroller.cpp new file mode 100644 index 0000000000..d9ccf65631 --- /dev/null +++ b/tests/testbreakpointcontroller.cpp @@ -0,0 +1,37 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "testbreakpointcontroller.h" + +using namespace KDevelop; + +TestBreakpointController::TestBreakpointController(IDebugSession *parent) + : IBreakpointController(parent) +{ + +} + +void TestBreakpointController::sendMaybe(Breakpoint *breakpoint) +{ + Q_UNUSED(breakpoint); +} diff --git a/tests/testbreakpointcontroller.h b/tests/testbreakpointcontroller.h new file mode 100644 index 0000000000..d9f2dade2f --- /dev/null +++ b/tests/testbreakpointcontroller.h @@ -0,0 +1,48 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef TESTBREAKPOINTCONTROLLER_H +#define TESTBREAKPOINTCONTROLLER_H + +#include "testsexport.h" + +#include + +namespace KDevelop { + +/** + * Dummy BreakpointController + */ +class KDEVPLATFORMTESTS_EXPORT TestBreakpointController : public IBreakpointController +{ + Q_OBJECT + +public: + explicit TestBreakpointController(IDebugSession *parent); + +protected: + void sendMaybe(Breakpoint *breakpoint) override; +}; + +} // end of namespace KDevelop +#endif // TESTBREAKPOINTCONTROLLER_H diff --git a/tests/testdebugsession.cpp b/tests/testdebugsession.cpp new file mode 100644 index 0000000000..6d58d57573 --- /dev/null +++ b/tests/testdebugsession.cpp @@ -0,0 +1,155 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "testdebugsession.h" + +#include "testbreakpointcontroller.h" +#include "testvariablecontroller.h" +#include "testframestackmodel.h" + +using namespace KDevelop; + +TestDebugSession::TestDebugSession() + : m_breakpointController(nullptr) + , m_variableController(nullptr) + , m_frameStackModel(nullptr) + , m_sessionState(NotStartedState) +{ + setBreakpointController(nullptr); + setVariableController(nullptr); + setFrameStackModel(nullptr); +} + +TestDebugSession::~TestDebugSession() +{ + delete m_breakpointController; + delete m_variableController; + delete m_frameStackModel; +} + +void TestDebugSession::setBreakpointController(IBreakpointController *breakpointController) +{ + delete m_breakpointController; + m_breakpointController = breakpointController; + if (!m_breakpointController) { + m_breakpointController = new TestBreakpointController(this); + } +} + +void TestDebugSession::setVariableController(IVariableController *variableController) +{ + delete m_variableController; + m_variableController = variableController; + if (!m_variableController) { + m_variableController = new TestVariableController(this); + } +} + +void TestDebugSession::setFrameStackModel(IFrameStackModel *frameStackModel) +{ + delete m_frameStackModel; + m_frameStackModel = frameStackModel; + if (!m_frameStackModel) { + m_frameStackModel = new TestFrameStackModel(this); + } +} + +IDebugSession::DebuggerState TestDebugSession::state() const +{ + return m_sessionState; +} + +bool TestDebugSession::restartAvaliable() const +{ + return true; +} + +IBreakpointController* TestDebugSession::breakpointController() const +{ + return m_breakpointController; +} + +IVariableController* TestDebugSession::variableController() const +{ + return m_variableController; +} + +IFrameStackModel* TestDebugSession::frameStackModel() const +{ + return m_frameStackModel; +} + +void TestDebugSession::restartDebugger() +{ + m_sessionState = ActiveState; +} + +void TestDebugSession::stopDebugger() +{ + m_sessionState = StoppedState; +} + +void TestDebugSession::interruptDebugger() +{ + m_sessionState = StoppedState; +} + +void TestDebugSession::run() +{ + m_sessionState = ActiveState; +} + +void TestDebugSession::runToCursor() +{ + m_sessionState = PausedState; +} + +void TestDebugSession::jumpToCursor() +{ + m_sessionState = PausedState; +} + +void TestDebugSession::stepOver() +{ + m_sessionState = PausedState; +} + +void TestDebugSession::stepIntoInstruction() +{ + m_sessionState = PausedState; +} + +void TestDebugSession::stepInto() +{ + m_sessionState = PausedState; +} + +void TestDebugSession::stepOverInstruction() +{ + m_sessionState = PausedState; +} + +void TestDebugSession::stepOut() +{ + m_sessionState = PausedState; +} diff --git a/tests/testdebugsession.h b/tests/testdebugsession.h new file mode 100644 index 0000000000..690ec6053c --- /dev/null +++ b/tests/testdebugsession.h @@ -0,0 +1,111 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef TESTDEBUGSESSION_H +#define TESTDEBUGSESSION_H + +#include "testsexport.h" + +#include + +#include + +using std::unique_ptr; + +namespace KDevelop { + +class IBreakpointController; +class IVariableController; +class IFrameStackModel; + +/** + * \class TestDebugSession testdebugsession.h + * + * This is an IDebugSession implementation that should be used only inside + * unit tests. + * + * The initial debug state is NotStartedState, one can use normal slots to + * change the state, for example calling runToCursor() changes to PausedState. + * See corresponding implementation for what state a specific slot changes to. + * + * This class also allows one to replace IBreakpointController, IVariableController, + * or IFrameStackModel implementation with custom implementation to make it possible + * to write tests more easily. + * + * The usage is as follows: + * \code + * AutoTestShell::init(); + * TestCore::initialize(Core::NoUi); + * TestDebugSession* session = new TestDebugSession(); + * //replace variable controller or similar + * session->setVariableController(new MyCustomVariableController(session)); + * ... //test code + * delete session; + * TestCore::shutdown(); + * \endcode + * + * @note It is important to set custom controllers right after the creation of the + * debug session, and not change them inside the test code, as required by + * IDebugSession that controllers do not change during the lifetime of a session + */ +class KDEVPLATFORMTESTS_EXPORT TestDebugSession : public IDebugSession +{ + Q_OBJECT + +public: + TestDebugSession(); + ~TestDebugSession() override; + + void setBreakpointController(IBreakpointController *breakpointController); + void setVariableController(IVariableController *variableController); + void setFrameStackModel(IFrameStackModel *frameStackModel); + + DebuggerState state() const override; + + bool restartAvaliable() const override; + IBreakpointController* breakpointController() const override; + IVariableController* variableController() const override; + IFrameStackModel* frameStackModel() const override; + +public Q_SLOTS: + void restartDebugger() override; + void stopDebugger() override; + void interruptDebugger() override; + void run() override; + void runToCursor() override; + void jumpToCursor() override; + void stepOver() override; + void stepIntoInstruction() override; + void stepInto() override; + void stepOverInstruction() override; + void stepOut() override; + +private: + IBreakpointController *m_breakpointController; + IVariableController *m_variableController; + IFrameStackModel *m_frameStackModel; + DebuggerState m_sessionState; +}; + +} // end of namespace KDevelop +#endif // TESTDEBUGSESSION_H diff --git a/tests/testframestackmodel.cpp b/tests/testframestackmodel.cpp new file mode 100644 index 0000000000..99f70245fc --- /dev/null +++ b/tests/testframestackmodel.cpp @@ -0,0 +1,43 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "testframestackmodel.h" + +using namespace KDevelop; + +TestFrameStackModel::TestFrameStackModel(IDebugSession *parent) + : FrameStackModel(parent) +{ +} + +void TestFrameStackModel::fetchThreads() +{ + +} + +void TestFrameStackModel::fetchFrames(int threadNumber, int from, int to) +{ + Q_UNUSED(threadNumber); + Q_UNUSED(from); + Q_UNUSED(to); +} diff --git a/tests/testframestackmodel.h b/tests/testframestackmodel.h new file mode 100644 index 0000000000..089dff6429 --- /dev/null +++ b/tests/testframestackmodel.h @@ -0,0 +1,51 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef TESTFRAMESTACKMODEL_H +#define TESTFRAMESTACKMODEL_H + +#include "testsexport.h" + +#include + +namespace KDevelop { + +/** + * Dummy frame stack model + */ +class KDEVPLATFORMTESTS_EXPORT TestFrameStackModel : public FrameStackModel +{ + Q_OBJECT + +public: + explicit TestFrameStackModel(IDebugSession *parent); + +protected: + void fetchThreads() override; + void fetchFrames(int threadNumber, int from, int to) override; + +private: +}; + +} // end of namespace KDevelop +#endif // TESTFRAMESTACKMODEL_H diff --git a/tests/testvariablecontroller.cpp b/tests/testvariablecontroller.cpp new file mode 100644 index 0000000000..659e27bb97 --- /dev/null +++ b/tests/testvariablecontroller.cpp @@ -0,0 +1,77 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "testvariablecontroller.h" + +using namespace KDevelop; +using KTextEditor::Range; +using KTextEditor::Document; +using KTextEditor::Cursor; + +TestVariableController::TestVariableController(IDebugSession* parent) + : IVariableController(parent) + , m_updatedTimes(0) +{ + +} + +Variable* TestVariableController::createVariable(TreeModel* model, TreeItem* parent, + const QString& expression, + const QString& display) +{ + Q_UNUSED(model); + Q_UNUSED(parent); + Q_UNUSED(expression); + Q_UNUSED(display); + + return nullptr; +} + +Range TestVariableController::expressionRangeUnderCursor(Document* doc, + const Cursor& cursor) +{ + Q_UNUSED(doc); + Q_UNUSED(cursor); + + return {}; +} + +void TestVariableController::addWatch(Variable* variable) +{ + Q_UNUSED(variable); +} + +void TestVariableController::addWatchpoint(Variable* variable) +{ + Q_UNUSED(variable); +} + +void TestVariableController::update() +{ + ++m_updatedTimes; +} + +int TestVariableController::updatedTimes() const +{ + return m_updatedTimes; +} diff --git a/tests/testvariablecontroller.h b/tests/testvariablecontroller.h new file mode 100644 index 0000000000..d22476bfa1 --- /dev/null +++ b/tests/testvariablecontroller.h @@ -0,0 +1,66 @@ +/* + * This file is part of KDevelop + * + * Copyright 2016 Aetf + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef TESTVARIABLECONTROLLER_H +#define TESTVARIABLECONTROLLER_H + +#include "testsexport.h" + +#include + +namespace KDevelop { + +/** + * Dummy VariableController that does nothing. + */ +class KDEVPLATFORMTESTS_EXPORT TestVariableController : public IVariableController +{ + Q_OBJECT + +public: + explicit TestVariableController(IDebugSession* parent); + + Variable* createVariable(TreeModel* model, TreeItem* parent, + const QString& expression, + const QString& display = {}) override; + + KTextEditor::Range expressionRangeUnderCursor(KTextEditor::Document* doc, + const KTextEditor::Cursor& cursor) override; + + void addWatch(Variable* variable) override; + void addWatchpoint(Variable* variable) override; + + /** + * Number of times update() has been called since creation. + */ + int updatedTimes() const; + +protected: + void update() override; + +private: + int m_updatedTimes; +}; + +} // end of namespace KDevelop +#endif // TESTVARIABLECONTROLLER_H