Skip to content

Commit d1593ca

Browse files
m-kuhnnyalldawson
authored andcommittedMay 14, 2017
Create a virtual QgsNative base class for platform services
A QgsNative base class is added, that offers default implementations for a platform interface. These methods can be overridded for the current platform at compile time to allow specialized handling for integration with the current system.
1 parent f6bd7b3 commit d1593ca

15 files changed

+124
-139
lines changed
 

‎CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,6 @@ ADD_CUSTOM_TARGET(version ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h)
748748
#TEST_DATA_DIR is also used by QgsRenderChecker currently in core
749749
SET (TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/testdata")
750750

751-
SET(USE_NATIVE_LIB FALSE)
752-
IF(APPLE)
753-
SET(USE_NATIVE_LIB TRUE)
754-
ENDIF(APPLE)
755-
756751
ADD_SUBDIRECTORY(src)
757752
ADD_SUBDIRECTORY(doc)
758753
ADD_SUBDIRECTORY(images)

‎src/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
IF(USE_NATIVE_LIB)
2-
ADD_SUBDIRECTORY(native)
3-
ENDIF(USE_NATIVE_LIB)
1+
ADD_SUBDIRECTORY(native)
42

53
ADD_SUBDIRECTORY(core)
64
ADD_SUBDIRECTORY(analysis)

‎src/app/CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ INCLUDE_DIRECTORIES(
519519
openstreetmap
520520
dwg
521521
dwg/libdxfrw
522+
${CMAKE_SOURCE_DIR}/src/native
523+
${CMAKE_BINARY_DIR}/src/native
522524
)
523525
INCLUDE_DIRECTORIES(SYSTEM
524526
${SPATIALITE_INCLUDE_DIR}
@@ -535,16 +537,14 @@ IF(ENABLE_MODELTEST)
535537
INCLUDE_DIRECTORIES(../../tests/qt_modeltest)
536538
ENDIF(ENABLE_MODELTEST)
537539

538-
IF (USE_NATIVE_LIB)
539-
IF(APPLE)
540-
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/native/mac)
541-
ENDIF(APPLE)
542-
ENDIF(USE_NATIVE_LIB)
543-
544540
IF (ANDROID)
545541
INCLUDE_DIRECTORIES(SYSTEM ${ANDROID_NDK_TOOLCHAIN_ROOT}/sysroot/usr/include)
546542
ENDIF (ANDROID)
547543

544+
IF (APPLE)
545+
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/native/mac)
546+
ENDIF (APPLE)
547+
548548
IF (POSTGRES_FOUND)
549549
INCLUDE_DIRECTORIES(SYSTEM ${POSTGRES_INCLUDE_DIR})
550550
ENDIF (POSTGRES_FOUND)
@@ -572,6 +572,7 @@ TARGET_LINK_LIBRARIES(qgis_app
572572
qgis_core
573573
qgis_gui
574574
qgis_analysis
575+
qgis_native
575576
libdxfrw
576577
)
577578

@@ -592,9 +593,6 @@ IF (APPLE)
592593
TARGET_LINK_LIBRARIES(qgis_app ${APP_SERVICES_LIBRARY})
593594
ENDIF(APPLE)
594595

595-
IF(USE_NATIVE_LIB)
596-
TARGET_LINK_LIBRARIES(qgis_app qgis_native)
597-
ENDIF(USE_NATIVE_LIB)
598596

599597
if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
600598
SET_TARGET_PROPERTIES(qgis_app PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
@@ -615,9 +613,7 @@ IF(WIN32)
615613
TARGET_LINK_LIBRARIES(qgis_app DbgHelp Qt5::WinExtras)
616614
ENDIF(WIN32)
617615

618-
IF(USE_NATIVE_LIB)
619-
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} qgis_native)
620-
ENDIF(USE_NATIVE_LIB)
616+
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} qgis_native)
621617

