Autogen: Tests: Add moc include tests

This commit is contained in:
Sebastian Holtermann 2017-02-16 15:59:56 +01:00 committed by Brad King
parent 50805693ba
commit 39c4819eaa
19 changed files with 354 additions and 0 deletions

View File

@ -206,6 +206,14 @@ target_link_libraries(skipRccB ${QT_LIBRARIES})
# Source files with the same basename in different subdirectories
add_subdirectory(sameName)
# -- Test
# Tests various include moc patterns
add_subdirectory(mocIncludeStrict)
# -- Test
# Tests various include moc patterns
add_subdirectory(mocIncludeRelaxed)
# -- Test
# Complex test case
add_subdirectory(complex)

View File

@ -0,0 +1,24 @@
#include "ObjA.hpp"
class SubObjA : public QObject
{
Q_OBJECT
public:
SubObjA() {}
~SubObjA() {}
Q_SLOT
void aSlot();
};
void SubObjA::aSlot()
{
}
void ObjA::go()
{
SubObjA subObj;
}
#include "ObjA.moc"

View File

@ -0,0 +1,13 @@
#ifndef OBJA_HPP
#define OBJA_HPP
#include <QObject>
class ObjA : public QObject
{
Q_OBJECT
Q_SLOT
void go();
};
#endif

View File

@ -0,0 +1,25 @@
#include "ObjB.hpp"
class SubObjB : public QObject
{
Q_OBJECT
public:
SubObjB() {}
~SubObjB() {}
Q_SLOT
void aSlot();
};
void SubObjB::aSlot()
{
}
void ObjB::go()
{
SubObjB subObj;
}
#include "ObjB.moc"
#include "moc_ObjB.cpp"

View File

@ -0,0 +1,13 @@
#ifndef OBJB_HPP
#define OBJB_HPP
#include <QObject>
class ObjB : public QObject
{
Q_OBJECT
Q_SLOT
void go();
};
#endif

View File

@ -0,0 +1,26 @@
#include "ObjC.hpp"
class SubObjC : public QObject
{
Q_OBJECT
public:
SubObjC() {}
~SubObjC() {}
Q_SLOT
void aSlot();
};
void SubObjC::aSlot()
{
}
void ObjC::go()
{
SubObjC subObj;
}
#include "ObjC.moc"
// Not the own header
#include "moc_ObjD.cpp"

View File

@ -0,0 +1,13 @@
#ifndef OBJC_HPP
#define OBJC_HPP
#include <QObject>
class ObjC : public QObject
{
Q_OBJECT
Q_SLOT
void go();
};
#endif

View File

@ -0,0 +1,26 @@
#include "ObjD.hpp"
class SubObjD : public QObject
{
Q_OBJECT
public:
SubObjD() {}
~SubObjD() {}
Q_SLOT
void aSlot();
};
void SubObjD::aSlot()
{
}
void ObjD::go()
{
SubObjD subObj;
}
#include "ObjD.moc"
// Header in subdirectory
#include "subA/moc_SubObjA.cpp"

View File

@ -0,0 +1,13 @@
#ifndef OBJD_HPP
#define OBJD_HPP
#include <QObject>
class ObjD : public QObject
{
Q_OBJECT
Q_SLOT
void go();
};
#endif

View File

@ -0,0 +1,27 @@
#include "SubObjA.hpp"
namespace subA {
class SubObjA : public QObject
{
Q_OBJECT
public:
SubObjA() {}
~SubObjA() {}
Q_SLOT
void aSlot();
};
void SubObjA::aSlot()
{
}
void ObjA::go()
{
SubObjA subObj;
}
}
#include "SubObjA.moc"

View File

@ -0,0 +1,16 @@
#ifndef SUBOBJA_HPP
#define SUBOBJA_HPP
#include <QObject>
namespace subA {
class ObjA : public QObject
{
Q_OBJECT
Q_SLOT
void go();
};
}
#endif

View File

@ -0,0 +1,27 @@
#include "SubObjB.hpp"
namespace subB {
class SubObjB : public QObject
{
Q_OBJECT
public:
SubObjB() {}
~SubObjB() {}
Q_SLOT
void aSlot();
};
void SubObjB::aSlot()
{
}
void ObjB::go()
{
SubObjB subObj;
}
}
#include "SubObjB.moc"

View File

@ -0,0 +1,16 @@
#ifndef SUBOBJB_HPP
#define SUBOBJB_HPP
#include <QObject>
namespace subB {
class ObjB : public QObject
{
Q_OBJECT
Q_SLOT
void go();
};
}
#endif

View File

@ -0,0 +1,27 @@
#include "SubObjC.hpp"
namespace subC {
class SubObjC : public QObject
{
Q_OBJECT
public:
SubObjC() {}
~SubObjC() {}
Q_SLOT
void aSlot();
};
void SubObjC::aSlot()
{
}
void ObjC::go()
{
SubObjC subObj;
}
}
#include "SubObjC.moc"

View File

@ -0,0 +1,16 @@
#ifndef SUBOBJC_HPP
#define SUBOBJC_HPP
#include <QObject>
namespace subC {
class ObjC : public QObject
{
Q_OBJECT
Q_SLOT
void go();
};
}
#endif

View File

@ -0,0 +1,18 @@
# Test moc include patterns
set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
include_directories("../mocInclude")
add_executable(mocIncludeRelaxed
../mocInclude/ObjA.cpp
../mocInclude/ObjB.cpp
../mocInclude/ObjC.cpp
../mocInclude/ObjD.cpp
../mocInclude/subA/SubObjA.cpp
../mocInclude/subB/SubObjB.cpp
../mocInclude/subC/SubObjC.cpp
main.cpp
)
target_link_libraries(mocIncludeRelaxed ${QT_LIBRARIES})
set_target_properties(mocIncludeRelaxed PROPERTIES AUTOMOC ON)

View File

@ -0,0 +1,14 @@
#include "ObjA.hpp"
#include "ObjB.hpp"
#include "ObjC.hpp"
int main(int argv, char** args)
{
ObjA objA;
ObjB objB;
ObjC objC;
return 0;
}
// Header in global subdirectory
#include "subB/moc_SubObjB.cpp"

View File

@ -0,0 +1,18 @@
# Test moc include patterns
set(CMAKE_AUTOMOC_RELAXED_MODE FALSE)
include_directories("../mocInclude")
add_executable(mocIncludeStrict
../mocInclude/ObjA.cpp
../mocInclude/ObjB.cpp
../mocInclude/ObjC.cpp
../mocInclude/ObjD.cpp
../mocInclude/subA/SubObjA.cpp
../mocInclude/subB/SubObjB.cpp
../mocInclude/subC/SubObjC.cpp
main.cpp
)
target_link_libraries(mocIncludeStrict ${QT_LIBRARIES})
set_target_properties(mocIncludeStrict PROPERTIES AUTOMOC ON)

View File

@ -0,0 +1,14 @@
#include "ObjA.hpp"
#include "ObjB.hpp"
#include "ObjC.hpp"
int main(int argv, char** args)
{
ObjA objA;
ObjB objB;
ObjC objC;
return 0;
}
// Header in global subdirectory
#include "subB/moc_SubObjB.cpp"