Autogen: Tests: Add test for MacOS frameworks

This commit is contained in:
Sebastian Holtermann 2017-12-06 14:06:24 +01:00 committed by Brad King
parent fcbd02fd6e
commit e4ccc68429
8 changed files with 162 additions and 0 deletions

View File

@ -214,6 +214,12 @@ add_subdirectory(uicInclude)
# OBJECT libraries
add_subdirectory(objectLibrary)
# -- Test
# MacOS Framework
if(APPLE AND (NOT QT_TEST_VERSION STREQUAL 4))
add_subdirectory(macosFW)
endif()
# -- Test
# Source files with the same basename in different subdirectories
add_subdirectory(sameName)

View File

@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.8)
project(macos-fw-test)
find_package(Qt5Test REQUIRED)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
if(POLICY CMP0042) # in CMake 3.0.0+
set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default
endif(POLICY CMP0042)
if(POLICY CMP0068) # in CMake 3.9+
cmake_policy(SET CMP0068 NEW)
endif(POLICY CMP0068)
add_subdirectory(src)
add_subdirectory(test)

View File

@ -0,0 +1,33 @@
set(MACOS_FW_LIB_VERSION "0.1")
set(MACOS_FW_LIB_SRCS
macos_fw_lib.cpp
)
set(MACOS_FW_LIB_HDRS
macos_fw_lib.h
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${Qt5Core_INCLUDE_DIRS}
)
add_library(macos_fw_lib SHARED
${MACOS_FW_LIB_SRCS}
${MACOS_FW_LIB_HDRS}
)
set_target_properties(macos_fw_lib PROPERTIES AUTOMOC TRUE)
set_target_properties(macos_fw_lib PROPERTIES
CLEAN_DIRECT_OUTPUT 1
FRAMEWORK 1
FRAMEWORK_VERSION ${MACOS_FW_LIB_VERSION}
VERSION ${MACOS_FW_LIB_VERSION}
SOVERSION ${MACOS_FW_LIB_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MACOS_FW_LIB_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER org.macos.fw_lib
POSITION_INDEPENDENT_CODE ON
PUBLIC_HEADER "${MACOS_FW_LIB_HDRS}"
)
target_link_libraries(macos_fw_lib
Qt5::Core
)

View File

@ -0,0 +1,17 @@
#include "macos_fw_lib.h"
#include <QString>
#include <QtGlobal>
MacosFWLib::MacosFWLib()
{
}
MacosFWLib::~MacosFWLib()
{
}
QString MacosFWLib::qtVersionString() const
{
return QString(qVersion());
}

View File

@ -0,0 +1,18 @@
#ifndef MACOSFWLIB_H
#define MACOSFWLIB_H
#include <QObject>
#include <QString>
class __attribute__((visibility("default"))) MacosFWLib : public QObject
{
Q_OBJECT
public:
explicit MacosFWLib();
~MacosFWLib();
QString qtVersionString() const;
};
#endif // MACOSFWLIB_H

View File

@ -0,0 +1,19 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../src
)
include_directories(SYSTEM
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
set(testname AutomocMacosFWLib)
add_executable(${testname} testMacosFWLib.cpp)
set_target_properties(${testname} PROPERTIES AUTOMOC TRUE)
target_link_libraries(${testname}
Qt5::Core
Qt5::Widgets
Qt5::Test
macos_fw_lib
)

View File

@ -0,0 +1,42 @@
#include <QObject>
#include <QString>
#include "macos_fw_lib.h"
#include "testMacosFWLib.h"
class TestMacosFWLib : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void init() {}
void cleanup() {}
void testQtVersion();
};
void TestMacosFWLib::initTestCase()
{
}
void TestMacosFWLib::cleanupTestCase()
{
}
void TestMacosFWLib::testQtVersion()
{
MacosFWLib* testLib = new MacosFWLib();
QVERIFY(testLib->qtVersionString().contains("5."));
testLib->deleteLater();
}
int main(int argc, char* argv[])
{
QApplication app(argc, argv, false);
MacosFWLib testObject;
return QTest::qExec(&testObject, argc, argv);
}
#include "testMacosFWLib.moc"

View File

@ -0,0 +1,7 @@
#ifndef TESTMACOSFWLIB_H
#define TESTMACOSFWLIB_H
#include "qapplication.h"
#include <QtTest/QtTest>
#endif // TESTMACOSFWLIB_H