622618
IF (APPLE)
623619
SET_TARGET_PROPERTIES(${QGIS_APP_NAME} PROPERTIES

‎src/app/qgisapp.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
100100
//
101101
#ifdef Q_OS_MACX
102102
#include <ApplicationServices/ApplicationServices.h>
103-
104-
// Virtual interfaces to Cocoa objective-c frameworks/classes/calls
105-
// cocoainitializer is to handle objective-c garbage collection
106-
// see: http://el-tramo.be/blog/mixing-cocoa-and-qt/
107-
//#include "cocoainitializer.h"
108-
#include "qgsmacappkit.h"
103+
#include "qgsmacnative.h"
109104

110105
// check macro breaks QItemDelegate
111106
#ifdef check
@@ -1205,6 +1200,12 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
12051200
}
12061201
#endif
12071202

1203+
#ifdef Q_OS_MAC
1204+
mNative = new QgsMacNative();
1205+
#else
1206+
mNative = new QgsNative();
1207+
#endif
1208+
12081209
} // QgisApp ctor
12091210

12101211
QgisApp::QgisApp()
@@ -1216,7 +1217,7 @@ QgisApp::QgisApp()
12161217
, mMapToolGroup( nullptr )
12171218
, mPreviewGroup( nullptr )
12181219
#ifdef Q_OS_MAC
1219-
, mWindowMenu( 0 )
1220+
, mWindowMenu( nullptr )
12201221
#endif
12211222
, mPanelMenu( nullptr )
12221223
, mToolbarMenu( nullptr )
@@ -6124,13 +6125,7 @@ void QgisApp::activate()
61246125

61256126
void QgisApp::bringAllToFront()
61266127
{
6127-
#ifdef Q_OS_MAC
6128-
// Bring forward all open windows while maintaining layering order
6129-
// method valid for Mac OS X >= 10.6
6130-
QgsNSRunningApplication* nsrapp = new QgsNSRunningApplication();
6131-
nsrapp->currentAppActivateIgnoringOtherApps();
6132-
delete nsrapp;
6133-
#endif
6128+
mNative->currentAppActivateIgnoringOtherApps();
61346129
}
61356130

61366131
void QgisApp::addWindow( QAction *action )

‎src/app/qgisapp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ class QgsDiagramProperties;
139139
#include "ui_qgisapp.h"
140140
#include "qgis_app.h"
141141

142+
#include "qgsnative.h"
143+
142144
#include <QGestureEvent>
143145
#include <QTapAndHoldGesture>
144146

@@ -1967,6 +1969,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
19671969

19681970
QHash< QgsComposition *, QgsMapLayerAction * > mAtlasFeatureActions;
19691971

1972+
QgsNative *mNative = nullptr;
1973+
19701974
int mProjOpen;
19711975

19721976
bool gestureEvent( QGestureEvent *event );

‎src/core/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,11 +1044,6 @@ INCLUDE_DIRECTORIES(SYSTEM
10441044
${QTKEYCHAIN_INCLUDE_DIR}
10451045
)
10461046

1047-
IF(USE_NATIVE_LIB)
1048-
IF(APPLE)
1049-
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/native/mac)
1050-
ENDIF(APPLE)
1051-
ENDIF(USE_NATIVE_LIB)
10521047

10531048
#for PAL classes
10541049
IF (WIN32)
@@ -1118,9 +1113,7 @@ IF (WIN32)
11181113
TARGET_LINK_LIBRARIES(qgis_core wsock32 ${SETUPAPI_LIBRARY} DbgHelp)
11191114
ENDIF (WIN32)
11201115

1121-
IF(USE_NATIVE_LIB)
1122-
TARGET_LINK_LIBRARIES(qgis_core qgis_native)
1123-
ENDIF(USE_NATIVE_LIB)
1116+
TARGET_LINK_LIBRARIES(qgis_core qgis_native)
11241117

11251118
IF (NOT WITH_INTERNAL_QEXTSERIALPORT)
11261119
TARGET_LINK_LIBRARIES(qgis_core ${QEXTSERIALPORT_LIBRARY})

‎src/native/CMakeLists.txt

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,54 +27,56 @@ ENDIF(APPLE)
2727
#############################################################
2828
# sources
2929

