[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevplatform/veritas
From: Manuel Breugelmans <mbr.nxi () gmail ! com>
Date: 2008-10-08 13:52:44
Message-ID: 1223473964.516902.31621.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 869210 by mbreugel:
fix a set of defects
- Test-result sync would not work for leafs, only for their parents. Fixed.
- Stop used to be soft, a running executable would not get killed. Exit the hard way instead.
- Selection & verbose toggles would wrongfully be shown for certain types of test-items. Fixed.
M +38 -28 internal/runnerwindow.cpp
M +1 -0 internal/runnerwindow.h
M +1 -1 internal/selectiontoggle.cpp
M +2 -0 internal/test_p.h
M +15 -0 internal/testexecutor.cpp
M +1 -0 internal/testexecutor.h
M +2 -2 internal/verbosetoggle.cpp
M +27 -0 test.cpp
M +11 -0 test.h
M +35 -14 tests/runnerwindowtest.cpp
M +3 -0 tests/runnerwindowtest.h
--- trunk/KDE/kdevplatform/veritas/internal/runnerwindow.cpp #869209:869210
@@ -40,6 +40,7 @@
#include "interfaces/idocumentcontroller.h"
#include "utils.h"
+#include "test_p.h"
#include "resultswidget.h"
#include <QMessageBox>
@@ -73,6 +74,7 @@
using Veritas::ResultsProxyModel;
using Veritas::VerboseManager;
using Veritas::TestExecutor;
+using Veritas::Test;
const Ui::RunnerWindow* RunnerWindow::ui() const
{
@@ -176,11 +178,33 @@
}
}
+namespace
+{
+/*! functor that counts the selected leaf tests */
+class SelectedLeafCount
+{
+public:
+ SelectedLeafCount() : result(0) {}
+ void operator()(Test* t) {
+ if ((t->childCount() == 0) && t->internal()->isChecked()) {
+ result++;
+ }
+ }
+ int result;
+};
+
+}
+
void RunnerWindow::resetProgressBar() const
{
ui()->progressRun->setValue(0);
ui()->progressRun->update();
- if (ui()->progressRun->maximum() == 0) {
+ if (runnerModel()) {
+ SelectedLeafCount slf;
+ traverseTree(runnerModel()->rootItem(), slf);
+ if (slf.result == 0) slf.result++; // 0 results in an indeterminate progressbar, not good
+ ui()->progressRun->setMaximum(slf.result);
+ } else {
ui()->progressRun->setMaximum(1);
}
}
@@ -437,43 +461,29 @@
if (numItems > 0) setRedBar();
}
+namespace
+{
+inline Test* testFromIndex(const QModelIndex& index)
+{
+ return static_cast<Test*>(index.internalPointer());
+}
+}
+
void RunnerWindow::syncResultWithTest(const QItemSelection& selected,
const QItemSelection& deselected) const
{
Q_UNUSED(deselected);
QModelIndexList indexes = selected.indexes();
- // Do nothing when there are no results or no runner item is selected.
if (indexes.count() < 1 || !runnerProxyModel()->index(0, 0).isValid()) {
- return;
+ return; // Do nothing when there are no results or no runner item is selected.
}
+
enableResultSync(false); // Prevent circular reaction
-
- // Get the results model index that corresponds to the runner item index.
- QModelIndex testItemIndex = runnerProxyModel()->mapToSource(indexes.first());
- QModelIndex resultIndex = resultsModel()->mapFromTestIndex(testItemIndex);
- QModelIndex viewIndex = resultsProxyModel()->mapFromSource(resultIndex);
-
- QModelIndex filterIndex;
- if (resultIndex.isValid() && viewIndex.isValid()) {
- resultsView()->clearSelection();
- resultsView()->setCurrentIndex(viewIndex);
- scrollToHighlightedRows();
- filterIndex = testItemIndex.parent();
- } else if (!resultIndex.isValid()) {
- filterIndex = testItemIndex;
- }
-
- if (filterIndex.isValid()) {
- Test* t = static_cast<Test*>(filterIndex.internalPointer());
+ QModelIndex testIndex = runnerProxyModel()->mapToSource(indexes.first());
+ if (testIndex.isValid()) {
+ Test* t = testFromIndex(testIndex);
resultsProxyModel()->setTestFilter(t);
}
-
- if (!resultIndex.isValid()) {
- kDebug() << "Failed to find result item for runner stuff";
- } else if (!viewIndex.isValid()) {
- kDebug() << "Looks like result is being filtered";
- }
-
enableResultSync(true);
}
--- trunk/KDE/kdevplatform/veritas/internal/runnerwindow.h #869209:869210
@@ -54,6 +54,7 @@
* in appropriate views to the user and provides commands for their
* manipulation. Runner items can be executed.
*/
+// TODO this is starting to smell like a GOD class. fix it
class VERITAS_EXPORT RunnerWindow : public QWidget
{
Q_OBJECT
--- trunk/KDE/kdevplatform/veritas/internal/selectiontoggle.cpp #869209:869210
@@ -40,7 +40,7 @@
bool SelectionToggle::shouldShow(Test* t)
{
- return t != 0;
+ return t != 0 && t->needSelectionToggle();
}
SelectionToggle::SelectionToggle(QWidget* parent) :
--- trunk/KDE/kdevplatform/veritas/internal/test_p.h #869209:869210
@@ -65,6 +65,8 @@
QMap<QString, Test*> childMap;
QList<Test*> children;
QList<QVariant> itemData;
+ bool needVerboseToggle;
+ bool needSelectionToggle;
static const int columnCount;
};
--- trunk/KDE/kdevplatform/veritas/internal/testexecutor.cpp #869209:869210
@@ -74,6 +74,18 @@
m_previous = current;
}
+/*! functor which aborts a test */
+class KillTest
+{
+public:
+ void operator()(Test* t);
+};
+
+void KillTest::operator()(Test* t)
+{
+ t->kill();
+}
+
} // end anonymous namespace
@@ -96,7 +108,10 @@
void TestExecutor::stop()
{
+ Test* root = m_root;
cleanup();
+ KillTest kt;
+ traverseTree(root, kt);
}
void TestExecutor::cleanup()
--- trunk/KDE/kdevplatform/veritas/internal/testexecutor.h #869209:869210
@@ -34,6 +34,7 @@
class VERITAS_EXPORT TestExecutor : public QObject
{
Q_OBJECT
+
public:
TestExecutor();
virtual ~TestExecutor();
--- trunk/KDE/kdevplatform/veritas/internal/verbosetoggle.cpp #869209:869210
@@ -49,6 +49,7 @@
this, SLOT(setIconOverlay()));
connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)),
this, SLOT(refreshIcon()));
+ setToolTip(i18nc("@info:tooltip", "Verbose Output"));
}
VerboseToggle::~VerboseToggle()
@@ -79,13 +80,12 @@
m_fadingTimeLine->stop();
}
m_fadingValue = 255;
- i18nc("@info:tooltip", "Verbose Output");
update();
}
bool VerboseToggle::shouldShow(Test* t)
{
- return t && t->shouldRun();
+ return t!=0 && t->needVerboseToggle();
}
void VerboseToggle::setIconOverlay()
--- trunk/KDE/kdevplatform/veritas/test.cpp #869209:869210
@@ -50,6 +50,8 @@
d->name.clear();
}
d->check();
+ d->needVerboseToggle = false;
+ d->needSelectionToggle = false;
}
Test::Test(const QString& name, Test* parent)
@@ -63,6 +65,8 @@
d->itemData << QString();
}
d->check();
+ d->needVerboseToggle = false;
+ d->needSelectionToggle = false;
}
QString Test::name() const
@@ -70,6 +74,29 @@
return d->name;
}
+void Test::kill()
+{}
+
+bool Test::needVerboseToggle() const
+{
+ return d->needVerboseToggle;
+}
+
+void Test::setVerboseToggle(bool enabled)
+{
+ d->needVerboseToggle = enabled;
+}
+
+bool Test::needSelectionToggle() const
+{
+ return d->needSelectionToggle;
+}
+
+void Test::setSelectionToggle(bool enabled)
+{
+ d->needSelectionToggle = enabled;
+}
+
Test::~Test()
{
delete d->result;
--- trunk/KDE/kdevplatform/veritas/test.h #869209:869210
@@ -63,6 +63,8 @@
class VERITAS_EXPORT Test : public QObject
{
Q_OBJECT
+Q_PROPERTY(bool verboseToggle READ needVerboseToggle WRITE setVerboseToggle)
+Q_PROPERTY(bool selectionToggle READ needSelectionToggle WRITE setSelectionToggle)
public Q_SLOTS:
@@ -71,6 +73,11 @@
public: // Operations
+ bool needVerboseToggle() const;
+ void setVerboseToggle(bool);
+ bool needSelectionToggle() const;
+ void setSelectionToggle(bool);
+
/*! Factory method that constructs a blank root test. Always use
* this method to construct test-tree roots. */
static Test* createRoot();
@@ -93,6 +100,10 @@
Implement this in a subclass. Default to not run. */
virtual bool shouldRun() const;
+ /*! Performs a hard stop if test was running, to be implemented by
+ * concrete tests. */
+ virtual void kill();
+
/*! Identifies this test. Also shown in the runnerview-tree */
QString name() const;
--- trunk/KDE/kdevplatform/veritas/tests/runnerwindowtest.cpp #869209:869210
@@ -259,34 +259,55 @@
// command
void RunnerWindowTest::clickRunnerResults()
{
- model->child11->m_state = Veritas::RunError;
+ model->child11->m_state = Veritas::RunSuccess;
+ model->child12->m_state = Veritas::RunError;
model->child21->m_state = Veritas::RunError;
runAllTests();
- // fake a click on the second root test.
- // this is expected to filter all but the result of
- // child21.
// r0
- // -child10
- // -child11 [failed]
- // r1 <- clicked
+ // -child11
+ // -child12 [failed]
+ // r1
// -child21 [failed]
+
+ // select r1 in the runner-tree
+ // since child21 has failed this item's result should now be shown in
+ // the resultsview. All other results are expected to be filtered
QModelIndex i = m_proxy->index(1,0);
m_view->selectionModel()->select(i, QItemSelectionModel::Select);
+ assertResultsProxyShowsOnly("child21");
- // since the 2nd item in the runnertree was set to fail,
- // and we selected it's parent this should be the only
- // item currently visible in the resultsview.
- QModelIndex result21 = m_resultsProxy->index(0,0);
- KVERIFY_MSG(result21.isValid(),
+ // now select child12.
+ // the results view should have been reset and show only child12's result item
+ i = m_proxy->index(0,0).child(1,0);
+ m_view->selectionModel()->select(i, QItemSelectionModel::Select);
+ assertResultsProxyShowsOnly("child12");
+
+ // now select child11
+ // since this test did pass, the results view should be empty
+ i = m_proxy->index(0,0).child(0,0);
+ m_view->selectionModel()->select(i, QItemSelectionModel::Select);
+ assertResultsProxyShowsNothing();
+}
+
+void RunnerWindowTest::assertResultsProxyShowsOnly(const QString& itemData)
+{
+ QModelIndex result = m_resultsProxy->index(0,0);
+ KVERIFY_MSG(result.isValid(),
"Was expecting to find something in the resultsview, "
"however it is empty (filtered).");
- //QTest::qWait(5000);
KVERIFY_MSG(!m_resultsProxy->index(1,0).isValid(),
"Resultsview should contain only a single item.");
- KOMPARE("child21", m_resultsProxy->data(result21));
+ KOMPARE(itemData, m_resultsProxy->data(result));
+}
+void RunnerWindowTest::assertResultsProxyShowsNothing()
+{
+ QModelIndex first = m_resultsProxy->index(0,0);
+ KVERIFY_MSG(!first.isValid(),
+ QString("Was expecting an empty resultiew but index(0,0) is valid. data: %1").
+ arg(m_resultsProxy->data(first).toString()));
}
// command
--- trunk/KDE/kdevplatform/veritas/tests/runnerwindowtest.h #869209:869210
@@ -68,6 +68,9 @@
void runAllTests();
void printModel(const QModelIndex& mi, int);
+ void assertResultsProxyShowsOnly(const QString& itemData);
+ void assertResultsProxyShowsNothing();
+
private:
Veritas::RunnerWindow* window;
Veritas::RunnerModelStub* model;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic