http://code.google.com/p/gtest-runner-qt/source/detail?r=27
Modified:
/trunk/Makefile
/trunk/Makefile.Debug
/trunk/Makefile.Release
/trunk/include/Defines.h
/trunk/include/GTest.h
/trunk/include/GTestExecutable.h
/trunk/include/GTestExecutableResults.h
/trunk/include/GTestResults.h
/trunk/include/GTestRunner.h
/trunk/include/TestTreeWidget.h
/trunk/include/TestTreeWidgetItem.h
/trunk/src/GTestExecutable.cpp
/trunk/src/GTestExecutableResults.cpp
/trunk/src/GTestParser.cpp
/trunk/src/GTestResults.cpp
/trunk/src/GTestRunner.cpp
/trunk/src/GTestSuite.cpp
/trunk/src/GTestSuiteResults.cpp
/trunk/src/TestTreeWidget.cpp
/trunk/src/TestTreeWidgetItem.cpp
=======================================
--- /trunk/Makefile Sat Aug 7 11:11:45 2010
+++ /trunk/Makefile Thu Aug 12 16:12:42 2010
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Aug 7 14:42:20 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Aug 11 20:01:39 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
=======================================
--- /trunk/Makefile.Debug Sat Aug 7 11:11:45 2010
+++ /trunk/Makefile.Debug Thu Aug 12 16:12:42 2010
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Aug 7 14:42:20 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Aug 11 20:01:39 2010
# Project: GTestRunner.pro
# Template: app
#############################################################################
@@ -133,7 +133,7 @@
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/GTestResultsItem.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
+ $(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
clean:compiler_clean
=======================================
--- /trunk/Makefile.Release Sat Aug 7 11:11:45 2010
+++ /trunk/Makefile.Release Thu Aug 12 16:12:42 2010
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Aug 7 14:42:20 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Aug 11 20:01:39 2010
# Project: GTestRunner.pro
# Template: app
#############################################################################
@@ -133,7 +133,7 @@
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/GTestResultsItem.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
+ $(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
clean:compiler_clean
=======================================
--- /trunk/include/Defines.h Sun Aug 8 10:59:31 2010
+++ /trunk/include/Defines.h Thu Aug 12 16:12:42 2010
@@ -22,6 +22,6 @@
#ifndef DEFINES_H_
#define DEFINES_H_
-typedef unsigned int uint;
+typedef unsigned int uint; //!< An unsigned integer type, should I be
using uint32_t?
#endif /* DEFINES_H_ */
=======================================
--- /trunk/include/GTest.h Tue Aug 10 15:48:07 2010
+++ /trunk/include/GTest.h Thu Aug 12 16:12:42 2010
@@ -23,7 +23,6 @@
#include "GTestResults.h"
-
/*! \brief This class logically represents a single unit test.
*
* This class attempts to mirror what an actual unit test is comprised of.
@@ -49,8 +48,8 @@
*/
signals:
- void requestingRun(QString testName, QString caseName = QString());
- void testResultsReady();
+ void requestingRun(QString testName, QString caseName = QString()); //!<
Sends a request to the parent GTest
+ void testResultsReady(); //!< Sends a notification that the test results
have been received and are ready to be read.
public:
GTest(QObject* parent = 0, QString name = QString());
=======================================
--- /trunk/include/GTestExecutable.h Tue Aug 10 15:48:07 2010
+++ /trunk/include/GTestExecutable.h Thu Aug 12 16:12:42 2010
@@ -74,7 +74,7 @@
void readExecutableOutput(QBuffer& standardChannel);
signals:
- void listingReady(GTestExecutable* sender);
+ void listingReady(GTestExecutable* sender); //!< Sends notification that
a new listing has been received.
public slots:
void standardErrorAvailable();
@@ -123,7 +123,7 @@
* this is semantically clearer. This should either be removed, or
* perhaps a 'name' and 'filepath' could be two separate variables
* where 'filepath' is the full path and 'name' is simply the filename.
- * \TODO TODO::create a new instance variable 'filePath'.
+ * \todo TODO::create a new instance variable 'filePath'.
*/
inline QString GTestExecutable::getExecutablePath() const { return name; }
@@ -154,7 +154,7 @@
* valid and that produceListing() and runTest() will work by calling
* GTestExecutable::getState()
* \param executablePath The fully qualified path to a gtest executable.
- * \TODO TODO::set the return value of this function to return STATE
+ * \todo TODO::set the return value of this function to return STATE
*/
inline void GTestExecutable::setExecutablePath(QString executablePath) {
this->name = executablePath; }
@@ -169,7 +169,7 @@
*
* Resetting the executable prepares it to be run again and produce new
* test results.
- * \TODO TODO::This should be clearing the buffers, runList, etc.
+ * \todo TODO::This should be clearing the buffers, runList, etc.
*/
inline void GTestExecutable::resetRunState() { setRunFlag(false); }
=======================================
--- /trunk/include/GTestExecutableResults.h Sat Aug 7 11:11:45 2010
+++ /trunk/include/GTestExecutableResults.h Thu Aug 12 16:12:42 2010
@@ -24,6 +24,12 @@
#include "Defines.h"
#include "GTestSuiteResults.h"
+/*! \brief Placeholder class to differentiate from GTestSuiteResults.
+ *
+ * Currently, this class provides no functionality beyond that of a
+ * GTestSuiteResults object. However, further changes to the software
+ * may prompt usefulness from this class.
+ */
class GTestExecutableResults : public GTestSuiteResults {
public:
=======================================
--- /trunk/include/GTestResults.h Tue Aug 10 15:48:07 2010
+++ /trunk/include/GTestResults.h Thu Aug 12 16:12:42 2010
@@ -33,7 +33,7 @@
//! The run status of the GTest.
enum STATUS {
RUN, //!< The test was run.
- //! \TODO TODO::Investigate other run status of a GTest.
+ //! \todo TODO::Investigate other run status of a GTest.
UNDEFINED //!< Currently not sure what the other possibilities are.
};
@@ -53,6 +53,7 @@
GTestResults(QString name);
virtual ~GTestResults();
+ //TODO::Check whether these should be private and have GTestExecutable as
a friend.
void setStatus(QString status);
void setRunningTime(uint runTime);
void addFailureMessage(QString failureMsg);
@@ -61,48 +62,109 @@
QString getName() const;
uint getRunningTime() const;
virtual uint getFailureCount() const;
- QString getFailureMessage(uint num) const;
+ QString getFailureMessage(uint index) const;
QStringList getFailureMessages() const;
virtual GTestResults* getTestResults(QString name);
};
+/*! \brief Sets the run status of the gtest.
+ *
+ * This function takes a QString from the 'run' attribute in the
+ * .xml file. It parses this and sets it to a enum value for later
+ * retrieval.
+ * \param statusString The status as retrieved from the gtest .xml file.
+ */
inline void GTestResults::setStatus(QString statusString) {
if(statusString == "run")
status = RUN;
}
+/*! \brief Sets the elapsed running time of the gtest.
+ *
+ * This function takes the 'time' attribute in the .xml file.
+ * It parses this and sets it to a enum value for later retrieval.
+ * \param runTime The running time as retrieved from the gtest .xml file.
+ */
inline void GTestResults::setRunningTime(uint runTime) {
time = runTime;
}
+/*! \brief Adds a failure message to the list of failure messages.
+ *
+ * This appends a failure message to the end of the list of failure
messages.
+ * \param failureMsg The failure message as retrieved from the gtest
executable.
+ */
inline void GTestResults::addFailureMessage(QString failureMsg) {
failureMessages.append(failureMsg);
}
+/*! \brief Retrieves the run status of the unit test.
+ *
+ * This function gives the run status for the unit test result that
+ * this object represents.
+ * \return The run status of the unit test.
+ */
inline GTestResults::STATUS GTestResults::getStatus() const { return
status; }
+/*! \brief Retrieves the name of the unit test this result belongs to.
+ *
+ * \return The name of the unit test this result belongs to.
+ */
inline QString GTestResults::getName() const {
return name;
}
+/*! \brief Retrieves the time elapsed from this unit test.
+ *
+ * For single tests, this is the time it took to run the unit test.
+ * In subclasses, this is used to get the total running time of an
+ * aggregate of tests.
+ * \return The total elapses time for this test.
+ */
inline uint GTestResults::getRunningTime() const {
return time;
}
+/*! \brief Retrieves the total number of failure messages for this test.
+ *
+ * \note There can be multiple failures per test.
+ * \return The number of failures.
+ */
inline uint GTestResults::getFailureCount() const {
return failureMessages.size();
}
-inline QString GTestResults::getFailureMessage(uint num) const {
- return failureMessages.at(num);
+/*! \brief Retrieves the failure message indexed by 'index'.
+ *
+ * This retrieves the index'th failure string from the list of
+ * failure strings.
+ * \note If you wish to iterate through all failure messages, it
+ * is recommended that you retrieve a copy of the entire list
+ * of messages \see GTestResults::getFailureMessage().
+ * \return The failure message at index 'index.
+ */
+inline QString GTestResults::getFailureMessage(uint index) const {
+ return failureMessages.at(index);
}
+/*! \brief Retrieves the entire list of failure messages.
+ *
+ * If you wish to iterate through all messages, this function is the
+ * prefered method to call.
+ * \return A copy of the entire list of failure messages.
+ */
inline QStringList GTestResults::getFailureMessages() const {
return failureMessages;
}
+/*! \brief Retrieves the test result object with name 'name'.
+ *
+ * This function is primarily for subclasses which may hold references
+ * to other test results.
+ * \return A pointer to a GTestResult.
+ */
inline GTestResults* GTestResults::getTestResults(QString name) { return
(name == this->name ? this : 0); }
#endif /* GTESTRESULTS_H_ */
=======================================
--- /trunk/include/GTestRunner.h Sat Aug 7 11:11:45 2010
+++ /trunk/include/GTestRunner.h Thu Aug 12 16:12:42 2010
@@ -33,6 +33,12 @@
#include "GTestExecutable.h"
#include "TestTreeWidget.h"
+/*! \brief The is the main application window class.
+ *
+ * This class handles all the GUI functionality of the application (this
may
+ * change as the application grows). It provides the interaction between
+ * the test running functionality and the user.
+ */
class GTestRunner : public QMainWindow
{
Q_OBJECT
@@ -42,8 +48,8 @@
~GTestRunner();
signals:
- void aboutToRunTests();
- void runningTests();
+ void aboutToRunTests(); //!< Sends a signal to any listeners to prepare
for test runs.
+ void runningTests(); //!< Sends a signal when the processes have been
launched.
public slots:
void addTests();
@@ -54,23 +60,23 @@
void treeItemClicked(QTreeWidgetItem* item, int column);
private:
- QMenuBar *menuBar;
- QMenu fileMenu;
- QMenu helpMenu;
- QStatusBar statusBar;
-
- QWidget centralWidget;
- QToolBar testTreeTools;
- TestTreeWidget testTree;
-
- QList<GTestExecutable*> gtestList;
+ 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.
+
+ QList<GTestExecutable*> gtestList; //!< A list of all loaded gtest
executables. \todo TODO::change list to a hash.
void setup();
void setupMenus();
void setupToolBars();
void setupLayout();
- void invokeListingRetrieval(QString filename);
+ void invokeListingRetrieval(GTestExecutable* gtest);
};
=======================================
--- /trunk/include/TestTreeWidget.h Sat Aug 7 11:11:45 2010
+++ /trunk/include/TestTreeWidget.h Thu Aug 12 16:12:42 2010
@@ -24,6 +24,12 @@
#include "GTestResults.h"
#include "TestTreeWidgetItem.h"
+/*! \brief An extension of the QTreeWidget to provide custom functionality.
+ *
+ * Currently, the only purpose of this subclass is to provide a mechanism
of
+ * custom defined slots to asynchronously populate test results into the
+ * tree.
+ */
class TestTreeWidget : public QTreeWidget {
Q_OBJECT
=======================================
--- /trunk/include/TestTreeWidgetItem.h Sat Aug 7 11:11:45 2010
+++ /trunk/include/TestTreeWidgetItem.h Thu Aug 12 16:12:42 2010
@@ -22,6 +22,10 @@
#include "GTestResults.h"
+/*! \brief Extends the QTreeWidgetItem to make a QObject derived version.
+ *
+ * \todo TODO::Examine alternative solutions to this structure (Custom
treeview with hash data struct).
+ */
class TestTreeWidgetItem : public QObject, public QTreeWidgetItem {
Q_OBJECT
=======================================
--- /trunk/src/GTestExecutable.cpp Tue Aug 10 15:48:07 2010
+++ /trunk/src/GTestExecutable.cpp Thu Aug 12 16:12:42 2010
@@ -54,7 +54,7 @@
* A caller can determine when the listing is ready by connecting a slot to
* the listingReady() slot.
*
- * \TODO TODO::check the state variable before running.
+ * \todo TODO::check the state variable before running.
*/
void GTestExecutable::produceListing() {
//We lock so that any attempt to try to produce a listing
@@ -79,7 +79,7 @@
* processes the stdout buffer that was filled by the gtest executable.
* It breaks the buffer into lines which is then understood by the
GTestRunner.
*
- * \TODO TODO::Have this function create the GTest / GTestSuite tree
instead of the test runner
+ * \todo TODO::Have this function create the GTest / GTestSuite tree
instead of the test runner
*/
void GTestExecutable::parseListing(int /*exitCode*/, QProcess::ExitStatus
exitStatus) {
if(exitStatus != QProcess::NormalExit) {
@@ -105,7 +105,7 @@
* This creates a process and runs it based on the 'name' instance
* variable which represents the filepath of the executable.
*
- * \TODO TODO::Check the state before running the test.
+ * \todo TODO::Check the state before running the test.
*/
void GTestExecutable::runTest() {
//We lock so that any attempt to try to produce a listing
=======================================
--- /trunk/src/GTestExecutableResults.cpp Sat Aug 7 11:11:45 2010
+++ /trunk/src/GTestExecutableResults.cpp Thu Aug 12 16:12:42 2010
@@ -16,13 +16,18 @@
#include "GTestExecutableResults.h"
+/*! \brief Constructor
+ * \param name The name of the test executable this result belongs to.
+ */
GTestExecutableResults::GTestExecutableResults(QString name)
: GTestSuiteResults(name)
{}
-GTestExecutableResults::~GTestExecutableResults() {
-
-}
+/*! \brief Destructor
+ *
+ */
+GTestExecutableResults::~GTestExecutableResults()
+{}
=======================================
--- /trunk/src/GTestParser.cpp Sat Aug 7 11:11:45 2010
+++ /trunk/src/GTestParser.cpp Thu Aug 12 16:12:42 2010
@@ -21,10 +21,42 @@
#include "GTestParser.h"
+/*! \brief Constructor
+ * \param inStream The data stream the represents the gtest .xml file
source.
+ */
GTestParser::GTestParser(QIODevice* inStream)
: xmlSource(inStream)
{}
+/*! \brief Parses the .xml file given to the constructor.
+ *
+ * This function takes the .xml source file and parses it. It creates a
single
+ * GTestExecutableResults object which acts as the root node of a tree of
+ * GTestResults object.
+ * \dot
+ digraph "Test Results Structure" {
+ node [shape=record, fontname=Helvetica, fontsize=10];
+ exe [label="GTestExecutableResults" URL="\ref GTestExecutableResults"];
+ suite1 [label="GTestSuiteResults" URL="\ref GTestSuiteResults"];
+ suite2 [label="GTestSuiteResults" URL="\ref GTestSuiteResults"];
+ suite3 [label="GTestSuiteResults" URL="\ref GTestSuiteResults"];
+ unit1 [label="GTestResults" URL="\ref GTestResults"];
+ unit2 [label="GTestResults" URL="\ref GTestResults"];
+ unit3 [label="GTestResults" URL="\ref GTestResults"];
+ unit4 [label="GTestResults" URL="\ref GTestResults"];
+ unit5 [label="GTestResults" URL="\ref GTestResults"];
+ exe -> suite1 [arrowhead="open", style="solid"];
+ exe -> suite2 [arrowhead="open", style="solid"];
+ exe -> suite3 [arrowhead="open", style="solid"];
+ suite1 -> unit1 [arrowhead="open", style="solid"];
+ suite2 -> unit2 [arrowhead="open", style="solid"];
+ suite3 -> unit3 [arrowhead="open", style="solid"];
+ suite3 -> unit4 [arrowhead="open", style="solid"];
+ suite3 -> unit5 [arrowhead="open", style="solid"];
+ }
+ \enddot
+ * \return The tree of unit test results.
+ */
GTestExecutableResults* GTestParser::parse() {
xmlSource->open(QIODevice::ReadOnly);
xmlSource->seek(0);
=======================================
--- /trunk/src/GTestResults.cpp Sat Aug 7 11:11:45 2010
+++ /trunk/src/GTestResults.cpp Thu Aug 12 16:12:42 2010
@@ -16,12 +16,18 @@
#include "GTestResults.h"
+/*! \brief Constructor
+ *
+ * \param name The name of the unit test to which this object belongs.
+ */
GTestResults::GTestResults(QString name)
: name(name), time(-1), failureMessages(), status(UNDEFINED)
{}
-GTestResults::~GTestResults() {
-
-}
+/*! \brief Destructor
+ *
+ */
+GTestResults::~GTestResults()
+{}
=======================================
--- /trunk/src/GTestRunner.cpp Sat Aug 7 11:11:45 2010
+++ /trunk/src/GTestRunner.cpp Thu Aug 12 16:12:42 2010
@@ -27,6 +27,12 @@
#include <QTreeWidgetItemIterator>
#include <QVBoxLayout>
+/*! \brief Constructor
+ *
+ * \param parent The parent QWidget object. This should be null, as this
is the main window.
+ * \param flags The main window flags for the application.
+ * <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),
fileMenu(tr("&File")), helpMenu(tr("&Help")), statusBar(this),
@@ -37,11 +43,17 @@
setup();
}
+/*! \brief Destructor
+ *
+ */
GTestRunner::~GTestRunner()
-{
-
-}
-
+{}
+
+/*! \brief Sets up the application GUI.
+ *
+ * This function sets up some high level objects and gets them
+ * to set up as well.
+ */
void GTestRunner::setup() {
//menus
menuBar = QMainWindow::menuBar();
@@ -59,6 +71,10 @@
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);
@@ -85,6 +101,10 @@
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);
@@ -103,6 +123,11 @@
testTreeTools.addAction(removeTestsAct);
}
+/*! \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;
@@ -116,16 +141,24 @@
centralWidget.setLayout(mainLayout);
}
+/*! \brief Slot to prompt a dialog to have the user add unit tests to run.
+ *
+ * This function prompts a file selection dialog and has the user select
+ * the gtest executable they wish to add to the testing setup. It has some
+ * basic error handling, however, it could use a bit more robustness.
+ * \todo TODO::Investigate security issues with this. Any way to detect
gtest before running?
+ */
void GTestRunner::addTests() {
- bool addResolved = false;
+ bool addResolved = false; //flag to see if we've got a good test.
QString filepath;
GTestExecutable* newTest = new GTestExecutable(this);
while(!addResolved) {
filepath = QFileDialog::getOpenFileName(this, tr("Select Google Test
Executable"));
qDebug() << "File path received:" << filepath;
- if(filepath.isEmpty())
+ if(filepath.isEmpty()) //Empty path means user clicked cancel.
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) {
@@ -175,16 +208,30 @@
}
}
- invokeListingRetrieval(filepath);
+ //We've got a good test, so let's have it send up a listing.
+ invokeListingRetrieval(newTest);
}
-void GTestRunner::invokeListingRetrieval(QString filepath) {
- GTestExecutable *gtest = new GTestExecutable(this, filepath);
+/*! \brief Sets up and requests a listing from a GTestExecutable.
+ *
+ * This creates a signal / slot mapping so that the runner is informed
+ * when the listing is ready.
+ */
+void GTestRunner::invokeListingRetrieval(GTestExecutable* gtest) {
+ //Have the executable inform us when the listing is ready.
QObject::connect(gtest, SIGNAL(listingReady(GTestExecutable*)),
this, SLOT(updateListing(GTestExecutable*)));
gtest->produceListing();
}
+/*! \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 GTestRunner::updateListing(GTestExecutable* gtest) {
qDebug() << "Updating listing";
const int exitCode = gtest->getExitCode();
@@ -259,10 +306,18 @@
&testTree, SLOT(populateTestResult(QObject*)));
}
+/*! \brief Updates all the listings for every GTestExecutable.
+ *
+ * \todo TODO::Launch this function from a 'refresh' button.
+ * \todo TODO::Fill out this method.
+ */
void GTestRunner::updateAllListings() {
}
+/*! \brief Runs all tests that are checked.
+ *
+ */
void GTestRunner::runTests() {
emit aboutToRunTests();
QTreeWidgetItemIterator it(&testTree,
QTreeWidgetItemIterator::NoChildren);
@@ -289,18 +344,23 @@
emit runningTests();
}
-//TODO::Refactor the three copies of setTestResults to one function
-//TODO::The above will require a common base class, or a templated function
-void GTestRunner::setTestResult(GTest* /*gtest*/) {
-}
-
-/*
- * This function handles correcting the check states. If a parent is
- * part checked and all its children are part checked, we transition
- * to fully checked (previous state must have been unchecked and a click
- * must have been made on the parent). If any of the children are not
- * part checked, we know that we did not in fact click on the parent
- * (and thus we can immediately return), so a part checked parent is fine.
+/*! \brief Sets the test result of the given gtest.
+ *
+ * \todo TODO::Check to see if this function is needed/used.
+ */
+void GTestRunner::setTestResult(GTest* /*gtest*/)
+{}
+
+/*! \brief Slot to handle maintaining valid checkbox states.
+ *
+ * This function handles correcting the check states. If a parent is
+ * part checked and all its children are part checked, we transition
+ * to fully checked (previous state must have been unchecked and a click
+ * must have been made on the parent). If any of the children are not
+ * part checked, we know that we did not in fact click on the parent
+ * (and thus we can immediately return), so a part checked parent is fine.
+ * \param item The item in the tree that was clicked.
+ * \param column The column of the 'item' that was clicked.
*/
void GTestRunner::treeItemClicked(QTreeWidgetItem* item, int /*column*/) {
if(item->childCount() == 0 || item->parent() == 0)
=======================================
--- /trunk/src/GTestSuite.cpp Sun Aug 8 10:59:31 2010
+++ /trunk/src/GTestSuite.cpp Thu Aug 12 16:12:42 2010
@@ -37,7 +37,7 @@
* Receives a run request from a child test. Adds the test to its runlist.
* If received by a GTestSuite, this will emit a request with its name as
* the testCase.
- * \TODO TODO::Store testName and testCase for selective execution by the
GTestExecutable
+ * \todo TODO::Store testName and testCase for selective execution by the
GTestExecutable
* \param testName The name of the GTest to run.
* \param testCase The name of the GTestSuite to run. Note that
* this is 'null' if sent from a GTest, and is the
@@ -75,7 +75,7 @@
*
* This test should be run by right-clicking and selecting run on
* a test suite object.
- * \TODO TODO::Run all tests in suite immediately.
+ * \todo TODO::Run all tests in suite immediately.
*/
void GTestSuite::run() {
}
=======================================
--- /trunk/src/GTestSuiteResults.cpp Sat Aug 7 11:11:45 2010
+++ /trunk/src/GTestSuiteResults.cpp Thu Aug 12 16:12:42 2010
@@ -16,13 +16,19 @@
#include "GTestSuiteResults.h"
+/*! \brief Constructor
+ *
+ * \param name The name of the unit test this result belongs to.
+ */
GTestSuiteResults::GTestSuiteResults(QString name)
: GTestResults(name)
{}
-GTestSuiteResults::~GTestSuiteResults() {
-
-}
+/*! \brief Destructor
+ *
+ */
+GTestSuiteResults::~GTestSuiteResults()
+{}
=======================================
--- /trunk/src/TestTreeWidget.cpp Sat Aug 7 11:11:45 2010
+++ /trunk/src/TestTreeWidget.cpp Thu Aug 12 16:12:42 2010
@@ -18,13 +18,29 @@
#include "GTestSuite.h"
#include "GTestExecutable.h"
+/*! \brief Constructor
+ *
+ * \param parent The parent QWidget.
+ */
TestTreeWidget::TestTreeWidget(QWidget* parent)
: QTreeWidget(parent)
{}
+/*! \brief Destructor
+ *
+ */
TestTreeWidget::~TestTreeWidget()
{}
+/*! \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 TestTreeWidget::populateTestResult(QObject* item) {
TestTreeWidgetItem* treeItem = static_cast<TestTreeWidgetItem*>(item);
if(treeItem == 0)
=======================================
--- /trunk/src/TestTreeWidgetItem.cpp Sat Aug 7 11:11:45 2010
+++ /trunk/src/TestTreeWidgetItem.cpp Thu Aug 12 16:12:42 2010
@@ -16,14 +16,30 @@
#include "TestTreeWidgetItem.h"
-
+/*! \brief Constructor
+ *
+ * <a href="http://doc.qt.nokia.com/4.6/qtreewidgetitem.html#type">See
QTreeWidgetItem</a>
+ * \param parent, The tree widget to which the object belongs.
+ * \param strings Initial strings to be inserted as columns of this
element.
+ * \param type A type used to identify what kind of data is attached to
this item.
+ */
TestTreeWidgetItem::TestTreeWidgetItem(QTreeWidget* parent, const
QStringList& strings, int type)
: QObject(), QTreeWidgetItem(parent, strings, type)
{}
+/*! \brief Constructor
+ *
+ * <a href="http://doc.qt.nokia.com/4.6/qtreewidgetitem.html#type">See
QTreeWidgetItem</a>
+ * \param parent, The tree widget item to which the object belongs.
+ * \param strings Initial strings to be inserted as columns of this
element.
+ * \param type A type used to identify what kind of data is attached to
this item.
+ */
TestTreeWidgetItem::TestTreeWidgetItem(QTreeWidgetItem* parent, const
QStringList& strings, int type)
: QObject(), QTreeWidgetItem(parent, strings, type)
{}
+/*! \brief Destructor
+ *
+ */
TestTreeWidgetItem::~TestTreeWidgetItem()
{}