30-
SET(QGIS_CORE_SRCS)
30+
SET(QGIS_NATIVE_SRCS
31+
qgsnative.cpp
32+
)
3133

3234
IF(APPLE)
3335
SET(QGIS_APP_OBJC_SRCS
3436
mac/cocoainitializer.mm
35-
mac/qgsmacappkit.mm
37+
mac/qgsmacnative.mm
3638
)
3739

3840
SET_SOURCE_FILES_PROPERTIES(${QGIS_APP_OBJC_SRCS} PROPERTIES COMPILE_FLAGS "-x objective-c++")
3941

40-
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
42+
SET(QGIS_NATIVE_SRCS ${QGIS_NATIVE_SRCS}
4143
${QGIS_APP_OBJC_SRCS}
42-
mac/qgsmacnative.cpp
4344
)
4445
ENDIF(APPLE)
4546

46-
SET(QGIS_CORE_MOC_HDRS)
47-
48-
QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS})
47+
SET(QGIS_NATIVE_HDRS
48+
qgsnative.h
49+
)
4950

5051
# install headers
5152

5253
IF(APPLE)
53-
SET (QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
54+
SET (QGIS_NATIVE_HDRS ${QGIS_NATIVE_HDRS}
5455
mac/qgsmacnative.h
5556
mac/cocoainitializer.h
56-
mac/qgsmacappkit.h
5757
)
5858
ENDIF(APPLE)
5959

6060
INCLUDE_DIRECTORIES(
6161
${CMAKE_CURRENT_SOURCE_DIR}
62+
${CMAKE_CURRENT_BINARY_DIR}
6263
)
6364

64-
IF(APPLE)
65-
INCLUDE_DIRECTORIES(mac)
66-
ENDIF(APPLE)
67-
68-
# Test data dir for QgsRenderChecker
69-
ADD_DEFINITIONS(-DTEST_DATA_DIR="\\"${TEST_DATA_DIR}\\"")
70-
7165
#############################################################
7266
# qgis_native library
7367

74-
ADD_LIBRARY(qgis_native SHARED ${QGIS_CORE_SRCS} ${QGIS_CORE_MOC_SRCS} ${QGIS_CORE_HDRS} ${QGIS_CORE_MOC_HDRS})
68+
ADD_LIBRARY(qgis_native SHARED ${QGIS_NATIVE_SRCS} ${QGIS_NATIVE_HDRS})
69+
70+
GENERATE_EXPORT_HEADER(
71+
qgis_native
72+
BASE_NAME NATIVE
73+
EXPORT_FILE_NAME qgis_native.h
74+
)
75+
76+
SET(QGIS_NATIVE_HDRS ${QGIS_NATIVE_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_native.h)
7577

7678
IF(NOT APPLE)
77-
INSTALL(FILES ${QGIS_CORE_HDRS} ${QGIS_CORE_MOC_HDRS} DESTINATION ${QGIS_INCLUDE_DIR})
79+
INSTALL(FILES ${QGIS_NATIVE_HDRS} DESTINATION ${QGIS_INCLUDE_DIR})
7880
ELSE(NOT APPLE)
7981
SET_TARGET_PROPERTIES(qgis_native PROPERTIES
8082
CLEAN_DIRECT_OUTPUT 1
@@ -84,7 +86,7 @@ ELSE(NOT APPLE)
8486
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${COMPLETE_VERSION}
8587
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis2_native
8688
BUILD_WITH_INSTALL_RPATH TRUE
87-
PUBLIC_HEADER "${QGIS_CORE_HDRS};${QGIS_CORE_MOC_HDRS}"
89+
PUBLIC_HEADER "${QGIS_NATIVE_HDRS}"
8890
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
8991
)
9092
ENDIF(NOT APPLE)
@@ -94,7 +96,7 @@ IF(NOT ANDROID)
9496
SET_TARGET_PROPERTIES(qgis_native PROPERTIES
9597
VERSION ${COMPLETE_VERSION}
9698
SOVERSION ${COMPLETE_VERSION}
97-
)
99+
)
98100
ENDIF(NOT ANDROID)
99101

100102
TARGET_LINK_LIBRARIES(qgis_native "${NATIVE_LINK_LIBS}")
@@ -106,7 +108,8 @@ INSTALL(TARGETS qgis_native
106108
LIBRARY DESTINATION ${QGIS_LIB_DIR}
107109
ARCHIVE DESTINATION ${QGIS_LIB_DIR}
108110
FRAMEWORK DESTINATION ${QGIS_FW_SUBDIR}
109-
PUBLIC_HEADER DESTINATION ${QGIS_INCLUDE_DIR})
111+
PUBLIC_HEADER DESTINATION ${QGIS_INCLUDE_DIR}
112+
)
110113

