summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/testlib/qtestbasicstreamer.cpp165
-rw-r--r--src/testlib/qtestbasicstreamer.h87
-rw-r--r--src/testlib/qtestxunitstreamer.cpp32
-rw-r--r--src/testlib/qtestxunitstreamer.h12
-rw-r--r--src/testlib/qxunittestlogger_p.h4
-rw-r--r--src/testlib/testlib.pro2
-rw-r--r--src/tools/uic/qclass_lib_map.h1
7 files changed, 37 insertions, 266 deletions
diff --git a/src/testlib/qtestbasicstreamer.cpp b/src/testlib/qtestbasicstreamer.cpp
deleted file mode 100644
index 1d272ea2c5..0000000000
--- a/src/testlib/qtestbasicstreamer.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtTest module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qtestbasicstreamer.h"
-#include "qxunittestlogger_p.h"
-#include "qtestelement.h"
-#include "qtestelementattribute.h"
-#include "qtestassert.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef Q_OS_WIN
-#include <unistd.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QTestBasicStreamer::QTestBasicStreamer(QXunitTestLogger *logger)
- :testLogger(logger)
-{
- QTEST_ASSERT(testLogger);
-}
-
-QTestBasicStreamer::~QTestBasicStreamer()
-{}
-
-void QTestBasicStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted )
- return;
- formatted->data()[0] = '\0';
-}
-
-void QTestBasicStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted )
- return;
- formatted->data()[0] = '\0';
-}
-
-void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted )
- return;
- formatted->data()[0] = '\0';
-}
-
-void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted )
- return;
- formatted->data()[0] = '\0';
-}
-
-void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
-{
- if(!attribute || !formatted )
- return;
- formatted->data()[0] = '\0';
-}
-
-void QTestBasicStreamer::output(QTestElement *element) const
-{
- if(!element)
- return;
-
- outputElements(element);
-}
-
-void QTestBasicStreamer::outputElements(QTestElement *element, bool) const
-{
- QTestCharBuffer buf;
- bool hasChildren;
- /*
- Elements are in reverse order of occurrence, so start from the end and work
- our way backwards.
- */
- while (element && element->nextElement()) {
- element = element->nextElement();
- }
- while (element) {
- hasChildren = element->childElements();
-
- formatStart(element, &buf);
- outputString(buf.data());
-
- formatBeforeAttributes(element, &buf);
- outputString(buf.data());
-
- outputElementAttributes(element, element->attributes());
-
- formatAfterAttributes(element, &buf);
- outputString(buf.data());
-
- if(hasChildren)
- outputElements(element->childElements(), true);
-
- formatEnd(element, &buf);
- outputString(buf.data());
-
- element = element->previousElement();
- }
-}
-
-void QTestBasicStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const
-{
- QTestCharBuffer buf;
- while(attribute){
- formatAttributes(element, attribute, &buf);
- outputString(buf.data());
- attribute = attribute->nextElement();
- }
-}
-
-void QTestBasicStreamer::outputString(const char *msg) const
-{
- testLogger->outputString(msg);
-}
-
-QXunitTestLogger *QTestBasicStreamer::logger() const
-{
- return testLogger;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/testlib/qtestbasicstreamer.h b/src/testlib/qtestbasicstreamer.h
deleted file mode 100644
index d53db06225..0000000000
--- a/src/testlib/qtestbasicstreamer.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtTest module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTESTBASICSTREAMER_H
-#define QTESTBASICSTREAMER_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Test)
-
-class QTestElement;
-class QTestElementAttribute;
-class QXunitTestLogger;
-struct QTestCharBuffer;
-
-class QTestBasicStreamer
-{
- public:
- QTestBasicStreamer(QXunitTestLogger *logger);
- virtual ~QTestBasicStreamer();
-
- virtual void output(QTestElement *element) const;
-
- void outputString(const char *msg) const;
-
- QXunitTestLogger *logger() const;
-
- protected:
- virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
- virtual void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
- virtual void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
- virtual void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
- virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
- virtual void outputElements(QTestElement *element, bool isChildElement = false) const;
- virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
-
- private:
- QXunitTestLogger *testLogger;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp
index 93b40de1cf..f70945add0 100644
--- a/src/testlib/qtestxunitstreamer.cpp
+++ b/src/testlib/qtestxunitstreamer.cpp
@@ -40,7 +40,10 @@
****************************************************************************/
#include "qtestxunitstreamer.h"
+#include "qxunittestlogger_p.h"
#include "qtestelement.h"
+#include "qtestelementattribute.h"
+#include "qtestassert.h"
#include "QtTest/private/qtestlog_p.h"
#include "QtTest/private/qtestresult_p.h"
@@ -49,8 +52,10 @@
QT_BEGIN_NAMESPACE
QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger)
- : QTestBasicStreamer(logger)
-{}
+ : testLogger(logger)
+{
+ QTEST_ASSERT(testLogger);
+}
QTestXunitStreamer::~QTestXunitStreamer()
{}
@@ -165,8 +170,10 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTes
void QTestXunitStreamer::output(QTestElement *element) const
{
+ QTEST_ASSERT(element);
+
outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
- QTestBasicStreamer::output(element);
+ outputElements(element);
}
void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
@@ -187,9 +194,6 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
formatStart(element, &buf);
outputString(buf.data());
- formatBeforeAttributes(element, &buf);
- outputString(buf.data());
-
outputElementAttributes(element, element->attributes());
formatAfterAttributes(element, &buf);
@@ -205,5 +209,19 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
}
}
-QT_END_NAMESPACE
+void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const
+{
+ QTestCharBuffer buf;
+ while(attribute){
+ formatAttributes(element, attribute, &buf);
+ outputString(buf.data());
+ attribute = attribute->nextElement();
+ }
+}
+void QTestXunitStreamer::outputString(const char *msg) const
+{
+ testLogger->outputString(msg);
+}
+
+QT_END_NAMESPACE
diff --git a/src/testlib/qtestxunitstreamer.h b/src/testlib/qtestxunitstreamer.h
index 4f2fc7f2da..127c9b1780 100644
--- a/src/testlib/qtestxunitstreamer.h
+++ b/src/testlib/qtestxunitstreamer.h
@@ -42,7 +42,7 @@
#ifndef QTESTXUNITSTREAMER_H
#define QTESTXUNITSTREAMER_H
-#include <QtTest/qtestbasicstreamer.h>
+#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
@@ -50,9 +50,12 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Test)
+class QTestElement;
+class QTestElementAttribute;
class QXunitTestLogger;
+struct QTestCharBuffer;
-class QTestXunitStreamer: public QTestBasicStreamer
+class QTestXunitStreamer
{
public:
QTestXunitStreamer(QXunitTestLogger *logger);
@@ -64,10 +67,15 @@ class QTestXunitStreamer: public QTestBasicStreamer
void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
void output(QTestElement *element) const;
void outputElements(QTestElement *element, bool isChildElement = false) const;
+ void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
+
+ void outputString(const char *msg) const;
private:
void displayXunitXmlHeader() const;
static void indentForElement(const QTestElement* element, char* buf, int size);
+
+ QXunitTestLogger *testLogger;
};
QT_END_NAMESPACE
diff --git a/src/testlib/qxunittestlogger_p.h b/src/testlib/qxunittestlogger_p.h
index 5c295dfaa1..0607504310 100644
--- a/src/testlib/qxunittestlogger_p.h
+++ b/src/testlib/qxunittestlogger_p.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
-class QTestBasicStreamer;
+class QTestXunitStreamer;
class QTestElement;
class QXunitTestLogger : public QAbstractTestLogger
@@ -84,7 +84,7 @@ class QXunitTestLogger : public QAbstractTestLogger
QTestElement *listOfTestcases;
QTestElement *currentLogElement;
QTestElement *errorLogElement;
- QTestBasicStreamer *logFormatter;
+ QTestXunitStreamer *logFormatter;
int testCounter;
int failureCounter;
diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro
index 6ca67e3967..d4dec9660e 100644
--- a/src/testlib/testlib.pro
+++ b/src/testlib/testlib.pro
@@ -18,7 +18,6 @@ HEADERS = qbenchmark.h \
qsignalspy.h \
qtestaccessible.h \
qtestassert.h \
- qtestbasicstreamer.h \
qtestcase.h \
qtestcoreelement.h \
qtestcorelist.h \
@@ -53,7 +52,6 @@ SOURCES = qtestcase.cpp \
qbenchmarkmetric.cpp \
qtestelement.cpp \
qtestelementattribute.cpp \
- qtestbasicstreamer.cpp \
qtestxunitstreamer.cpp \
qxunittestlogger.cpp
DEFINES *= QT_NO_CAST_TO_ASCII \
diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h
index a4b71defd0..cf5a53deff 100644
--- a/src/tools/uic/qclass_lib_map.h
+++ b/src/tools/uic/qclass_lib_map.h
@@ -514,7 +514,6 @@ QT_CLASS_LIB(QTest, QtTest, qtest.h)
QT_CLASS_LIB(QtTestGui, QtTest, qtest_gui.h)
QT_CLASS_LIB(QTestAccessibilityEvent, QtTest, qtestaccessible.h)
QT_CLASS_LIB(QTestAccessibility, QtTest, qtestaccessible.h)
-QT_CLASS_LIB(QTestBasicStreamer, QtTest, qtestbasicstreamer.h)
QT_CLASS_LIB(QTestCoreElement, QtTest, qtestcoreelement.h)
QT_CLASS_LIB(QTestCoreList, QtTest, qtestcorelist.h)
QT_CLASS_LIB(QTestData, QtTest, qtestdata.h)