http://code.google.com/p/gtest-runner-qt/source/detail?r=30
Added:
/trunk/include/TestTreeItem.h
/trunk/include/TestTreeModel.h
/trunk/src/TestTreeItem.cpp
/trunk/src/TestTreeModel.cpp
/trunk/src/main.cpp
Deleted:
/trunk/main.cpp
Modified:
/trunk/GTestRunner.pro
/trunk/Makefile
/trunk/Makefile.Debug
/trunk/Makefile.Release
/trunk/include/GTestExecutable.h
/trunk/include/GTestRunner.h
/trunk/include/GTestSuiteResults.h
/trunk/src/GTestExecutable.cpp
/trunk/src/GTestRunner.cpp
/trunk/src/GTestSuite.cpp
=======================================
--- /dev/null
+++ /trunk/include/TestTreeItem.h Sat Sep 25 09:25:39 2010
@@ -0,0 +1,146 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * TestTreeItem.h - Created on 2010-08-28
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#ifndef TESTTREEITEM_H_
+#define TESTTREEITEM_H_
+
+#include <QList>
+#include <QMap>
+#include <QQueue>
+#include <QVariant>
+
+/*! \brief A constituent item of the TestTreeModel.
+ *
+ * TestTreeItems make up the body of the TestTreeModel. They are what hold
the data
+ * and the relations between them. Together, the items form a tree which
reflects
+ * the relations between an executable to a test suite to a test case.
+ * \todo Should I just make this a full blown private subclass of QList?
+ */
+class TestTreeItem {
+
+public:
+ TestTreeItem(QMap<int, QVariant>& data, TestTreeItem* parent = 0);
+ ~TestTreeItem();
+
+ void appendChild(TestTreeItem *child);
+ TestTreeItem* child(int row) const;
+ int childCount() const;
+ QList<TestTreeItem*> children() const;
+ int column() const;
+ int columnCount() const;
+ QVariant data(int role) const;
+ QMap<int, QVariant> data() const;
+ TestTreeItem* findChild(const QVariant& value, int role) const;
+ bool insertChild(int row, TestTreeItem* child);
+ bool insertChildren(int row, QList<TestTreeItem*> children);
+ TestTreeItem* parent();
+ bool removeChild(TestTreeItem* child);
+ void removeChildAt(int index);
+ int row() const;
+ bool setData(const QVariant& value, int role);
+ bool setData(const QMap<int, QVariant>& data);
+
+private:
+ QList<TestTreeItem*> childItems; //!< The children of the TestTreeItem
+ QMap<int, QVariant> itemData; //!< The data for this item.
+ TestTreeItem* parentItem; //!< The parent of this item.
+};
+
+/*! \brief Removes the child specified at the index given.
+ *
+ * If the index given is larger than the number of children, or less
+ * than 0, this function does nothing.
+ * \param index The index of the child to remove.
+ */
+inline void TestTreeItem::removeChildAt(int index) {
childItems.removeAt(index); }
+
+/*! \brief Removes the child given from this tree item.
+ *
+ * \param child The child to remove.
+ * \return true if the child is removed, false otherwise.
+ */
+inline bool TestTreeItem::removeChild(TestTreeItem* child) { return
childItems.removeOne(child); }
+
+/*! \brief Retrieves a pointer to the child in row 'row'.
+ *
+ * If the row is invalid (less than 0 or greater or equal to the number
+ * of children, a null pointer is returned.
+ * \param row The index of the child.
+ * \return null if row is invalid, a pointer to the child in row 'row
otherwise.
+ */
+inline TestTreeItem* TestTreeItem::child(int row) const { return
childItems.value(row); }
+
+/*! \brief Retrieves a list of all the children held by this item.
+ *
+ * \return A list of the children held by this item.
+ */
+inline QList<TestTreeItem*> TestTreeItem::children() const { return
childItems; }
+
+/*! \brief Retrieves the number of children held by this object.
+ *
+ * \return The number of children.
+ */
+inline int TestTreeItem::childCount() const { return childItems.count(); }
+
+/*! \brief Retrieves the number of columns this index has.
+ *
+ * Currently, this is fixed at one, but this may be changed in the future.
+ * \return The number of columns (one).
+ */
+inline int TestTreeItem::columnCount() const { return 1; }
+
+/*! \brief Inserts a child in this item before the item indexed at row.
+ *
+ * The row parameter will become the index of this child when inserted.
+ * If the index is greater than the number of children, or less than 0,
+ * this function does nothing and returns false.
+ * \param row The row to insert this item before.
+ * \param child The child to insert into this item.
+ * \return true if the child was successfully inserted, false otherwise.
+ */
+inline bool TestTreeItem::insertChild(int row, TestTreeItem* child) {
+ if(row < 0 || row > childItems.size())
+ return false;
+ childItems.insert(row, child);
+ return true;
+}
+
+/*! \brief Inserts the list of children given at the index 'row'.
+ *
+ * The row parameter will become the index of the first item in
+ * the list. If the row parameter is greater than the number of children
+ * or less than 0, this function does nothing and returns false.
+ * \param row The row to insert this item before.
+ * \param children The list of children to insert into this item.
+ * \return true if the children were successfully inserted, false
otherwise.
+ */
+inline bool TestTreeItem::insertChildren(int row, QList<TestTreeItem*>
children) {
+ if(row < 0 || row > childItems.size())
+ return false;
+ TestTreeItem* child;
+ foreach(child, children)
+ childItems.insert(row++, child);
+ return true;
+}
+
+/*! \brief Retrieves the column this item is in.
+ *
+ * Currently, we only support a single column, so this is always 0.
+ * \return The column this item is in (zero).
+ */
+inline int TestTreeItem::column() const { return 0; }
+
+#endif /* TESTTREEITEM_H_ */
=======================================
--- /dev/null
+++ /trunk/include/TestTreeModel.h Sat Sep 25 09:25:39 2010
@@ -0,0 +1,100 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * TestTreeModel.h - Created on 2010-08-28
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#ifndef TESTTREEMODEL_H_
+#define TESTTREEMODEL_H_
+
+#include <QAbstractItemModel>
+#include <QHash>
+#include <QModelIndex>
+#include <QSharedPointer>
+#include <QVariant>
+
+class TestTreeItem;
+class GTest;
+class GTestExecutable;
+
+/*! \brief The data model that holds the unit test application hierarchy.
+ *
+ * The unit test hierarchy is structured as a collection of trees. These
+ * are each held as branches of an invisible root node (which conveniently
+ * holds the model's header data).
+ */
+class TestTreeModel : public QAbstractItemModel {
+
+ Q_OBJECT;
+
+private:
+
+ /*! \brief This enum specifies whether a recursive
+ * function should be called recursively up and/or
+ * down the unit test tree hierarchy.
+ */
+ enum RECURSE {
+ NONE = 0x0,
+ TO_PARENT = 0x1,
+ TO_CHILDREN = 0x2
+ };
+
+ QHash<QString, QSharedPointer<GTestExecutable> > testExeHash; //!< A hash
of all loaded gtest executables.
+ QHash<GTest*, TestTreeItem*> itemTestHash; //!< A hash that relates unit
tests to tree items
+
+ template <class T, class U>
+ TestTreeItem* createNewTreeItem(T* parent, U* test);
+ bool setCheckState(TestTreeItem* item, Qt::CheckState state, int
recursionDirection = (TO_PARENT | TO_CHILDREN));
+
+signals:
+ void aboutToRunTests();
+ void runningTests();
+ void resettingRunStates();
+
+private slots:
+ void updateListing(GTestExecutable* gtest);
+ void updateAllListings();
+ void populateTestResult();
+ void removeSenderItem();
+ void runTests();
+
+public:
+
+ enum ERROR {
+ NO_ERROR = 0,
+ FILE_NOT_FOUND,
+ INSUFFICIENT_PRIVILEGES,
+ UNKNOWN
+ };
+
+ TestTreeModel(QObject* parent = 0);
+ ~TestTreeModel();
+
+ int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+ Qt::ItemFlags flags(const QModelIndex& index) const;
+ QVariant headerData(int secton, Qt::Orientation orientation, int role =
Qt::DisplayRole) const;
+ QModelIndex index(int row, int column, const QModelIndex& parent =
QModelIndex()) const;
+ bool insertItem(TestTreeItem* item, int row, TestTreeItem* parent);
+ bool insertItems(const QList<TestTreeItem*> items, int row, TestTreeItem*
parent);
+ QModelIndex parent(const QModelIndex& index) const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ bool setData(const QModelIndex& index, const QVariant& value, int role =
Qt::EditRole);
+ ERROR addDataSource(const QString filepath);
+
+private:
+ TestTreeItem* rootItem; //!< This is the root of the data model.
+
+};
+
+#endif /* TESTTREEMODEL_H_ */
=======================================
--- /dev/null
+++ /trunk/src/TestTreeItem.cpp Sat Sep 25 09:25:39 2010
@@ -0,0 +1,104 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * TestTreeItem.cpp - Created on 2010-08-29
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#include "TestTreeItem.h"
+
+/*! \brief Constructor
+ *
+ * \param data The list of data to assign to this item. The QMap should map
+ * between a Qt::ItemDataRole and the QVariant with the data.
+ * \param parent The parent of this item.
+ */
+TestTreeItem::TestTreeItem(QMap<int, QVariant>& data, TestTreeItem* parent)
+: childItems(), itemData(data), parentItem(parent)
+{}
+
+/*! \brief Destructor
+ *
+ */
+TestTreeItem::~TestTreeItem()
+{
+ qDeleteAll(childItems);
+}
+
+/*! \brief Appends the child to the end of this item.
+ *
+ * \param child A pointer to the child to append.
+ */
+void TestTreeItem::appendChild(TestTreeItem *child) {
+ childItems.append(child);
+}
+
+/*! \brief Retrieves the data item specified by the role (a
Qt::ItemDataRole).
+ *
+ * \param role A value from Qt::ItemDataRole specifying a model role.
+ * \return A variant holding the data.
+ */
+QVariant TestTreeItem::data(int role) const {
+ return itemData.value(role);
+}
+
+/*! \brief Retrieves a pointer to the parent of this item.
+ *
+ * \return A pointer to the parent of this item.
+ */
+TestTreeItem* TestTreeItem::parent() {
+ return parentItem;
+}
+
+/*! \brief Retrieves the row that this item is in.
+ *
+ * The row is relative to the parent. The row this item is in,
+ * is the index of the item in the children of its parent.
+ * \return The row this item is in, or if it has no parent (the rootItem)
0.
+ */
+int TestTreeItem::row() const {
+ if(parentItem)
+ return parentItem->childItems.indexOf(const_cast<TestTreeItem*>(this));
+ return 0;
+}
+
+/*! \brief Sets the data for the given role to the variant 'value'.
+ *
+ * \param value The value to set for the given role.
+ * \param role The role specified from Qt::ItemDataRole.
+ * \return true if the data was set, false otherwise.
+ */
+bool TestTreeItem::setData(const QVariant& value, int role) {
+ itemData.insert(role, value);
+ return true;
+}
+
+/*! \brief Finds the child who has the value 'value' contained in the
role 'role'.
+ *
+ * If no child item is found who has the value given for the role given,
then null
+ * is returned.
+ * \param value The value to match.
+ * \param role The role to match (one of Qt::ItemDataRole).
+ * \return The child the holds the value for the given role, or null if
not found.
+ */
+TestTreeItem* TestTreeItem::findChild(const QVariant& value, int role)
const {
+ QList<TestTreeItem*>::const_iterator it = childItems.begin();
+ while(it != childItems.end()) {
+ if((*it)->data(role) == value)
+ return *it;
+ ++it;
+ }
+ return 0;
+}
+
+
+
=======================================
--- /dev/null
+++ /trunk/src/TestTreeModel.cpp Sat Sep 25 09:25:39 2010
@@ -0,0 +1,530 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * TestTreeModel.cpp - Created on 2010-08-28
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#include <QApplication>
+#include <QDebug>
+#include <QMap>
+#include <QMessageBox>
+#include <QSharedPointer>
+#include <QStack>
+
+#include "TestTreeModel.h"
+#include "TestTreeItem.h"
+#include "GTestExecutable.h"
+
+/*! \brief Constructor
+ *
+ */
+TestTreeModel::TestTreeModel(QObject* parent)
+: QAbstractItemModel(parent)
+{
+ QMap<int, QVariant> data;
+ data.insert(0,"Test Name");
+ rootItem = new TestTreeItem(data, 0);
+}
+
+/*! \brief Destructor
+ *
+ */
+TestTreeModel::~TestTreeModel() {
+ delete rootItem;
+}
+
+/*! \brief Gives a count of the number of columns contained by the
index 'parent'.
+ *
+ * If the index is invalid the number of columns contained by the rootItem
are
+ * returned.
+ * \return The number of columns given by the index 'parent' or the number
of
+ * columns in the rootItem is 'parent' is invalid.
+ */
+int TestTreeModel::columnCount(const QModelIndex& parent) const {
+ if (parent.isValid())
+ return
static_cast<TestTreeItem*>(parent.internalPointer())->columnCount();
+ else
+ return rootItem->columnCount();
+}
+
+/*! \brief Accesses data contained within the model.
+ *
+ * The data contained in the index 'index' for the given 'role' are
returned
+ * within a QVariant. If the index is invalid, or if the item specified by
+ * the index does not contain data for the role 'role', an empty QVariant
+ * is returned.
+ * \return The data specified by the index 'index' and the role 'role'.
+ */
+QVariant TestTreeModel::data(const QModelIndex& index, int role) const {
+ if (!index.isValid())
+ return QVariant();
+
+ switch(role) {
+ //list supported data accesses here.
+ case Qt::BackgroundColorRole:
+ case Qt::CheckStateRole:
+ case Qt::DisplayRole: {
+ TestTreeItem *item =
static_cast<TestTreeItem*>(index.internalPointer());
+ if(item)
+ return item->data(role);
+ return QVariant();
+ }
+ default:
+ return QVariant();
+ }
+}
+
+/*! \brief Returns the flags for the item specified by the given index.
+ *
+ * If the index is invalid, this function returns 0. Otherwise, items
within
+ * the TestTreeModel are enabled, selectable, checkable, and if they have
children,
+ * are tristate checkable.
+ * \see TestTreeModel::setCheckState() for more information on check
states.
+ */
+Qt::ItemFlags TestTreeModel::flags(const QModelIndex& index) const {
+ if (!index.isValid())
+ return 0;
+
+ Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable |
Qt::ItemIsUserCheckable;
+
+ if(static_cast<TestTreeItem*>(index.internalPointer())->childCount() > 0)
+ flags |= Qt::ItemIsTristate;
+
+ return flags;
+}
+
+/*! \brief Retrieves the header information for the model.
+ *
+ * Section and orientation are ignored for this model. We only provide
data in
+ * one dimension so there are unnecessary. The data for the given role is
provided.
+ * \return The data for the given role.
+ */
+QVariant TestTreeModel::headerData(int /*section*/, Qt::Orientation
/*orientation*/, int role) const {
+ if(rootItem)
+ return rootItem->data(role);
+ return QVariant();
+}
+
+/*! \brief Retrieves a model index at the specified (row, columns) from
the given parent.
+ *
+ * Retrieves a model index for the model. If parent is not specified, or
is a default
+ * constructed index, an index to a top level item is returned.
+ * \return A model index for the given row and column with the
parent 'parent'.
+ */
+QModelIndex TestTreeModel::index(int row, int column, const QModelIndex&
parent) const {
+ if(!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ TestTreeItem* parentItem;
+ TestTreeItem* childItem;
+
+ if(parent.isValid())
+ parentItem = static_cast<TestTreeItem*>(parent.internalPointer());
+ else
+ parentItem = rootItem;
+
+ childItem = parentItem->child(row);
+ if(childItem)
+ return createIndex(row, column, childItem);
+ return QModelIndex();
+}
+
+/*! \brief Retrieves the parent of the index provided.
+ *
+ * If the index is invalid or is a top level item, an invalid index is
returned.
+ * \return The parent of the index if it exists. An invalid index
otherwise.
+ */
+QModelIndex TestTreeModel::parent(const QModelIndex &index) const {
+ if (!index.isValid())
+ return QModelIndex();
+
+ TestTreeItem *childItem =
static_cast<TestTreeItem*>(index.internalPointer());
+ TestTreeItem *parentItem = childItem->parent();
+
+ if (parentItem == rootItem || !parentItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
+/*! \brief Retrieves the number of rows provided by the parent 'parent'.
+ *
+ * \return If the index is valid, the number of children held by 'parent'
is returned.
+ * Else, the number of top level items is returned.
+ */
+int TestTreeModel::rowCount(const QModelIndex& parent) const {
+ TestTreeItem *parentItem;
+ if (parent.column() > 0)
+ return 0;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<TestTreeItem*>(parent.internalPointer());
+
+ return parentItem->childCount();
+}
+
+/*! \brief Sets data on the model.
+ *
+ * It is trusted that the user of this function respects the information
provided by
+ * \see TestTreeModel::flags(). This function will set the data contained
in var
+ * on the item specified by index for the given role. If data in the model
is changed,
+ * the TestTreeModel::dataChanged() signal is emitted.
+ */
+bool TestTreeModel::setData(const QModelIndex& index, const QVariant& var,
int role) {
+ if(!index.isValid())
+ return false;
+ TestTreeItem* item = static_cast<TestTreeItem*>(index.internalPointer());
+ if(!item)
+ return false;
+
+ bool dataModified;
+ if(role == Qt::CheckStateRole)
+ dataModified = this->setCheckState(item,
static_cast<Qt::CheckState>(var.value<int>()));
+ else {
+ dataModified = item->setData(var, role);
+ if(dataModified)
+ emit dataChanged(index, index);
+ }
+ return dataModified;
+}
+
+/*! \brief Sets the checkstate on the given item.
+ *
+ * This function is recursive. The recursion is only allowed to propagate
+ * away from the original item that has been checked. This function
maintains
+ * the consistency of the check states of items contained in the model.
The rules
+ * are described as follows:
+ * \li An item that is a leaf (i.e. has no children) cannot be partially
checked.
+ * \li An item must be set to partially checked if it contains both
checked and unchecked
+ * or partially checked child items.
+ * \li If a partially checked item is changed to checked, all its children
will be checked.
+ * \li If a checked item is set to unchecked, all its children will be
unchecked.
+ * \return true of the checking was successful, false otherwise.
+ */
+bool TestTreeModel::setCheckState(TestTreeItem* item, Qt::CheckState
newState, int recursionDirection) {
+ if(!item)
+ return false;
+ bool retval;
+ if(newState == Qt::Checked || newState == Qt::Unchecked) {
+ if(recursionDirection & TO_CHILDREN)
+ for(int i=0,j=item->childCount();i<j;i++)
+ setCheckState(item->child(i), newState, TO_CHILDREN);
+
+ retval = item->setData(QVariant(static_cast<int>(newState)),
Qt::CheckStateRole);
+ if(recursionDirection & TO_PARENT) {
+ setCheckState(item->parent(), Qt::PartiallyChecked, TO_PARENT);
+ }
+ }
+ else /*newState == Qt::PartiallyChecked*/ {
+ bool checked = false;
+ bool unchecked = false;
+ Qt::CheckState childState;
+ for(int i=0,j=item->childCount();i<j&&(!checked||!unchecked);i++) {
+ childState =
static_cast<Qt::CheckState>(item->child(i)->data(Qt::CheckStateRole).value<int>());
+ if(childState == Qt::Checked)
+ checked = true;
+ else if(childState == Qt::Unchecked)
+ unchecked = true;
+ }
+ if(recursionDirection == (TO_PARENT | TO_CHILDREN)) {
+ if(checked && !unchecked)
+ newState = Qt::Unchecked;
+ else if(!checked && unchecked)
+ newState = Qt::Checked;
+ for(int i=0,j=item->childCount();i<j;i++)
+ setCheckState(item->child(i), newState, TO_CHILDREN);
+ retval = item->setData(QVariant(static_cast<int>(newState)),
Qt::CheckStateRole);
+ }
+ else {
+ if(checked && !unchecked)
+ newState = Qt::Checked; //only checked children
+ else if(!checked && unchecked)
+ newState = Qt::Unchecked; //only unchecked children
+ retval = item->setData(QVariant(static_cast<int>(newState)),
Qt::CheckStateRole);
+ }
+ if(recursionDirection & TO_PARENT) {
+ setCheckState(item->parent(), Qt::PartiallyChecked, TO_PARENT);
+ }
+ }
+ QModelIndex index(createIndex(item->row(),0,item));
+ emit dataChanged(index, index);
+ return retval;
+}
+
+/*! \brief This function adds a data source for this model.
+ *
+ * The data source specified must be a string containing the path to a
+ * google test executable.
+ * \return An error code whether the addition of the data source was
successful.
+ * \todo Set this function to take a QFile instead of a string.
+ */
+TestTreeModel::ERROR TestTreeModel::addDataSource(const QString filepath) {
+ QSharedPointer<GTestExecutable> newTest =
QSharedPointer<GTestExecutable>(new GTestExecutable(this));
+ newTest->setExecutablePath(filepath);
+ switch(newTest->getState()) {
+ case GTestExecutable::VALID:
+ QObject::connect(newTest.data(), SIGNAL(listingReady(GTestExecutable*)),
+ this, SLOT(updateListing(GTestExecutable*)));
+ //We insert it so that it doesn't auto-delete from the shared ptr.
+ //Will probably be useful later on when we want to save settings.
+ testExeHash.insert(newTest->objectName(), newTest);
+ //We've got test, so let's have it send up a listing.
+ newTest->produceListing();
+ return NO_ERROR;
+ case GTestExecutable::FILE_NOT_FOUND:
+ return FILE_NOT_FOUND;
+ case GTestExecutable::INSUFFICIENT_PRIVILEGES:
+ return INSUFFICIENT_PRIVILEGES;
+ default:
+ return UNKNOWN;
+ }
+}
+
+/* \brief Creates a tree item and sets up some slot/signals.
+ *
+ * This function is a help to the updateListing method which enables
+ * simplified creation of new tree items. It is templated as I didn't
+ * feel like writing three copies of the same code (thus making the
+ * function useless). It simply sets up some common states among tree
+ * items and some signal/slots between the tree item and its corresponding
+ * test item.
+ */
+template <class T, class U>
+TestTreeItem* TestTreeModel::createNewTreeItem(T* parent, U* test) {
+ QVariant var;
+ QMap<int, QVariant> data;
+ var.setValue<QString>(test->objectName());
+ data.insert(Qt::DisplayRole, var);
+ var.setValue<GTest*>(test);
+ data.insert(Qt::UserRole, var);
+ var.setValue(static_cast<int>(Qt::Unchecked));
+ data.insert(Qt::CheckStateRole, var);
+ TestTreeItem* newTreeItem = new TestTreeItem(data, parent);
+
+ itemTestHash.insert(test, newTreeItem);
+
+ QObject::connect(test, SIGNAL(destroyed()),
+ this, SLOT(removeSenderItem()));
+ QObject::connect(test, SIGNAL(testResultsReady()),
+ this, SLOT(populateTestResult()));
+ return newTreeItem;
+}
+
+/*! \brief Updates the tree with a listing provided by 'gtest'.
+ *
+ * This function takes the 'gtest' and retrieves its listing. It then
+ * takes the listing and populates the main test tree with the tests
+ * it provides.
+ * \todo TODO::Update a listing that already exists.
+ * \todo TODO::Refactor this method. It's a bit too long.
+ */
+void TestTreeModel::updateListing(GTestExecutable* gtest) {
+ const int exitCode = gtest->getExitCode();
+ QString exePath = gtest->getExecutablePath();
+ if(exitCode != 0) {
+ QMessageBox::critical(0, "Error Retrieving Test Listing",
+ QString("Exit code").append(exitCode).append("was returned from the
Google Test executable at").append(exePath).append(". Are you sure this is
a valid Google Test unit test executable?"));
+ //! \todo Perform switch statement of process error.
+ return;
+ }
+
+ TestTreeItem* suiteTreeItem = 0;
+ TestTreeItem* testTreeItem = 0;
+ TestTreeItem* exeTreeItem = rootItem->findChild(gtest->objectName(),
Qt::DisplayRole);
+
+ if(!exeTreeItem) {
+ //If we haven't added the test yet, make one now.
+ exeTreeItem =
createNewTreeItem<TestTreeItem,GTestExecutable>(rootItem,gtest);
+ insertItem(exeTreeItem, rootItem->childCount(), rootItem);
+
+ QObject::connect(this, SIGNAL(runningTests()),
+ gtest, SLOT(runTest()));
+ QObject::connect(this, SIGNAL(resettingRunStates()),
+ gtest, SLOT(resetRunState()));
+ }
+
+ //Get which of the tests are new. This should be all of them the first
+ //time through for this test.
+ QSet<QString> newTests = gtest->getListing() - gtest->getOldListing();
+
+ //Iterate through all the suites.
+ QList<GTestSuite*> suiteList = gtest->findChildren<GTestSuite*>();
+ QList<GTestSuite*>::iterator suiteIter = suiteList.begin();
+ while(suiteIter != suiteList.end()) {
+ if(!newTests.contains((*suiteIter)->objectName())) {
+ suiteIter++;
+ continue; //already have this added
+ }
+
+ //Create a new GTestSuite tree item.
+ suiteTreeItem = createNewTreeItem<TestTreeItem,GTestSuite>(exeTreeItem,
*suiteIter);
+ insertItem(suiteTreeItem, exeTreeItem->childCount(), exeTreeItem);
+
+ //Iterate through all the tests of this suite.
+ QList<GTest*> testList = (*suiteIter)->findChildren<GTest*>();
+ QList<GTest*>::iterator testIter = testList.begin();
+ while(testIter != testList.end()) {
+
if(!newTests.contains((*suiteIter)->objectName().append('.').append((*testIter)->objectName())))
{
+ testIter++;
+ continue; //already have this added
+ }
+
+ //Create a new GTest tree item.
+ testTreeItem = createNewTreeItem<TestTreeItem, GTest>(suiteTreeItem,
*testIter);
+ insertItem(testTreeItem, suiteTreeItem->childCount(), suiteTreeItem);
+ ++testIter;
+ }
+ ++suiteIter;
+ }
+ emit layoutChanged();
+}
+
+/*! \brief Populates a test result into the test tree.
+ *
+ * This function takes a QObject* which should be a TestTreeWidgetItem.
+ * If it is called with anything else, the function does nothing. It takes
+ * the item and retrieves its corresponding GTest. The GTest should already
+ * have its updated result attached to it, thus, it retrieves the result
+ * and sets the item to the appropriate pass / fail state.
+ * \param item This should be a TestTreeWidgetItem which needs its test
result updated.
+ */
+void TestTreeModel::populateTestResult() {
+ GTest* test = static_cast<GTest*>(sender());
+ if(test == 0)
+ return; //! \todo exception management stuff here
+ TestTreeItem* treeItem = itemTestHash.value(test);
+ if(treeItem == 0)
+ return; //! \todo exception management stuff here
+
+ QVariant var = treeItem->data(Qt::UserRole);
+ GTest* testItem = var.value<GTest*>();
+ if(testItem == 0) {
+ testItem = var.value<GTestSuite*>();
+ if(testItem == 0) {
+ testItem = var.value<GTestExecutable*>();
+ if(testItem == 0)
+ return; //! \todo exception management stuff here
+ }
+ }
+
+ const GTestResults* testResults = testItem->getTestResults();
+ if(testResults == 0)
+ return;
+
+ QModelIndex index = createIndex(treeItem->row(), treeItem->column(),
treeItem);
+ if(testResults->getFailureCount() == 0)
+ setData(index, QVariant(QBrush(QColor(0xAB,0xFF,0xBB,0xFF))),
Qt::BackgroundRole);
+ else
+ setData(index, QVariant(QBrush(QColor(0xFF,0x88,0x88,0xFF))),
Qt::BackgroundRole);
+}
+
+/*! \brief A slot that removes the signal's sender from the data model.
+ *
+ * The sender must be a GTest or this function does nothing.
+ */
+//! \todo Investigate whether we can give a persistent index to a GTest.
+void TestTreeModel::removeSenderItem() {
+ GTest* test = static_cast<GTest*>(sender());
+ if(!test)
+ return; //! \todo exception management stuff here
+ TestTreeItem* item = itemTestHash.value(test);
+ item->parent()->removeChild(item);
+ itemTestHash.remove(test);
+ delete item; //! \todo use QSharedPointers for items
+}
+
+/*! \brief Inserts a single item into the model before row 'row' on the
parent given.
+ *
+ * If the parent, or the item is null, this function does nothing and
returns false.
+ * Otherwise, the appropriate QAbstractItemModel signals are emitted and
the child
+ * is inserted into the model.
+ * \return true if the item was inserted successfully, false otherwise.
+ */
+bool TestTreeModel::insertItem(TestTreeItem* item, int row, TestTreeItem*
parent) {
+ if(item == 0 || parent == 0)
+ return false;
+ beginInsertRows(createIndex(parent->row(), 0, parent), row, row);
+ parent->insertChild(row, item);
+ endInsertRows();
+ return true;
+}
+
+/*! \brief Inserts a list of items into the model before row 'row' on the
parent given.
+ *
+ * If the parent, or the item is null, this function does nothing and
returns false.
+ * Otherwise, the appropriate QAbstractItemModel signals are emitted and
the children
+ * are inserted into the model.
+ * \param items A list of items to be inserted.
+ * \param row The position to insert the items.
+ * \param parent The parent to add the items to as child rows.
+ * \return true if the items were inserted successfully, false otherwise.
+ */
+bool TestTreeModel::insertItems(QList<TestTreeItem*> items, int row,
TestTreeItem* parent) {
+ if(items.count() == 0 || parent == 0)
+ return false;
+ beginInsertRows(createIndex(parent->row(), 0, parent), row,
row+items.count());
+ parent->insertChildren(row, items);
+ endInsertRows();
+ return true;
+}
+
+/*! \brief Runs all tests that are checked.
+ *
+ * This is the only way tests results are populated into the model.
+ * This is the method the model uses to notify the GTestExecutables to run
+ * their corresponding executable on the file system and to populate its
results
+ * into the data model.
+ */
+void TestTreeModel::runTests() {
+ emit aboutToRunTests();
+
+ QStack<TestTreeItem*> stack;
+ QList<TestTreeItem*> children;
+ TestTreeItem* item;
+ stack.push(rootItem);
+
+ while(!stack.isEmpty()) {
+ item = stack.pop();
+ GTest* test = item->data(Qt::UserRole).value<GTest*>();
+ if(test && (item->data(Qt::CheckStateRole).value<int>() == Qt::Checked))
+ test->run();
+ else {
+ children = item->children();
+ QList<TestTreeItem*>::iterator it = children.begin();
+ while(it != children.end()) {
+ stack.push(*it);
+ ++it;
+ }
+ }
+ }
+
+ emit runningTests();
+}
+
+/*! \brief Updates all the listings for every GTestExecutable.
+ *
+ * This function iterates through the collection of GTestExecutables
+ * and invokes their listing retrieval mechanism.
+ */
+void TestTreeModel::updateAllListings() {
+ QHash<QString, QSharedPointer<GTestExecutable> >::iterator it =
testExeHash.begin();
+ while(it != testExeHash.end()) {
+ (*it)->produceListing();
+ ++it;
+ }
+}
+
+
+
=======================================
--- /dev/null
+++ /trunk/src/main.cpp Sat Sep 25 09:25:39 2010
@@ -0,0 +1,28 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * main.cpp - Created on
2010-07-23 *
+
*
*
+ * Copyright (C) 2010 Sandy
Chapman *
+
*
*
+ * This library is free software; you can redistribute it and/or modify it
under the *
+ * terms of the GNU Lesser General Public License as published by the Free
Software *
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version. *
+ * This library 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 Lesser General Public License for more
details. *
+ * You should have received a copy of the GNU Lesser General Public
License along with this *
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, *
+ * Boston, MA 02111-1307
USA *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#include "GTestRunner.h"
+
+#include <QtGui>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ GTestRunner w;
+ w.show();
+ return a.exec();
+}
=======================================
--- /trunk/main.cpp Sun Jul 25 10:11:16 2010
+++ /dev/null
@@ -1,28 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
- * main.cpp - Created on
2010-07-23 *
-
*
*
- * Copyright (C) 2010 Sandy
Chapman *
-
*
*
- * This library is free software; you can redistribute it and/or modify it
under the *
- * terms of the GNU Lesser General Public License as published by the Free
Software *
- * Foundation; either version 2.1 of the License, or (at your option) any
later version. *
- * This library 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 Lesser General Public License for more
details. *
- * You should have received a copy of the GNU Lesser General Public
License along with this *
- * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, *
- * Boston, MA 02111-1307
USA *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
-
-#include "GTestRunner.h"
-
-#include <QtGui>
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- GTestRunner w;
- w.show();
- return a.exec();
-}
=======================================
--- /trunk/GTestRunner.pro Tue Aug 10 15:48:07 2010
+++ /trunk/GTestRunner.pro Sat Sep 25 09:25:39 2010
@@ -1,10 +1,15 @@
TEMPLATE = app
-TARGET = GTestRunner
-QT += core \
- gui
-HEADERS += include/TestTreeWidgetItem.h \
- include/TestTreeWidget.h \
- include/GTestSuiteResults.h \
+
+CONFIG += debug_and_release
+CONFIG(debug, debug|release) {
+ TARGET = gtestrunner-debug
+}
+else {
+ TARGET = gtestrunner
+}
+QT += core gui xml
+INCLUDEPATH += include
+HEADERS += include/GTestSuiteResults.h \
include/GTestResults.h \
include/GTestSuite.h \
include/Defines.h \
@@ -12,18 +17,21 @@
include/GTest.h \
include/GTestExecutable.h \
include/GTestParser.h \
- include/GTestRunner.h
-SOURCES += src/TestTreeWidgetItem.cpp \
- src/TestTreeWidget.cpp \
- src/GTestResults.cpp \
+ include/GTestRunner.h \
+ include/TestTreeModel.h \
+ include/TestTreeItem.h
+SOURCES += src/GTestResults.cpp \
src/GTestSuiteResults.cpp \
src/GTestSuite.cpp \
src/GTestExecutableResults.cpp \
src/GTest.cpp \
src/GTestExecutable.cpp \
- main.cpp \
+ src/main.cpp \
src/GTestParser.cpp \
- src/GTestRunner.cpp
-FORMS +=
-RESOURCES +=
-INCLUDEPATH += include
+ src/GTestRunner.cpp \
+ src/TestTreeModel.cpp \
+ src/TestTreeItem.cpp
+FORMS += resources/gtestrunner.ui
+UI_HEADERS_DIR = include
+UI_SOURCES_DIR = src
+RESOURCES += resources/gtestrunner.qrc
=======================================
--- /trunk/Makefile Thu Aug 12 16:12:42 2010
+++ /trunk/Makefile Sat Sep 25 09:25:39 2010
@@ -1,16 +1,16 @@
#############################################################################
-# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Aug 11 20:01:39 2010
+# Makefile for building: gtestrunner
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Sep 25 13:21:13 2010
# Project: GTestRunner.pro
# Template: app
-# Command: /usr/local/Trolltech/Qt-4.6.2/bin/qmake -unix
CONFIG+=debug_and_release -o Makefile GTestRunner.pro
+# Command: /usr/bin/qmake -unix -o Makefile GTestRunner.pro
#############################################################################
first: release
install: release-install
uninstall: release-uninstall
MAKEFILE = Makefile
-QMAKE = /usr/local/Trolltech/Qt-4.6.2/bin/qmake
+QMAKE = /usr/bin/qmake
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
@@ -63,53 +63,55 @@
debug-uninstall: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug uninstall
-Makefile: GTestRunner.pro
/usr/local/Trolltech/Qt-4.6.2/mkspecs/linux-g++-64/qmake.conf
/usr/local/Trolltech/Qt-4.6.2/mkspecs/common/g++.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/unix.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/linux.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/qconfig.pri \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_functions.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_config.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/exclusive_builds.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_pre.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/release.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/debug_and_release.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_post.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/warn_on.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/unix/thread.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/moc.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/resources.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/uic.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/yacc.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/lex.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/include_source_dir.prf \
- /usr/local/Trolltech/Qt-4.6.2/lib/libQtGui.prl \
- /usr/local/Trolltech/Qt-4.6.2/lib/libQtCore.prl
- $(QMAKE) -unix CONFIG+=debug_and_release -o Makefile GTestRunner.pro
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/common/g++.conf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/common/unix.conf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/common/linux.conf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/qconfig.pri:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_functions.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_config.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/exclusive_builds.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_pre.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/release.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/debug_and_release.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_post.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/warn_on.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/unix/thread.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/moc.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/resources.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/uic.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/yacc.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/lex.prf:
-/usr/local/Trolltech/Qt-4.6.2/mkspecs/features/include_source_dir.prf:
-/usr/local/Trolltech/Qt-4.6.2/lib/libQtGui.prl:
-/usr/local/Trolltech/Qt-4.6.2/lib/libQtCore.prl:
+Makefile: GTestRunner.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf
/usr/share/qt4/mkspecs/common/g++.conf \
+ /usr/share/qt4/mkspecs/common/unix.conf \
+ /usr/share/qt4/mkspecs/common/linux.conf \
+ /usr/share/qt4/mkspecs/qconfig.pri \
+ /usr/share/qt4/mkspecs/features/qt_functions.prf \
+ /usr/share/qt4/mkspecs/features/qt_config.prf \
+ /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
+ /usr/share/qt4/mkspecs/features/default_pre.prf \
+ /usr/share/qt4/mkspecs/features/release.prf \
+ /usr/share/qt4/mkspecs/features/debug_and_release.prf \
+ /usr/share/qt4/mkspecs/features/default_post.prf \
+ /usr/share/qt4/mkspecs/features/warn_on.prf \
+ /usr/share/qt4/mkspecs/features/qt.prf \
+ /usr/share/qt4/mkspecs/features/unix/thread.prf \
+ /usr/share/qt4/mkspecs/features/moc.prf \
+ /usr/share/qt4/mkspecs/features/resources.prf \
+ /usr/share/qt4/mkspecs/features/uic.prf \
+ /usr/share/qt4/mkspecs/features/yacc.prf \
+ /usr/share/qt4/mkspecs/features/lex.prf \
+ /usr/share/qt4/mkspecs/features/include_source_dir.prf \
+ /usr/lib/libQtXml.prl \
+ /usr/lib/libQtGui.prl \
+ /usr/lib/libQtCore.prl
+ $(QMAKE) -unix -o Makefile GTestRunner.pro
+/usr/share/qt4/mkspecs/common/g++.conf:
+/usr/share/qt4/mkspecs/common/unix.conf:
+/usr/share/qt4/mkspecs/common/linux.conf:
+/usr/share/qt4/mkspecs/qconfig.pri:
+/usr/share/qt4/mkspecs/features/qt_functions.prf:
+/usr/share/qt4/mkspecs/features/qt_config.prf:
+/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
+/usr/share/qt4/mkspecs/features/default_pre.prf:
+/usr/share/qt4/mkspecs/features/release.prf:
+/usr/share/qt4/mkspecs/features/debug_and_release.prf:
+/usr/share/qt4/mkspecs/features/default_post.prf:
+/usr/share/qt4/mkspecs/features/warn_on.prf:
+/usr/share/qt4/mkspecs/features/qt.prf:
+/usr/share/qt4/mkspecs/features/unix/thread.prf:
+/usr/share/qt4/mkspecs/features/moc.prf:
+/usr/share/qt4/mkspecs/features/resources.prf:
+/usr/share/qt4/mkspecs/features/uic.prf:
+/usr/share/qt4/mkspecs/features/yacc.prf:
+/usr/share/qt4/mkspecs/features/lex.prf:
+/usr/share/qt4/mkspecs/features/include_source_dir.prf:
+/usr/lib/libQtXml.prl:
+/usr/lib/libQtGui.prl:
+/usr/lib/libQtCore.prl:
qmake: qmake_all FORCE
- @$(QMAKE) -unix CONFIG+=debug_and_release -o Makefile GTestRunner.pro
+ @$(QMAKE) -unix -o Makefile GTestRunner.pro
qmake_all: FORCE
=======================================
--- /trunk/Makefile.Debug Thu Aug 12 16:12:42 2010
+++ /trunk/Makefile.Debug Sat Sep 25 09:25:39 2010
@@ -1,6 +1,6 @@
#############################################################################
-# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Aug 11 20:01:39 2010
+# Makefile for building: gtestrunner-debug
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Sep 25 13:21:13 2010
# Project: GTestRunner.pro
# Template: app
#############################################################################
@@ -9,16 +9,16 @@
CC = gcc
CXX = g++
-DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS = -m64 -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS = -m64 -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH = -I/usr/local/Trolltech/Qt-4.6.2/mkspecs/linux-g++-64 -I.
-I/usr/local/Trolltech/Qt-4.6.2/include/QtCore
-I/usr/local/Trolltech/Qt-4.6.2/include/QtGui
-I/usr/local/Trolltech/Qt-4.6.2/include -Iinclude -Idebug
+DEFINES = -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
+INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I.
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml
-I/usr/include/qt4 -Iinclude -Idebug -Iinclude
LINK = g++
-LFLAGS = -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-4.6.2/lib
-LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-4.6.2/lib -lQtGui
-L/usr/local/Trolltech/Qt-4.6.2/lib -L/usr/X11R6/lib64 -lQtCore -lpthread
+LFLAGS =
+LIBS = $(SUBLIBS) -L/usr/lib -lQtXml -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
-QMAKE = /usr/local/Trolltech/Qt-4.6.2/bin/qmake
+QMAKE = /usr/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
@@ -42,25 +42,23 @@
####### Files
-SOURCES = src/TestTreeWidgetItem.cpp \
- src/TestTreeWidget.cpp \
- src/GTestResults.cpp \
+SOURCES = src/GTestResults.cpp \
src/GTestSuiteResults.cpp \
src/GTestSuite.cpp \
src/GTestExecutableResults.cpp \
src/GTest.cpp \
src/GTestExecutable.cpp \
- main.cpp \
+ src/main.cpp \
src/GTestParser.cpp \
- src/GTestRunner.cpp debug/moc_TestTreeWidgetItem.cpp \
- debug/moc_TestTreeWidget.cpp \
- debug/moc_GTestSuite.cpp \
+ src/GTestRunner.cpp \
+ src/TestTreeModel.cpp \
+ src/TestTreeItem.cpp debug/moc_GTestSuite.cpp \
debug/moc_GTest.cpp \
debug/moc_GTestExecutable.cpp \
- debug/moc_GTestRunner.cpp
-OBJECTS = debug/TestTreeWidgetItem.o \
- debug/TestTreeWidget.o \
- debug/GTestResults.o \
+ debug/moc_GTestRunner.cpp \
+ debug/moc_TestTreeModel.cpp \
+ debug/qrc_gtestrunner.cpp
+OBJECTS = debug/GTestResults.o \
debug/GTestSuiteResults.o \
debug/GTestSuite.o \
debug/GTestExecutableResults.o \
@@ -69,37 +67,39 @@
debug/main.o \
debug/GTestParser.o \
debug/GTestRunner.o \
- debug/moc_TestTreeWidgetItem.o \
- debug/moc_TestTreeWidget.o \
+ debug/TestTreeModel.o \
+ debug/TestTreeItem.o \
debug/moc_GTestSuite.o \
debug/moc_GTest.o \
debug/moc_GTestExecutable.o \
- debug/moc_GTestRunner.o
-DIST = /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/g++.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/unix.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/linux.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/qconfig.pri \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_functions.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_config.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/exclusive_builds.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_pre.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/debug.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/debug_and_release.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_post.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/build_pass.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/warn_on.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/unix/thread.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/moc.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/resources.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/uic.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/yacc.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/lex.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/include_source_dir.prf \
+ debug/moc_GTestRunner.o \
+ debug/moc_TestTreeModel.o \
+ debug/qrc_gtestrunner.o
+DIST = /usr/share/qt4/mkspecs/common/g++.conf \
+ /usr/share/qt4/mkspecs/common/unix.conf \
+ /usr/share/qt4/mkspecs/common/linux.conf \
+ /usr/share/qt4/mkspecs/qconfig.pri \
+ /usr/share/qt4/mkspecs/features/qt_functions.prf \
+ /usr/share/qt4/mkspecs/features/qt_config.prf \
+ /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
+ /usr/share/qt4/mkspecs/features/default_pre.prf \
+ /usr/share/qt4/mkspecs/features/debug.prf \
+ /usr/share/qt4/mkspecs/features/debug_and_release.prf \
+ /usr/share/qt4/mkspecs/features/default_post.prf \
+ /usr/share/qt4/mkspecs/features/build_pass.prf \
+ /usr/share/qt4/mkspecs/features/warn_on.prf \
+ /usr/share/qt4/mkspecs/features/qt.prf \
+ /usr/share/qt4/mkspecs/features/unix/thread.prf \
+ /usr/share/qt4/mkspecs/features/moc.prf \
+ /usr/share/qt4/mkspecs/features/resources.prf \
+ /usr/share/qt4/mkspecs/features/uic.prf \
+ /usr/share/qt4/mkspecs/features/yacc.prf \
+ /usr/share/qt4/mkspecs/features/lex.prf \
+ /usr/share/qt4/mkspecs/features/include_source_dir.prf \
GTestRunner.pro
-QMAKE_TARGET = GTestRunner
+QMAKE_TARGET = gtestrunner-debug
DESTDIR =
-TARGET = GTestRunner
+TARGET = gtestrunner-debug
first: all
####### Implicit rules
@@ -125,15 +125,15 @@
all: Makefile.Debug $(TARGET)
-$(TARGET): $(OBJECTS)
+$(TARGET): include/ui_gtestrunner.h $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
qmake: FORCE
- @$(QMAKE) -unix CONFIG+=debug_and_release -o Makefile.Debug
GTestRunner.pro
+ @$(QMAKE) -unix -o Makefile.Debug GTestRunner.pro
dist:
- @$(CHK_DIR_EXISTS) debug/GTestRunner1.0.0 || $(MKDIR)
debug/GTestRunner1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) debug/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents include/TestTreeWidgetItem.h
include/TestTreeWidget.h include/GTestSuiteResults.h include/GTestResults.h
include/GTestSuite.h include/Defines.h include/GTestExecutableResults.h
include/GTest.h include/GTestExecutable.h include/GTestParser.h
include/GTestRunner.h debug/GTestRunner1.0.0/ && $(COPY_FILE) --parents
src/TestTreeWidgetItem.cpp src/TestTreeWidget.cpp src/GTestResults.cpp
src/GTestSuiteResults.cpp src/GTestSuite.cpp src/GTestExecutableResults.cpp
src/GTest.cpp src/GTestExecutable.cpp main.cpp src/GTestParser.cpp
src/GTestRunner.cpp debug/GTestRunner1.0.0/ && (cd `dirname
debug/GTestRunner1.0.0` && $(TAR) GTestRunner1.0.0.tar GTestRunner1.0.0 &&
$(COMPRESS) GTestRunner1.0.0.tar) && $(MOVE) `dirname
debug/GTestRunner1.0.0`/GTestRunner1.0.0.tar.gz . && $(DEL_FILE) -r
debug/GTestRunner1.0.0
+ @$(CHK_DIR_EXISTS) debug/gtestrunner-debug1.0.0 || $(MKDIR)
debug/gtestrunner-debug1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) debug/gtestrunner-debug1.0.0/
&& $(COPY_FILE) --parents include/GTestSuiteResults.h
include/GTestResults.h include/GTestSuite.h include/Defines.h
include/GTestExecutableResults.h include/GTest.h include/GTestExecutable.h
include/GTestParser.h include/GTestRunner.h include/TestTreeModel.h
include/TestTreeItem.h debug/gtestrunner-debug1.0.0/ && $(COPY_FILE)
--parents resources/gtestrunner.qrc debug/gtestrunner-debug1.0.0/ &&
$(COPY_FILE) --parents src/GTestResults.cpp src/GTestSuiteResults.cpp
src/GTestSuite.cpp src/GTestExecutableResults.cpp src/GTest.cpp
src/GTestExecutable.cpp src/main.cpp src/GTestParser.cpp
src/GTestRunner.cpp src/TestTreeModel.cpp src/TestTreeItem.cpp
debug/gtestrunner-debug1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.ui debug/gtestrunner-debug1.0.0/ && (cd `dirname
debug/gtestrunner-debug1.0.0` && $(TAR) gtestrunner-debug1.0.0.tar
gtestrunner-debug1.0.0 && $(COMPRESS) gtestrunner-debug1.0.0.tar) &&
$(MOVE) `dirname
debug/gtestrunner-debug1.0.0`/gtestrunner-debug1.0.0.tar.gz . &&
$(DEL_FILE) -r debug/gtestrunner-debug1.0.0
clean:compiler_clean
@@ -152,28 +152,17 @@
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
-compiler_moc_header_make_all: debug/moc_TestTreeWidgetItem.cpp
debug/moc_TestTreeWidget.cpp debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
+compiler_moc_header_make_all: debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
debug/moc_TestTreeModel.cpp
compiler_moc_header_clean:
- -$(DEL_FILE) debug/moc_TestTreeWidgetItem.cpp
debug/moc_TestTreeWidget.cpp debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
-debug/moc_TestTreeWidgetItem.cpp: include/GTestResults.h \
- include/TestTreeWidgetItem.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/TestTreeWidgetItem.h -o debug/moc_TestTreeWidgetItem.cpp
-
-debug/moc_TestTreeWidget.cpp: include/GTest.h \
- include/GTestResults.h \
- include/TestTreeWidgetItem.h \
- include/TestTreeWidget.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/TestTreeWidget.h -o debug/moc_TestTreeWidget.cpp
-
+ -$(DEL_FILE) debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
debug/moc_TestTreeModel.cpp
debug/moc_GTestSuite.cpp: include/GTest.h \
- include/GTestResults.h \
include/GTestSuiteResults.h \
+ include/GTestResults.h \
include/GTestSuite.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestSuite.h -o debug/moc_GTestSuite.cpp
-
-debug/moc_GTest.cpp: include/GTestResults.h \
- include/GTest.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTest.h -o debug/moc_GTest.cpp
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestSuite.h -o
debug/moc_GTestSuite.cpp
+
+debug/moc_GTest.cpp: include/GTest.h
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTest.h -o
debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp: include/GTestExecutableResults.h \
include/Defines.h \
@@ -182,45 +171,61 @@
include/GTestSuite.h \
include/GTest.h \
include/GTestExecutable.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestExecutable.h -o debug/moc_GTestExecutable.cpp
-
-debug/moc_GTestRunner.cpp: include/GTestExecutable.h \
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestExecutable.h -o
debug/moc_GTestExecutable.cpp
+
+debug/moc_GTestRunner.cpp: include/ui_gtestrunner.h \
+ include/GTestExecutable.h \
include/GTestExecutableResults.h \
include/Defines.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
include/GTestSuite.h \
include/GTest.h \
- include/TestTreeWidget.h \
- include/TestTreeWidgetItem.h \
include/GTestRunner.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestRunner.h -o debug/moc_GTestRunner.cpp
-
-compiler_rcc_make_all:
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestRunner.h -o
debug/moc_GTestRunner.cpp
+
+debug/moc_TestTreeModel.cpp: include/TestTreeModel.h
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/TestTreeModel.h -o
debug/moc_TestTreeModel.cpp
+
+compiler_rcc_make_all: debug/qrc_gtestrunner.cpp
compiler_rcc_clean:
+ -$(DEL_FILE) debug/qrc_gtestrunner.cpp
+debug/qrc_gtestrunner.cpp: resources/gtestrunner.qrc \
+ resources/plus.svg \
+ resources/reload.svg \
+ resources/help.svg \
+ resources/remove.svg \
+ resources/savefileas.svg \
+ resources/stop.svg \
+ resources/run.svg \
+ resources/exit.svg \
+ resources/openfile.svg \
+ resources/qt.png \
+ resources/newfile.svg \
+ resources/savefile.svg
+ /usr/bin/rcc -name gtestrunner resources/gtestrunner.qrc -o
debug/qrc_gtestrunner.cpp
+
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
-compiler_uic_make_all:
+compiler_uic_make_all: include/ui_gtestrunner.h
compiler_uic_clean:
+ -$(DEL_FILE) include/ui_gtestrunner.h
+include/ui_gtestrunner.h: resources/gtestrunner.ui
+ /usr/bin/uic-qt4 resources/gtestrunner.ui -o include/ui_gtestrunner.h
+
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
-compiler_clean: compiler_moc_header_clean
+compiler_clean: compiler_moc_header_clean compiler_rcc_clean
compiler_uic_clean
####### Compile
-debug/TestTreeWidgetItem.o: src/TestTreeWidgetItem.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TestTreeWidgetItem.o
src/TestTreeWidgetItem.cpp
-
-debug/TestTreeWidget.o: src/TestTreeWidget.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TestTreeWidget.o
src/TestTreeWidget.cpp
-
debug/GTestResults.o: src/GTestResults.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestResults.o
src/GTestResults.cpp
@@ -239,8 +244,8 @@
debug/GTestExecutable.o: src/GTestExecutable.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestExecutable.o
src/GTestExecutable.cpp
-debug/main.o: main.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/main.o main.cpp
+debug/main.o: src/main.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/main.o src/main.cpp
debug/GTestParser.o: src/GTestParser.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestParser.o
src/GTestParser.cpp
@@ -248,11 +253,11 @@
debug/GTestRunner.o: src/GTestRunner.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestRunner.o
src/GTestRunner.cpp
-debug/moc_TestTreeWidgetItem.o: debug/moc_TestTreeWidgetItem.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_TestTreeWidgetItem.o
debug/moc_TestTreeWidgetItem.cpp
-
-debug/moc_TestTreeWidget.o: debug/moc_TestTreeWidget.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_TestTreeWidget.o
debug/moc_TestTreeWidget.cpp
+debug/TestTreeModel.o: src/TestTreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TestTreeModel.o
src/TestTreeModel.cpp
+
+debug/TestTreeItem.o: src/TestTreeItem.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TestTreeItem.o
src/TestTreeItem.cpp
debug/moc_GTestSuite.o: debug/moc_GTestSuite.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_GTestSuite.o
debug/moc_GTestSuite.cpp
@@ -266,6 +271,12 @@
debug/moc_GTestRunner.o: debug/moc_GTestRunner.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_GTestRunner.o
debug/moc_GTestRunner.cpp
+debug/moc_TestTreeModel.o: debug/moc_TestTreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_TestTreeModel.o
debug/moc_TestTreeModel.cpp
+
+debug/qrc_gtestrunner.o: debug/qrc_gtestrunner.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/qrc_gtestrunner.o
debug/qrc_gtestrunner.cpp
+
####### Install
install: FORCE
=======================================
--- /trunk/Makefile.Release Thu Aug 12 16:12:42 2010
+++ /trunk/Makefile.Release Sat Sep 25 09:25:39 2010
@@ -1,6 +1,6 @@
#############################################################################
-# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Aug 11 20:01:39 2010
+# Makefile for building: gtestrunner
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Sep 25 13:21:13 2010
# Project: GTestRunner.pro
# Template: app
#############################################################################
@@ -9,16 +9,16 @@
CC = gcc
CXX = g++
-DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH = -I/usr/local/Trolltech/Qt-4.6.2/mkspecs/linux-g++-64 -I.
-I/usr/local/Trolltech/Qt-4.6.2/include/QtCore
-I/usr/local/Trolltech/Qt-4.6.2/include/QtGui
-I/usr/local/Trolltech/Qt-4.6.2/include -Iinclude -Irelease
+DEFINES = -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB
-DQT_SHARED
+CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I.
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml
-I/usr/include/qt4 -Iinclude -Irelease -Iinclude
LINK = g++
-LFLAGS = -m64 -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt-4.6.2/lib
-LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-4.6.2/lib -lQtGui
-L/usr/local/Trolltech/Qt-4.6.2/lib -L/usr/X11R6/lib64 -lQtCore -lpthread
+LFLAGS = -Wl,-O1
+LIBS = $(SUBLIBS) -L/usr/lib -lQtXml -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
-QMAKE = /usr/local/Trolltech/Qt-4.6.2/bin/qmake
+QMAKE = /usr/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
@@ -42,25 +42,23 @@
####### Files
-SOURCES = src/TestTreeWidgetItem.cpp \
- src/TestTreeWidget.cpp \
- src/GTestResults.cpp \
+SOURCES = src/GTestResults.cpp \
src/GTestSuiteResults.cpp \
src/GTestSuite.cpp \
src/GTestExecutableResults.cpp \
src/GTest.cpp \
src/GTestExecutable.cpp \
- main.cpp \
+ src/main.cpp \
src/GTestParser.cpp \
- src/GTestRunner.cpp release/moc_TestTreeWidgetItem.cpp \
- release/moc_TestTreeWidget.cpp \
- release/moc_GTestSuite.cpp \
+ src/GTestRunner.cpp \
+ src/TestTreeModel.cpp \
+ src/TestTreeItem.cpp release/moc_GTestSuite.cpp \
release/moc_GTest.cpp \
release/moc_GTestExecutable.cpp \
- release/moc_GTestRunner.cpp
-OBJECTS = release/TestTreeWidgetItem.o \
- release/TestTreeWidget.o \
- release/GTestResults.o \
+ release/moc_GTestRunner.cpp \
+ release/moc_TestTreeModel.cpp \
+ release/qrc_gtestrunner.cpp
+OBJECTS = release/GTestResults.o \
release/GTestSuiteResults.o \
release/GTestSuite.o \
release/GTestExecutableResults.o \
@@ -69,37 +67,39 @@
release/main.o \
release/GTestParser.o \
release/GTestRunner.o \
- release/moc_TestTreeWidgetItem.o \
- release/moc_TestTreeWidget.o \
+ release/TestTreeModel.o \
+ release/TestTreeItem.o \
release/moc_GTestSuite.o \
release/moc_GTest.o \
release/moc_GTestExecutable.o \
- release/moc_GTestRunner.o
-DIST = /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/g++.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/unix.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/common/linux.conf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/qconfig.pri \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_functions.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt_config.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/exclusive_builds.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_pre.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/release.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/debug_and_release.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/default_post.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/build_pass.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/warn_on.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/qt.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/unix/thread.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/moc.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/resources.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/uic.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/yacc.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/lex.prf \
- /usr/local/Trolltech/Qt-4.6.2/mkspecs/features/include_source_dir.prf \
+ release/moc_GTestRunner.o \
+ release/moc_TestTreeModel.o \
+ release/qrc_gtestrunner.o
+DIST = /usr/share/qt4/mkspecs/common/g++.conf \
+ /usr/share/qt4/mkspecs/common/unix.conf \
+ /usr/share/qt4/mkspecs/common/linux.conf \
+ /usr/share/qt4/mkspecs/qconfig.pri \
+ /usr/share/qt4/mkspecs/features/qt_functions.prf \
+ /usr/share/qt4/mkspecs/features/qt_config.prf \
+ /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
+ /usr/share/qt4/mkspecs/features/default_pre.prf \
+ /usr/share/qt4/mkspecs/features/release.prf \
+ /usr/share/qt4/mkspecs/features/debug_and_release.prf \
+ /usr/share/qt4/mkspecs/features/default_post.prf \
+ /usr/share/qt4/mkspecs/features/build_pass.prf \
+ /usr/share/qt4/mkspecs/features/warn_on.prf \
+ /usr/share/qt4/mkspecs/features/qt.prf \
+ /usr/share/qt4/mkspecs/features/unix/thread.prf \
+ /usr/share/qt4/mkspecs/features/moc.prf \
+ /usr/share/qt4/mkspecs/features/resources.prf \
+ /usr/share/qt4/mkspecs/features/uic.prf \
+ /usr/share/qt4/mkspecs/features/yacc.prf \
+ /usr/share/qt4/mkspecs/features/lex.prf \
+ /usr/share/qt4/mkspecs/features/include_source_dir.prf \
GTestRunner.pro
-QMAKE_TARGET = GTestRunner
+QMAKE_TARGET = gtestrunner
DESTDIR =
-TARGET = GTestRunner
+TARGET = gtestrunner
first: all
####### Implicit rules
@@ -125,15 +125,15 @@
all: Makefile.Release $(TARGET)
-$(TARGET): $(OBJECTS)
+$(TARGET): include/ui_gtestrunner.h $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
qmake: FORCE
- @$(QMAKE) -unix CONFIG+=debug_and_release -o Makefile.Release
GTestRunner.pro
+ @$(QMAKE) -unix -o Makefile.Release GTestRunner.pro
dist:
- @$(CHK_DIR_EXISTS) release/GTestRunner1.0.0 || $(MKDIR)
release/GTestRunner1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) release/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents include/TestTreeWidgetItem.h
include/TestTreeWidget.h include/GTestSuiteResults.h include/GTestResults.h
include/GTestSuite.h include/Defines.h include/GTestExecutableResults.h
include/GTest.h include/GTestExecutable.h include/GTestParser.h
include/GTestRunner.h release/GTestRunner1.0.0/ && $(COPY_FILE) --parents
src/TestTreeWidgetItem.cpp src/TestTreeWidget.cpp src/GTestResults.cpp
src/GTestSuiteResults.cpp src/GTestSuite.cpp src/GTestExecutableResults.cpp
src/GTest.cpp src/GTestExecutable.cpp main.cpp src/GTestParser.cpp
src/GTestRunner.cpp release/GTestRunner1.0.0/ && (cd `dirname
release/GTestRunner1.0.0` && $(TAR) GTestRunner1.0.0.tar GTestRunner1.0.0
&& $(COMPRESS) GTestRunner1.0.0.tar) && $(MOVE) `dirname
release/GTestRunner1.0.0`/GTestRunner1.0.0.tar.gz . && $(DEL_FILE) -r
release/GTestRunner1.0.0
+ @$(CHK_DIR_EXISTS) release/gtestrunner1.0.0 || $(MKDIR)
release/gtestrunner1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) release/gtestrunner1.0.0/ &&
$(COPY_FILE) --parents include/GTestSuiteResults.h include/GTestResults.h
include/GTestSuite.h include/Defines.h include/GTestExecutableResults.h
include/GTest.h include/GTestExecutable.h include/GTestParser.h
include/GTestRunner.h include/TestTreeModel.h include/TestTreeItem.h
release/gtestrunner1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.qrc release/gtestrunner1.0.0/ && $(COPY_FILE)
--parents src/GTestResults.cpp src/GTestSuiteResults.cpp src/GTestSuite.cpp
src/GTestExecutableResults.cpp src/GTest.cpp src/GTestExecutable.cpp
src/main.cpp src/GTestParser.cpp src/GTestRunner.cpp src/TestTreeModel.cpp
src/TestTreeItem.cpp release/gtestrunner1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.ui release/gtestrunner1.0.0/ && (cd `dirname
release/gtestrunner1.0.0` && $(TAR) gtestrunner1.0.0.tar gtestrunner1.0.0
&& $(COMPRESS) gtestrunner1.0.0.tar) && $(MOVE) `dirname
release/gtestrunner1.0.0`/gtestrunner1.0.0.tar.gz . && $(DEL_FILE) -r
release/gtestrunner1.0.0
clean:compiler_clean
@@ -152,28 +152,17 @@
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
-compiler_moc_header_make_all: release/moc_TestTreeWidgetItem.cpp
release/moc_TestTreeWidget.cpp release/moc_GTestSuite.cpp
release/moc_GTest.cpp release/moc_GTestExecutable.cpp
release/moc_GTestRunner.cpp
+compiler_moc_header_make_all: release/moc_GTestSuite.cpp
release/moc_GTest.cpp release/moc_GTestExecutable.cpp
release/moc_GTestRunner.cpp release/moc_TestTreeModel.cpp
compiler_moc_header_clean:
- -$(DEL_FILE) release/moc_TestTreeWidgetItem.cpp
release/moc_TestTreeWidget.cpp release/moc_GTestSuite.cpp
release/moc_GTest.cpp release/moc_GTestExecutable.cpp
release/moc_GTestRunner.cpp
-release/moc_TestTreeWidgetItem.cpp: include/GTestResults.h \
- include/TestTreeWidgetItem.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/TestTreeWidgetItem.h -o release/moc_TestTreeWidgetItem.cpp
-
-release/moc_TestTreeWidget.cpp: include/GTest.h \
- include/GTestResults.h \
- include/TestTreeWidgetItem.h \
- include/TestTreeWidget.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/TestTreeWidget.h -o release/moc_TestTreeWidget.cpp
-
+ -$(DEL_FILE) release/moc_GTestSuite.cpp release/moc_GTest.cpp
release/moc_GTestExecutable.cpp release/moc_GTestRunner.cpp
release/moc_TestTreeModel.cpp
release/moc_GTestSuite.cpp: include/GTest.h \
- include/GTestResults.h \
include/GTestSuiteResults.h \
+ include/GTestResults.h \
include/GTestSuite.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestSuite.h -o release/moc_GTestSuite.cpp
-
-release/moc_GTest.cpp: include/GTestResults.h \
- include/GTest.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTest.h -o release/moc_GTest.cpp
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestSuite.h -o
release/moc_GTestSuite.cpp
+
+release/moc_GTest.cpp: include/GTest.h
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTest.h -o
release/moc_GTest.cpp
release/moc_GTestExecutable.cpp: include/GTestExecutableResults.h \
include/Defines.h \
@@ -182,45 +171,61 @@
include/GTestSuite.h \
include/GTest.h \
include/GTestExecutable.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestExecutable.h -o release/moc_GTestExecutable.cpp
-
-release/moc_GTestRunner.cpp: include/GTestExecutable.h \
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestExecutable.h -o
release/moc_GTestExecutable.cpp
+
+release/moc_GTestRunner.cpp: include/ui_gtestrunner.h \
+ include/GTestExecutable.h \
include/GTestExecutableResults.h \
include/Defines.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
include/GTestSuite.h \
include/GTest.h \
- include/TestTreeWidget.h \
- include/TestTreeWidgetItem.h \
include/GTestRunner.h
- /usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestRunner.h -o release/moc_GTestRunner.cpp
-
-compiler_rcc_make_all:
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestRunner.h -o
release/moc_GTestRunner.cpp
+
+release/moc_TestTreeModel.cpp: include/TestTreeModel.h
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/TestTreeModel.h -o
release/moc_TestTreeModel.cpp
+
+compiler_rcc_make_all: release/qrc_gtestrunner.cpp
compiler_rcc_clean:
+ -$(DEL_FILE) release/qrc_gtestrunner.cpp
+release/qrc_gtestrunner.cpp: resources/gtestrunner.qrc \
+ resources/plus.svg \
+ resources/reload.svg \
+ resources/help.svg \
+ resources/remove.svg \
+ resources/savefileas.svg \
+ resources/stop.svg \
+ resources/run.svg \
+ resources/exit.svg \
+ resources/openfile.svg \
+ resources/qt.png \
+ resources/newfile.svg \
+ resources/savefile.svg
+ /usr/bin/rcc -name gtestrunner resources/gtestrunner.qrc -o
release/qrc_gtestrunner.cpp
+
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
-compiler_uic_make_all:
+compiler_uic_make_all: include/ui_gtestrunner.h
compiler_uic_clean:
+ -$(DEL_FILE) include/ui_gtestrunner.h
+include/ui_gtestrunner.h: resources/gtestrunner.ui
+ /usr/bin/uic-qt4 resources/gtestrunner.ui -o include/ui_gtestrunner.h
+
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
-compiler_clean: compiler_moc_header_clean
+compiler_clean: compiler_moc_header_clean compiler_rcc_clean
compiler_uic_clean
####### Compile
-release/TestTreeWidgetItem.o: src/TestTreeWidgetItem.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TestTreeWidgetItem.o
src/TestTreeWidgetItem.cpp
-
-release/TestTreeWidget.o: src/TestTreeWidget.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TestTreeWidget.o
src/TestTreeWidget.cpp
-
release/GTestResults.o: src/GTestResults.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestResults.o
src/GTestResults.cpp
@@ -239,8 +244,8 @@
release/GTestExecutable.o: src/GTestExecutable.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestExecutable.o
src/GTestExecutable.cpp
-release/main.o: main.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/main.o main.cpp
+release/main.o: src/main.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/main.o src/main.cpp
release/GTestParser.o: src/GTestParser.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestParser.o
src/GTestParser.cpp
@@ -248,11 +253,11 @@
release/GTestRunner.o: src/GTestRunner.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestRunner.o
src/GTestRunner.cpp
-release/moc_TestTreeWidgetItem.o: release/moc_TestTreeWidgetItem.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_TestTreeWidgetItem.o
release/moc_TestTreeWidgetItem.cpp
-
-release/moc_TestTreeWidget.o: release/moc_TestTreeWidget.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_TestTreeWidget.o
release/moc_TestTreeWidget.cpp
+release/TestTreeModel.o: src/TestTreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TestTreeModel.o
src/TestTreeModel.cpp
+
+release/TestTreeItem.o: src/TestTreeItem.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TestTreeItem.o
src/TestTreeItem.cpp
release/moc_GTestSuite.o: release/moc_GTestSuite.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_GTestSuite.o
release/moc_GTestSuite.cpp
@@ -266,6 +271,12 @@
release/moc_GTestRunner.o: release/moc_GTestRunner.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_GTestRunner.o
release/moc_GTestRunner.cpp
+release/moc_TestTreeModel.o: release/moc_TestTreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_TestTreeModel.o
release/moc_TestTreeModel.cpp
+
+release/qrc_gtestrunner.o: release/qrc_gtestrunner.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/qrc_gtestrunner.o
release/qrc_gtestrunner.cpp
+
####### Install
install: FORCE
=======================================
--- /trunk/include/GTestExecutable.h Tue Aug 17 16:53:58 2010
+++ /trunk/include/GTestExecutable.h Sat Sep 25 09:25:39 2010
@@ -108,6 +108,7 @@
//METHODS:
void produceListing();
+ virtual void run();
};
Q_DECLARE_METATYPE(GTestExecutable*);
=======================================
--- /trunk/include/GTestRunner.h Tue Aug 17 16:53:58 2010
+++ /trunk/include/GTestRunner.h Sat Sep 25 09:25:39 2010
@@ -30,8 +30,11 @@
#include <QToolBar>
#include <QTreeWidget>
+#include "ui_gtestrunner.h"
+
#include "GTestExecutable.h"
-#include "TestTreeWidget.h"
+
+class TestTreeModel;
/*! \brief The is the main application window class.
*
@@ -39,7 +42,7 @@
* change as the application grows). It provides the interaction between
* the test running functionality and the user.
*/
-class GTestRunner : public QMainWindow
+class GTestRunner : public QMainWindow, private Ui::GTestRunner
{
Q_OBJECT
@@ -53,26 +56,14 @@
public slots:
void addTests();
- void runTests();
void treeItemClicked(QTreeWidgetItem* item, int column);
private:
- QMenuBar *menuBar; //!< The main menu bar.
- QMenu fileMenu; //!< The file menu.
- QMenu helpMenu; //!< The help menu.
- QStatusBar statusBar; //!< The status bar.
-
- QWidget centralWidget; //!< The <a
href="http://doc.qt.nokia.com/4.6/qmainwindow.html#details">central
widget</a>.
- QToolBar testTreeTools; //!< The tool bar for the test tree.
- TestTreeWidget testTree;//!< The test tree.
-
void setup();
- void setupMenus();
- void setupToolBars();
- void setupLayout();
-
void invokeListingRetrieval(QSharedPointer<GTestExecutable> gtest);
+ TestTreeModel* testModel;
+
};
#endif // GTESTRUNNER_H
=======================================
--- /trunk/include/GTestSuiteResults.h Sat Aug 7 11:11:45 2010
+++ /trunk/include/GTestSuiteResults.h Sat Sep 25 09:25:39 2010
@@ -22,13 +22,19 @@
#include "GTestResults.h"
+/*! \brief This class logically represents the results of running a suite
of unit tests.
+ *
+ * The class is the analogue to a gtest suite's test results. It consists
of the name of
+ * the test suite (which is used to assign the result to the correct
GTestSuite), the running
+ * time, the error count, the failure count and run count of the suite's
constituents.
+ */
class GTestSuiteResults : public GTestResults {
protected:
- QHash<QString, GTestResults*> testResultsHash;
- uint errorCount;
- uint failureCount;
- uint runCount;
+ QHash<QString, GTestResults*> testResultsHash; //!< A hash to map between
a test name and its results.
+ uint errorCount; //!< The number of errors produced by the suite's
tests.
+ uint failureCount; //!< The number of failures in the suite's tests.
+ uint runCount; //!< The number of tests that were run.
public:
GTestSuiteResults(QString name);
@@ -45,24 +51,60 @@
uint getRunCount() const;
};
+/*! \brief Adds the test result as a child of this test result.
+ *
+ * This inserts the test result into the hash for fast retrieval.
+ * \param testResults The results of a single unit test.
+ */
inline void GTestSuiteResults::addTestResults(GTestResults* testResults) {
testResultsHash.insert(testResults->getName(), testResults);
}
+/*! \brief Sets the number of errors this suite had when run.
+ *
+ * \param errorCount The number of test errors.
+ */
inline void GTestSuiteResults::setErrorCount(uint errorCount) {
this->errorCount = errorCount; }
+/*! \brief Sets the number of failures this suite had when run.
+ *
+ * \param failureCount The number of test failures.
+ */
inline void GTestSuiteResults::setFailureCount(uint failureCount) {
this->failureCount = failureCount; }
+/*! \brief Sets the number of unit tests that were run from this suite.
+ *
+ * \param runCount The number of tests run.
+ */
inline void GTestSuiteResults::setRunCount(uint runCount) { this->runCount
= runCount; }
+/*! \brief Retrieves the test results given by the test named 'testName'.
+ *
+ * If this test suite results object doesn't have a result for the given
test,
+ * a null pointer is returned.
+ * \param testName The name of the test to retrieve its results.
+ * \return The test result object for the test 'testName'.
+ */
inline GTestResults* GTestSuiteResults::getTestResults(QString testName) {
return testResultsHash.value(testName);
}
+/*! \brief Retrieves the number of errors that occurred in running this
suite.
+ *
+ * \return The number of errors.
+ */
inline uint GTestSuiteResults::getErrorCount() const { return errorCount; }
+/*! \brief Retrieves the number of failures that occurred in running this
suite.
+ *
+ * \return The number of failed tests.
+ */
inline uint GTestSuiteResults::getFailureCount() const { return
failureCount; }
+/*! \brief Retrieves the number of tests run by running this suite.
+ *
+ * \return The number of tests run.
+ */
inline uint GTestSuiteResults::getRunCount() const { return runCount; }
#endif /* GTESTSUITERESULTS_H_ */
=======================================
--- /trunk/src/GTestExecutable.cpp Tue Aug 17 16:53:58 2010
+++ /trunk/src/GTestExecutable.cpp Sat Sep 25 09:25:39 2010
@@ -99,7 +99,7 @@
standardOutput.open(QBuffer::ReadOnly);
while(standardOutput.canReadLine()) {
line = standardOutput.readLine();
- line.resize(line.size()-1); //remove \n
+ line.resize(line.size()-1); //remove '\n'
if(line.endsWith('.')) { //this means its a test suite name
name = line.left(line.size()-1); //get the name without the '.'
testSuite = findChild<GTestSuite*>(name);
@@ -172,6 +172,7 @@
this, SLOT(standardOutputAvailable()));
QObject::connect(gtest, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(parseTestResults(int, QProcess::ExitStatus)));
+ //! \todo Only run tests in the runList.
gtest->start(objectName(), QStringList()
<< "--gtest_output=xml:./test_detail_1337.xml");
//unlock the processLock in the parseTestResults slot
}
@@ -297,5 +298,15 @@
}
return state;
}
+
+/*! \brief Sets all tests in the executable to be run.
+ *
+ * This test should be run by right-clicking and selecting run on
+ * a test suite object.
+ */
+void GTestExecutable::run() {
+ GTestSuite::run();
+ runOnSignal = true;
+}
=======================================
--- /trunk/src/GTestRunner.cpp Tue Aug 17 16:53:58 2010
+++ /trunk/src/GTestRunner.cpp Sat Sep 25 09:25:39 2010
@@ -15,7 +15,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
#include "GTestRunner.h"
-#include "TestTreeWidgetItem.h"
+#include "TestTreeModel.h"
#include <QAction>
#include <QDebug>
@@ -24,6 +24,7 @@
#include <QMessageBox>
#include <QSharedPointer>
#include <QSignalMapper>
+#include <QTreeView>
#include <QTreeWidgetItem>
#include <QTreeWidgetItemIterator>
#include <QVBoxLayout>
@@ -35,11 +36,9 @@
* <a
href="http://doc.qt.nokia.com/4.6/qt.html#WindowType-enum">Qt::WFlags
Reference</a>
*/
GTestRunner::GTestRunner(QWidget *parent, Qt::WFlags flags)
- : QMainWindow(parent, flags), menuBar(0),
- fileMenu(tr("&File")), helpMenu(tr("&Help")), statusBar(this),
- centralWidget(this), testTreeTools(this), testTree(this)
-{
- resize(500, 800);
+ : QMainWindow(parent, flags)
+{
+ setupUi(this);
setup();
}
@@ -48,7 +47,6 @@
*/
GTestRunner::~GTestRunner()
{
- menuBar->deleteLater();
}
/*! \brief Sets up the application GUI.
@@ -57,99 +55,23 @@
* to set up as well.
*/
void GTestRunner::setup() {
- //menus
- menuBar = QMainWindow::menuBar();
- setupMenus();
- setMenuBar(menuBar);
-
- //toolbar
- setupToolBars();
-
- setCentralWidget(¢ralWidget);
-
- QObject::connect(&testTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
- this, SLOT(treeItemClicked(QTreeWidgetItem*, int)));
- QObject::connect(this, SIGNAL(aboutToRunTests()),
- &testTree, SIGNAL(resettingRunStates()));
- QObject::connect(this, SIGNAL(runningTests()),
- &testTree, SIGNAL(runningTests()));
-
- setupLayout();
-}
-
-/*! \brief Sets up the application's menus.
- *
- * Creates menu items and adds actions to them.
- */
-void GTestRunner::setupMenus() {
- QAction* newTestSetupAct = new QAction(tr("&New Test Setup..."), this);
- QAction* openTestSetupAct = new QAction(tr("&Open Test Setup..."), this);
- QAction* saveTestSetupAct = new QAction(tr("&Save Test Setup..."), this);
- QAction* importTestExeAct = new QAction(tr("&Import Test Executable"),
this);
- QAction* quitAct = new QAction(tr("&Exit"), this);
-
- QObject::connect(importTestExeAct, SIGNAL(triggered()),
+ testModel = new TestTreeModel();
+ testTree->setModel(testModel);
+
+ QObject::connect(aboutQtAction, SIGNAL(triggered()),
+ qApp, SLOT(aboutQt()));
+
+ QObject::connect(importTestAction, SIGNAL(triggered()),
this, SLOT(addTests()));
- fileMenu.addAction(newTestSetupAct);
- fileMenu.addAction(openTestSetupAct);
- fileMenu.addAction(saveTestSetupAct);
- fileMenu.addAction(importTestExeAct);
- fileMenu.addAction(quitAct);
-
- QAction* aboutAct = new QAction(tr("&About GTestRunner..."), this);
- QAction* aboutQtAct = new QAction(tr("About &Qt..."), this);
-
- helpMenu.addAction(aboutAct);
- helpMenu.addAction(aboutQtAct);
-
- menuBar->addMenu(&fileMenu);
- menuBar->addMenu(&helpMenu);
-}
-
-/*! \brief Sets up the application's toolbars.
- *
- * Creates the toolbars and adds actions to them.
- */
-void GTestRunner::setupToolBars() {
- QAction* runTestsAct = new QAction(tr("Run"), this);
- QAction* stopTestsAct = new QAction(tr("Stop"), this);
- QAction* addTestsAct = new QAction(tr("Add"), this);
- QAction* removeTestsAct = new QAction(tr("Remove"), this);
- QAction* refreshTestListAct = new QAction(tr("Refresh"), this);
-
- QObject::connect(runTestsAct, SIGNAL(triggered()),
- this, SLOT(runTests()));
-
- QObject::connect(addTestsAct, SIGNAL(triggered()),
- this, SLOT(addTests()));
-
- QObject::connect(refreshTestListAct, SIGNAL(triggered()),
- &testTree, SLOT(updateAllListings()));
-
- testTreeTools.addAction(runTestsAct);
- testTreeTools.addAction(stopTestsAct);
- testTreeTools.addAction(addTestsAct);
- testTreeTools.addAction(removeTestsAct);
- testTreeTools.addAction(refreshTestListAct);
-}
-
-/*! \brief Sets up the application's layout.
- *
- * After all the elements are created, they are placed
- * in their appropriate layout.
- */
-void GTestRunner::setupLayout() {
- QGroupBox *treeBox = new QGroupBox(tr("Unit Tests Loaded"));
- QVBoxLayout *treeLayout = new QVBoxLayout;
- treeLayout->addWidget(&testTreeTools);
- treeLayout->addWidget(&testTree);
- treeBox->setLayout(treeLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(treeBox);
-
- centralWidget.setLayout(mainLayout);
+ QObject::connect(runTestsAction, SIGNAL(triggered()),
+ testModel, SLOT(runTests()));
+
+ QObject::connect(refreshAction, SIGNAL(triggered()),
+ testTree, SLOT(updateAllListings()));
+
+ QObject::connect(removeTestsAction, SIGNAL(triggered()),
+ testTree, SLOT(removeSelectedTests()));
}
/*! \brief Slot to prompt a dialog to have the user add unit tests to run.
@@ -162,7 +84,6 @@
void GTestRunner::addTests() {
bool addResolved = false; //flag to see if we've got a good test.
QString filepath;
- QSharedPointer<GTestExecutable> newTest =
QSharedPointer<GTestExecutable>(new GTestExecutable(this));
while(!addResolved) {
filepath = QFileDialog::getOpenFileName(this, tr("Select Google Test
Executable"));
qDebug() << "File path received:" << filepath;
@@ -170,10 +91,8 @@
return;
//Non-empty path, so let's check out whether we can use it or not.
- newTest->setExecutablePath(filepath);
- GTestExecutable::STATE state = newTest->getState();
- switch(state) {
- case GTestExecutable::FILE_NOT_FOUND: {
+ switch(testModel->addDataSource(filepath)) {
+ case TestTreeModel::FILE_NOT_FOUND: {
QMessageBox::StandardButton btnPressed = QMessageBox::warning(this,
tr("File Not Found"),
tr("It appears the filename entered does not exist. Please select a
valid Google test executable."),
@@ -186,7 +105,7 @@
}
break;
}
- case GTestExecutable::INSUFFICIENT_PRIVILEGES: {
+ case TestTreeModel::INSUFFICIENT_PRIVILEGES: {
QMessageBox::StandardButton btnPressed = QMessageBox::warning(this,
tr("Insufficient Permissions"),
tr("It appears that you do not have sufficient privileges to execute
this file. \
@@ -212,43 +131,22 @@
}
break;
}
- case GTestExecutable::VALID: {
- testTree.insertExecutable(newTest);
- addResolved = true;
+ case TestTreeModel::UNKNOWN: {
+ QMessageBox::warning(this,
+ tr("Unknown Error"),
+ tr("An unknown error has occured."),
+ QMessageBox::Ok);
break;
}
+ case TestTreeModel::NO_ERROR: {
+ return;
+// testTree->insertExecutable(newTest);
+// addResolved = true;
+// break;
+ }
}
}
}
-
-/*! \brief Runs all tests that are checked.
- *
- */
-void GTestRunner::runTests() {
- emit aboutToRunTests();
- QTreeWidgetItemIterator it(&testTree,
QTreeWidgetItemIterator::NoChildren);
- while(*it) {
- if((*it)->checkState(0) != Qt::Checked) {
- it++;
- continue;
- }
- (*it)->data(0,Qt::UserRole).value<GTest*>()->run();
- it++;
- }
- for(int i=0, j=testTree.topLevelItemCount(); i<j; i++) {
- QTreeWidgetItem* topLevelItem = testTree.topLevelItem(i);
- if(topLevelItem->checkState(0) == Qt::Unchecked)
- continue;
- GTestExecutable* gtest =
topLevelItem->data(0,Qt::UserRole).value<GTestExecutable*>();
- if(gtest != 0 && gtest->getState() == GTestExecutable::VALID) {
- gtest->setRunFlag(true);
- }
- else
- QMessageBox::warning(this,"Invalid Google Test",
- "An error has occurred when attempting to run a Google Test.");
- }
- emit runningTests();
-}
/*! \brief Slot to handle maintaining valid checkbox states.
*
=======================================
--- /trunk/src/GTestSuite.cpp Tue Aug 17 16:53:58 2010
+++ /trunk/src/GTestSuite.cpp Sat Sep 25 09:25:39 2010
@@ -86,12 +86,18 @@
emit testResultsReady();
}
-/*! \brief Runs all tests in the suite immediately.
+/*! \brief Sets all tests in the suite to be run.
*
* This test should be run by right-clicking and selecting run on
* a test suite object.
- * \todo TODO::Run all tests in suite immediately.
*/
void GTestSuite::run() {
+ runList.clear();
+ runList.append(reinterpret_cast<const QList<GTest*>& >(this->children()));
+ QList<GTest*>::iterator it = runList.begin();
+ while(it != runList.end()) {
+ (*it)->run();
+ ++it;
+ }
}