111114
# Mac dev frameworks
112115

‎src/native/mac/qgsmacnative.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
#ifndef QGSMACNATIVE_H
1919
#define QGSMACNATIVE_H
2020

21-
class QgsMacAppKit
21+
#include "qgsnative.h"
22+
23+
class NATIVE_EXPORT QgsMacNative : public QgsNative
2224
{
2325
public:
24-
virtual ~QgsMacAppKit();
26+
virtual ~QgsMacNative();
2527

26-
// NSRunningApplication interface
27-
virtual const char* currentAppLocalizedName() = 0;
28-
virtual void currentAppActivateIgnoringOtherApps() = 0;
28+
virtual const char* currentAppLocalizedName();
29+
virtual void currentAppActivateIgnoringOtherApps() override;
2930
};
3031

3132
#endif // QGSMACNATIVE_H

‎src/native/mac/qgsmacappkit.mm renamed to ‎src/native/mac/qgsmacnative.mm

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgsmacappkit.mm - interface to Mac objective-c AppKit.framework
2+
qgsmacnative.cpp - abstracted interface to native Mac objective-c
33
-------------------
44
begin : January 2014
55
copyright : (C) 2014 by Larry Shaffer
@@ -15,35 +15,20 @@
1515
* *
1616
***************************************************************************/
1717

18-
#include "qgsmacappkit.h"
18+
#include "qgsmacnative.h"
1919

2020
#include <Cocoa/Cocoa.h>
2121

22-
class QgsNSRunningApplication::Private
22+
QgsMacNative::~QgsMacNative()
2323
{
24-
public:
25-
// NSObject *obj;
26-
};
27-
28-
QgsNSRunningApplication::QgsNSRunningApplication()
29-
{
30-
// d = new Private;
31-
// d->obj = [NSObject someFunction];
32-
}
33-
34-
QgsNSRunningApplication::~QgsNSRunningApplication()
35-
{
36-
// [d->obj release];
37-
// delete d;
38-
// d = 0;
3924
}
4025

41-
const char* QgsNSRunningApplication::currentAppLocalizedName()
26+
const char* QgsMacNative::currentAppLocalizedName()
4227
{
4328
return [[[NSRunningApplication currentApplication] localizedName] UTF8String];
4429
}
4530

