summaryrefslogtreecommitdiff
path: root/Tests/QtAutogen
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-12-09 13:50:12 +0100
committerSebastian Holtermann <sebholt@xwmw.org>2017-12-13 13:50:19 +0100
commit540d08f4858ddbb8d0356f77f878b9fbb7af8f80 (patch)
tree3cb07d93312fd31e754675c4c11260606be79a00 /Tests/QtAutogen
parentb1504f9f97849777f4690565f8b5879372e7dd51 (diff)
downloadcmake-540d08f4858ddbb8d0356f77f878b9fbb7af8f80.tar.gz
Autogen: Tests: Move QtAutoUicInterface test to QtAutogen/UicInterface
Diffstat (limited to 'Tests/QtAutogen')
-rw-r--r--Tests/QtAutogen/CommonTests.cmake1
-rw-r--r--Tests/QtAutogen/UicInterface/CMakeLists.txt58
-rw-r--r--Tests/QtAutogen/UicInterface/klocalizedstring.cpp12
-rw-r--r--Tests/QtAutogen/UicInterface/klocalizedstring.h17
-rw-r--r--Tests/QtAutogen/UicInterface/libwidget.cpp14
-rw-r--r--Tests/QtAutogen/UicInterface/libwidget.h25
-rw-r--r--Tests/QtAutogen/UicInterface/libwidget.ui32
-rw-r--r--Tests/QtAutogen/UicInterface/main.cpp67
-rw-r--r--Tests/QtAutogen/UicInterface/mywidget.cpp14
-rw-r--r--Tests/QtAutogen/UicInterface/mywidget.h25
-rw-r--r--Tests/QtAutogen/UicInterface/mywidget.ui32
11 files changed, 297 insertions, 0 deletions
diff --git a/Tests/QtAutogen/CommonTests.cmake b/Tests/QtAutogen/CommonTests.cmake
index 5746ab5b98..c56780ecff 100644
--- a/Tests/QtAutogen/CommonTests.cmake
+++ b/Tests/QtAutogen/CommonTests.cmake
@@ -24,6 +24,7 @@ if(QT_TEST_ALLOW_QT_MACROS)
ADD_AUTOGEN_TEST(MocCMP0071)
endif()
ADD_AUTOGEN_TEST(UicInclude uicInclude)
+ADD_AUTOGEN_TEST(UicInterface QtAutoUicInterface)
ADD_AUTOGEN_TEST(ObjectLibrary someProgram)
if(APPLE AND (NOT QT_TEST_VERSION STREQUAL 4))
ADD_AUTOGEN_TEST(MacOsFW)
diff --git a/Tests/QtAutogen/UicInterface/CMakeLists.txt b/Tests/QtAutogen/UicInterface/CMakeLists.txt
new file mode 100644
index 0000000000..a216aff64f
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/CMakeLists.txt
@@ -0,0 +1,58 @@
+cmake_minimum_required(VERSION 3.10)
+project(UicInterface)
+include("../AutogenTest.cmake")
+
+set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+# BEGIN Upstream
+
+set(CMAKE_VERBOSE_MAKEFILE ON)
+
+add_library(KI18n klocalizedstring.cpp)
+target_link_libraries(KI18n ${QT_QTCORE_TARGET})
+
+set(autouic_options
+ -tr tr2$<$<NOT:$<BOOL:$<TARGET_PROPERTY:NO_KUIT_SEMANTIC>>>:x>i18n
+)
+if (NOT Qt5Widgets_VERSION VERSION_LESS 5.3.0)
+ list(APPEND autouic_options -include klocalizedstring.h)
+endif()
+
+set_property(TARGET KI18n APPEND PROPERTY
+ INTERFACE_AUTOUIC_OPTIONS ${autouic_options}
+)
+
+set(domainProp $<TARGET_PROPERTY:TRANSLATION_DOMAIN>)
+set(nameLower $<LOWER_CASE:$<MAKE_C_IDENTIFIER:$<TARGET_PROPERTY:NAME>>>)
+set(domain_logic
+ $<$<BOOL:${domainProp}>:${domainProp}>$<$<NOT:$<BOOL:${domainProp}>>:${nameLower}>
+)
+set_property(TARGET KI18n APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "TRANSLATION_DOMAIN=${domain_logic}"
+)
+
+# END upstream
+
+get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_GENERATOR_IS_MULTI_CONFIG)
+set(INC_DIR "include_$<CONFIG>" )
+else()
+set(INC_DIR "include" )
+endif()
+
+add_library(LibWidget libwidget.cpp)
+target_link_libraries(LibWidget KI18n ${QT_QTGUI_TARGET})
+set_property(TARGET LibWidget PROPERTY NO_KUIT_SEMANTIC ON)
+set_property(TARGET LibWidget PROPERTY TRANSLATION_DOMAIN customdomain)
+
+add_library(MyWidget mywidget.cpp)
+target_link_libraries(MyWidget KI18n ${QT_QTGUI_TARGET})
+
+add_executable(QtAutoUicInterface main.cpp)
+target_compile_definitions(QtAutoUicInterface
+ PRIVATE
+ UI_LIBWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/LibWidget_autogen/${INC_DIR}/ui_libwidget.h"
+ UI_MYWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/MyWidget_autogen/${INC_DIR}/ui_mywidget.h"
+)
diff --git a/Tests/QtAutogen/UicInterface/klocalizedstring.cpp b/Tests/QtAutogen/UicInterface/klocalizedstring.cpp
new file mode 100644
index 0000000000..b629cd176e
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/klocalizedstring.cpp
@@ -0,0 +1,12 @@
+
+#include "klocalizedstring.h"
+
+QString tr2xi18n(const char* text, const char*)
+{
+ return QLatin1String("TranslatedX") + QString::fromLatin1(text);
+}
+
+QString tr2i18n(const char* text, const char*)
+{
+ return QLatin1String("Translated") + QString::fromLatin1(text);
+}
diff --git a/Tests/QtAutogen/UicInterface/klocalizedstring.h b/Tests/QtAutogen/UicInterface/klocalizedstring.h
new file mode 100644
index 0000000000..6129599dc8
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/klocalizedstring.h
@@ -0,0 +1,17 @@
+
+#ifndef KLOCALIZEDSTRING_H
+#define KLOCALIZEDSTRING_H
+
+#include <QString>
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ QString tr2xi18n(const char* text, const char* comment = 0);
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ QString tr2i18n(const char* text, const char* comment = 0);
+
+#endif
diff --git a/Tests/QtAutogen/UicInterface/libwidget.cpp b/Tests/QtAutogen/UicInterface/libwidget.cpp
new file mode 100644
index 0000000000..008c22a961
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/libwidget.cpp
@@ -0,0 +1,14 @@
+
+#include "libwidget.h"
+
+LibWidget::LibWidget(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::LibWidget)
+{
+ ui->setupUi(this);
+}
+
+LibWidget::~LibWidget()
+{
+ delete ui;
+}
diff --git a/Tests/QtAutogen/UicInterface/libwidget.h b/Tests/QtAutogen/UicInterface/libwidget.h
new file mode 100644
index 0000000000..b6f3e82525
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/libwidget.h
@@ -0,0 +1,25 @@
+
+#ifndef LIBWIDGET_H
+#define LIBWIDGET_H
+
+#include <QWidget>
+#include <memory>
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
+#include <klocalizedstring.h>
+#endif
+
+#include "ui_libwidget.h"
+
+class LibWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit LibWidget(QWidget* parent = 0);
+ ~LibWidget();
+
+private:
+ Ui::LibWidget* ui;
+};
+
+#endif
diff --git a/Tests/QtAutogen/UicInterface/libwidget.ui b/Tests/QtAutogen/UicInterface/libwidget.ui
new file mode 100644
index 0000000000..897371e4a3
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/libwidget.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LibWidget</class>
+ <widget class="QWidget" name="LibWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>60</y>
+ <width>57</width>
+ <height>15</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>LibLabel</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/UicInterface/main.cpp b/Tests/QtAutogen/UicInterface/main.cpp
new file mode 100644
index 0000000000..68bd843630
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/main.cpp
@@ -0,0 +1,67 @@
+
+#include <fstream>
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ std::ifstream f;
+ f.open(UI_LIBWIDGET_H);
+ if (!f.is_open()) {
+ std::cout << "Could not open \"" UI_LIBWIDGET_H "\"." << std::endl;
+ return -1;
+ }
+
+ {
+ bool gotTr2i18n = false;
+
+ while (!f.eof()) {
+ std::string output;
+ getline(f, output);
+ if (!gotTr2i18n) {
+ gotTr2i18n = output.find("tr2i18n") != std::string::npos;
+ }
+ if (output.find("tr2xi18n") != std::string::npos) {
+ std::cout << "ui_libwidget,h uses tr2xi18n, though it should not."
+ << std::endl;
+ return -1;
+ }
+ }
+
+ if (!gotTr2i18n) {
+ std::cout << "Did not find tr2i18n in ui_libwidget.h" << std::endl;
+ return -1;
+ }
+ }
+
+ f.close();
+ f.open(UI_MYWIDGET_H);
+ if (!f.is_open()) {
+ std::cout << "Could not open \"" UI_MYWIDGET_H "\"." << std::endl;
+ return -1;
+ }
+
+ {
+ bool gotTr2xi18n = false;
+
+ while (!f.eof()) {
+ std::string output;
+ getline(f, output);
+ if (!gotTr2xi18n) {
+ gotTr2xi18n = output.find("tr2xi18n") != std::string::npos;
+ }
+ if (output.find("tr2i18n") != std::string::npos) {
+ std::cout << "ui_mywidget,h uses tr2i18n, though it should not."
+ << std::endl;
+ return -1;
+ }
+ }
+ if (!gotTr2xi18n) {
+ std::cout << "Did not find tr2xi18n in ui_mywidget.h" << std::endl;
+ return -1;
+ }
+ }
+ f.close();
+
+ return 0;
+}
diff --git a/Tests/QtAutogen/UicInterface/mywidget.cpp b/Tests/QtAutogen/UicInterface/mywidget.cpp
new file mode 100644
index 0000000000..7cf1a13189
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/mywidget.cpp
@@ -0,0 +1,14 @@
+
+#include "mywidget.h"
+
+MyWidget::MyWidget(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::MyWidget)
+{
+ ui->setupUi(this);
+}
+
+MyWidget::~MyWidget()
+{
+ delete ui;
+}
diff --git a/Tests/QtAutogen/UicInterface/mywidget.h b/Tests/QtAutogen/UicInterface/mywidget.h
new file mode 100644
index 0000000000..c23e55de77
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/mywidget.h
@@ -0,0 +1,25 @@
+
+#ifndef MYWIDGET_H
+#define MYWIDGET_H
+
+#include <QWidget>
+#include <memory>
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
+#include <klocalizedstring.h>
+#endif
+
+#include "ui_mywidget.h"
+
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit MyWidget(QWidget* parent = 0);
+ ~MyWidget();
+
+private:
+ Ui::MyWidget* ui;
+};
+
+#endif
diff --git a/Tests/QtAutogen/UicInterface/mywidget.ui b/Tests/QtAutogen/UicInterface/mywidget.ui
new file mode 100644
index 0000000000..b2b9cc5925
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/mywidget.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MyWidget</class>
+ <widget class="QWidget" name="MyWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QPushButton" name="pushButton">
+ <property name="geometry">
+ <rect>
+ <x>110</x>
+ <y>40</y>
+ <width>81</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Special button</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>