AutoTest: Add test for derived Qt tests

Change-Id: I8c61c08ff9b0653c02d262fb9010940e41e178af
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2017-01-05 11:48:55 +01:00
parent b1f1ccb32e
commit f375f197d1
9 changed files with 157 additions and 4 deletions

View File

@@ -121,13 +121,13 @@ void AutoTestUnitTests::testCodeParser_data()
<< 1 << 0 << 0 << 0; << 1 << 0 << 0 << 0;
QTest::newRow("mixedAutoTestAndQuickTests") QTest::newRow("mixedAutoTestAndQuickTests")
<< QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.pro")) << QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.pro"))
<< 3 << 5 << 3 << 8; << 4 << 5 << 3 << 10;
QTest::newRow("plainAutoTestQbs") QTest::newRow("plainAutoTestQbs")
<< QString(m_tmpDir->path() + QLatin1String("/plain/plain.qbs")) << QString(m_tmpDir->path() + QLatin1String("/plain/plain.qbs"))
<< 1 << 0 << 0 << 0; << 1 << 0 << 0 << 0;
QTest::newRow("mixedAutoTestAndQuickTestsQbs") QTest::newRow("mixedAutoTestAndQuickTestsQbs")
<< QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.qbs")) << QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.qbs"))
<< 3 << 5 << 3 << 8; << 4 << 5 << 3 << 10;
} }
void AutoTestUnitTests::testCodeParserSwitchStartup() void AutoTestUnitTests::testCodeParserSwitchStartup()
@@ -173,10 +173,10 @@ void AutoTestUnitTests::testCodeParserSwitchStartup_data()
<< QString(m_tmpDir->path() + QLatin1String("/plain/plain.qbs")) << QString(m_tmpDir->path() + QLatin1String("/plain/plain.qbs"))
<< QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.qbs")); << QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.qbs"));
QList<int> expectedAutoTests = QList<int>() << 1 << 3 << 1 << 3; QList<int> expectedAutoTests = QList<int>() << 1 << 4 << 1 << 4;
QList<int> expectedNamedQuickTests = QList<int>() << 0 << 5 << 0 << 5; QList<int> expectedNamedQuickTests = QList<int>() << 0 << 5 << 0 << 5;
QList<int> expectedUnnamedQuickTests = QList<int>() << 0 << 3 << 0 << 3; QList<int> expectedUnnamedQuickTests = QList<int>() << 0 << 3 << 0 << 3;
QList<int> expectedDataTagsCount = QList<int>() << 0 << 8 << 0 << 8; QList<int> expectedDataTagsCount = QList<int>() << 0 << 10 << 0 << 10;
QTest::newRow("loadMultipleProjects") QTest::newRow("loadMultipleProjects")
<< projects << expectedAutoTests << expectedNamedQuickTests << projects << expectedAutoTests << expectedNamedQuickTests

View File

@@ -39,6 +39,11 @@
<file>unit_test/mixed_atp/tests/auto/gui/gui.qbs</file> <file>unit_test/mixed_atp/tests/auto/gui/gui.qbs</file>
<file>unit_test/mixed_atp/tests/auto/quickauto/quickauto.qbs</file> <file>unit_test/mixed_atp/tests/auto/quickauto/quickauto.qbs</file>
<file>unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.qbs</file> <file>unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.qbs</file>
<file>unit_test/mixed_atp/tests/auto/derived/derived.pro</file>
<file>unit_test/mixed_atp/tests/auto/derived/derived.qbs</file>
<file>unit_test/mixed_atp/tests/auto/derived/origin.h</file>
<file>unit_test/mixed_atp/tests/auto/derived/origin.cpp</file>
<file>unit_test/mixed_atp/tests/auto/derived/tst_derivedtest.cpp</file>
<file>unit_test/simple_gt/src/main.cpp</file> <file>unit_test/simple_gt/src/main.cpp</file>
<file>unit_test/simple_gt/src/src.pro</file> <file>unit_test/simple_gt/src/src.pro</file>
<file>unit_test/simple_gt/src/src.qbs</file> <file>unit_test/simple_gt/src/src.qbs</file>

View File

@@ -2,6 +2,7 @@ TEMPLATE = subdirs
SUBDIRS = \ SUBDIRS = \
bench \ bench \
derived \
dummy \ dummy \
gui gui

View File

@@ -5,6 +5,7 @@ Project {
references: [ references: [
"bench/bench.qbs", "bench/bench.qbs",
"derived/derived.qbs",
"dummy/dummy.qbs", "dummy/dummy.qbs",
"gui/gui.qbs", "gui/gui.qbs",
"quickauto/quickauto.qbs", "quickauto/quickauto.qbs",

View File

@@ -0,0 +1,34 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-01-03T08:16:50
#
#-------------------------------------------------
QT += testlib
QT -= gui
TARGET = tst_derivedtest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += tst_derivedtest.cpp \
origin.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
HEADERS += \
origin.h

View File

@@ -0,0 +1,14 @@
import qbs
CppApplication {
type: "application"
name: "Derived Auto Test"
targetName: "tst_derivedtest"
Depends { name: "cpp" }
Depends { name: "Qt.testlib" }
files: [ "origin.cpp", "origin.h", "tst_derivedtest.cpp" ]
cpp.defines: base.concat("SRCDIR=" + path)
}

View File

@@ -0,0 +1,43 @@
#include "origin.h"
#include <QtTest>
Origin::Origin()
{
}
void Origin::testSchmu()
{
QCOMPARE(1, 1);
}
void Origin::testStr()
{
QFETCH(bool, localAware);
QString str1 = QLatin1String("Hello World");
QString str2 = QLatin1String("Hallo Welt");
if (!localAware) {
QBENCHMARK {
str1 == str2;
}
} else {
QBENCHMARK {
str1.localeAwareCompare(str2) == 0;
}
}
}
void Origin::testStr_data()
{
QTest::addColumn<bool>("localAware");
QTest::newRow("simple") << false;
QTest::newRow("localAware") << true;
}
void Origin::testBase1_data()
{
QTest::addColumn<bool>("bogus");
QTest::newRow("foo") << false; // we don't expect 'foo' and 'bar' to be displayed
QTest::newRow("bar") << true;
}

View File

@@ -0,0 +1,18 @@
#ifndef ORIGIN_H
#define ORIGIN_H
#include <QObject>
class Origin : public QObject
{
Q_OBJECT
public:
Origin();
private slots:
void testSchmu();
void testStr();
void testStr_data();
void testBase1_data(); // makes no sense - but should be handled correctly
};
#endif // ORIGIN_H

View File

@@ -0,0 +1,37 @@
#include "origin.h"
#include <QtTest>
class BaseTest : public Origin
{
Q_OBJECT
private slots:
void testBase1();
};
void BaseTest::testBase1()
{
QVERIFY(true);
}
class DerivedTest : public BaseTest
{
Q_OBJECT
private Q_SLOTS:
void testCase1();
void testBase1();
};
void DerivedTest::testCase1()
{
QVERIFY2(true, "Failure");
}
void DerivedTest::testBase1()
{
QVERIFY(true);
}
QTEST_APPLESS_MAIN(DerivedTest)
#include "tst_derivedtest.moc"