46-
void QgsNSRunningApplication::currentAppActivateIgnoringOtherApps()
31+
void QgsMacNative::currentAppActivateIgnoringOtherApps()
4732
{
4833
// valid for Mac OS X >= 10.6
4934
[[NSRunningApplication currentApplication] activateWithOptions:
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/***************************************************************************
2-
qgsmacnative.cpp - abstracted interface to native Mac objective-c
2+
qgsnative.cpp - abstracted interface to native system calls
33
-------------------
4-
begin : January 2014
5-
copyright : (C) 2014 by Larry Shaffer
6-
email : larrys at dakotacarto dot com
4+
begin : January 2017
5+
copyright : (C) 2017 by Matthias Kuhn
6+
email : matthias@opengis.ch
77
***************************************************************************/
88

99
/***************************************************************************
@@ -15,8 +15,12 @@
1515
* *
1616
***************************************************************************/
1717

18-
#include "qgsmacnative.h"
18+
#include "qgsnative.h"
1919

20-
QgsMacAppKit::~QgsMacAppKit()
20+
QgsNative::QgsNative()
21+
{
22+
}
23+
24+
void QgsNative::currentAppActivateIgnoringOtherApps()
2125
{
2226
}
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/***************************************************************************
2-
qgsmacappkit.h - interface to Mac objective-c AppKit.framework
2+
qgsnative.h - abstracted interface to native system calls
33
-------------------
4-
begin : January 2014
5-
copyright : (C) 2014 by Larry Shaffer
6-
email : larrys at dakotacarto dot com
4+
begin : January 2017
5+
copyright : (C) 2017 by Matthias Kuhn
6+
email : matthias@opengis.ch
77
***************************************************************************/
88

99
/***************************************************************************
@@ -15,23 +15,26 @@
1515
* *
1616
***************************************************************************/
1717

18-
#ifndef QGSMACAPPKIT_H
19-
#define QGSMACAPPKIT_H
18+
#ifndef QGSNATIVE_H
19+
#define QGSNATIVE_H
2020

21-
#include "qgsmacnative.h"
21+
#include "qgis_native.h"
2222

23-
class QgsNSRunningApplication : public QgsMacAppKit
23+
/**
24+
* Base class for implementing methods for native system calls that
25+
* are implemented in subclasses to provide platform abstraction.
26+
*/
27+
class NATIVE_EXPORT QgsNative
2428
{
2529
public:
26-
QgsNSRunningApplication();
27-
~QgsNSRunningApplication();
30+
QgsNative();
2831

29-
const char* currentAppLocalizedName();
30-
void currentAppActivateIgnoringOtherApps();
31-
32-
private:
33-
class Private;
34-
Private* d;
32+
/**
33+
* Bring QGIS to front. Default implementation does nothing.
34+
*
35+
* @note Added in QGIS 3.0
36+
*/
37+
virtual void currentAppActivateIgnoringOtherApps();
3538
};
3639

37-
#endif // QGSMACAPPKIT_H
40+
#endif // QGSNATIVE_H

‎tests/src/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ IF (ENABLE_TESTS)
3636
IF (WITH_DESKTOP)
3737
ADD_SUBDIRECTORY(app)
3838
ENDIF (WITH_DESKTOP)
39-
IF(USE_NATIVE_LIB)
40-
ADD_SUBDIRECTORY(native)
41-
ENDIF(USE_NATIVE_LIB)
39+
ADD_SUBDIRECTORY(native)
4240
IF (WITH_BINDINGS)
4341
ADD_SUBDIRECTORY(python)
4442
ENDIF (WITH_BINDINGS)

‎tests/src/app/CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
2222
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/app
2323
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/app/pluginmanager
2424
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/test
25+
${CMAKE_SOURCE_DIR}/src/native
26+
${CMAKE_BINARY_DIR}/src/native
2527
${CMAKE_BINARY_DIR}/src/core
2628
${CMAKE_BINARY_DIR}/src/gui
2729
${CMAKE_BINARY_DIR}/src/python
@@ -37,11 +39,6 @@ INCLUDE_DIRECTORIES(SYSTEM
3739
${QSCINTILLA_INCLUDE_DIR}
3840
)
3941

40-
IF(USE_NATIVE_LIB)
41-
IF(APPLE)
42-
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/native/mac)
43-
ENDIF(APPLE)
44-
ENDIF(USE_NATIVE_LIB)
4542

4643
#note for tests we should not include the moc of our
4744
#qtests in the executable file list as the moc is
@@ -82,9 +79,7 @@ MACRO (ADD_QGIS_TEST testname testsrc)
8279
TARGET_LINK_LIBRARIES(qgis_${testname} ${APP_SERVICES_LIBRARY} )
8380
ENDIF(APPLE)
8481
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname} -maxwarnings 10000)
85-
IF(USE_NATIVE_LIB)
86-
TARGET_LINK_LIBRARIES(qgis_${testname} qgis_native)
87-
ENDIF(USE_NATIVE_LIB)
82+
TARGET_LINK_LIBRARIES(qgis_${testname} qgis_native)
8883
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname})
8984
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
9085
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}

‎tests/src/native/CMakeLists.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
# the UI file won't be wrapped!
66
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
77
${CMAKE_CURRENT_BINARY_DIR}
8+
${CMAKE_SOURCE_DIR}/src/test
9+
${CMAKE_SOURCE_DIR}/src/core
10+
${CMAKE_SOURCE_DIR}/src/core/geometry
11+
${CMAKE_SOURCE_DIR}/src/native
12+
${CMAKE_BINARY_DIR}/src/native
13+
${CMAKE_BINARY_DIR}/src/core
14+
)
15+
16+
17+
INCLUDE_DIRECTORIES(SYSTEM
818
${QT_INCLUDE_DIR}
9-
)
19+
)
1020

1121
IF(APPLE)
1222
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/native/mac)
@@ -50,19 +60,25 @@ ENDIF (APPLE)
5060
MACRO (ADD_QGIS_TEST testname testsrc)
5161
SET(qgis_${testname}_SRCS ${testsrc} ${util_SRCS})
5262
SET(qgis_${testname}_MOC_CPPS ${testsrc})
53-
QT4_WRAP_CPP(qgis_${testname}_MOC_SRCS ${qgis_${testname}_MOC_CPPS})
54-
ADD_CUSTOM_TARGET(qgis_${testname}moc ALL DEPENDS ${qgis_${testname}_MOC_SRCS})
55-
ADD_EXECUTABLE(qgis_${testname} ${qgis_${testname}_SRCS})
56-
ADD_DEPENDENCIES(qgis_${testname} qgis_${testname}moc)
63+
ADD_EXECUTABLE(qgis_${testname} ${qgis_${testname}_SRCS} ${IMAGE_RCC_SRCS})
64+
SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES AUTOMOC TRUE)
5765
TARGET_LINK_LIBRARIES(qgis_${testname}
5866
${QT_QTCORE_LIBRARY}
5967
${QT_QTTEST_LIBRARY}
6068
qgis_app
61-
qgis_native)
62-
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname})
69+
qgis_native
70+
)
71+
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname} -maxwarnings 10000)
72+
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
73+
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
74+
# INSTALL_RPATH_USE_LINK_PATH true )
6375
ENDMACRO (ADD_QGIS_TEST)
6476

77+
78+
6579
#############################################################
6680
# Tests:
6781

68-
ADD_QGIS_TEST(macnativetest testqgsmacnative.cpp)
82+
IF (APPLE)
83+
ADD_QGIS_TEST(macnativetest testqgsmacnative.cpp)
84+
ENDIF (APPLE)

‎tests/src/native/testqgsmacnative.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
* (at your option) any later version. *
1313
* *
1414
***************************************************************************/
15-
#include <QtTest>
15+
16+
#include "qgstest.h"
1617
#include <QObject>
1718
#include <QString>
1819

1920
//header for class being tested
20-
#include <qgsmacappkit.h>
21+
#include "qgsmacnative.h"
2122

2223
class TestQgsMacNative: public QObject
2324
{
@@ -29,12 +30,10 @@ class TestQgsMacNative: public QObject
2930

3031
void TestQgsMacNative::testGetRunningAppName()
3132
{
32-
QgsNSRunningApplication* nsrapp = new QgsNSRunningApplication();
33-
QString nsrapp_name( nsrapp->currentAppLocalizedName() );
34-
delete nsrapp;
35-
36-
QCOMPARE( QString( "qgis_macnativetest" ), nsrapp_name.trimmed() );
33+
QgsMacNative* macNative = new QgsMacNative();
34+
QCOMPARE( QStringLiteral( "qgis_macnativetest" ), QString( macNative->currentAppLocalizedName() ) );
35+
delete macNative;
3736
}
3837

39-
QTEST_MAIN( TestQgsMacNative )
40-
#include "moc_testqgsmacnative.cxx"
38+
QGSTEST_MAIN( TestQgsMacNative )
39+
#include "testqgsmacnative.moc"

0 commit comments

Comments
 (0)
Please sign in to comment.