summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Funk <kevin.funk@kdab.com>2015-12-21 14:59:10 +0100
committerKevin Funk <kfunk@kde.org>2015-12-28 22:37:47 +0000
commitb8c88173de60e3962fddea2a53aad0f7d0e1b630 (patch)
tree2d5a30cb15dcac47ef08b0ddc7b1f117df4941a8 /tests
parent40733992775d54b492f0ddf36cfde209dbb7a690 (diff)
downloadqttools-b8c88173de60e3962fddea2a53aad0f7d0e1b630.tar.gz
Split up test_translation_macros
Split up into two individual tests: * test_add_translation_macro * test_create_translation_macro Required for upcoming extension of qt5_add_translation macro Change-Id: Iaf18aed493119bdbefec3790a7a29bb42c6925b7 Reviewed-by: Stephen Kelly <steveire@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/cmake/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/test_add_translation_macro/CMakeLists.txt23
-rw-r--r--tests/auto/cmake/test_add_translation_macro/myi18nobject.cpp (renamed from tests/auto/cmake/test_translation_macros/myi18nobject.cpp)0
-rw-r--r--tests/auto/cmake/test_add_translation_macro/myobject_de.ts (renamed from tests/auto/cmake/test_translation_macros/myobject_de.ts)6
-rw-r--r--tests/auto/cmake/test_add_translation_macro/some_dir/some_include.h (renamed from tests/auto/cmake/test_translation_macros/some_dir/some_include.h)0
-rw-r--r--tests/auto/cmake/test_create_translation_macro/CMakeLists.txt (renamed from tests/auto/cmake/test_translation_macros/CMakeLists.txt)3
-rw-r--r--tests/auto/cmake/test_create_translation_macro/myi18nobject.cpp51
-rw-r--r--tests/auto/cmake/test_create_translation_macro/myobject_de.ts12
-rw-r--r--tests/auto/cmake/test_create_translation_macro/some_dir/some_include.h41
9 files changed, 133 insertions, 6 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 5b54a45f0..bf69829fb 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -30,7 +30,8 @@ find_package(Qt5Core REQUIRED)
include("${_Qt5CTestMacros}")
if(NOT CMAKE_CROSSCOMPILING)
- expect_pass(test_translation_macros)
+ expect_pass(test_create_translation_macro)
+ expect_pass(test_add_translation_macro)
endif()
if (NOT NO_WIDGETS)
diff --git a/tests/auto/cmake/test_add_translation_macro/CMakeLists.txt b/tests/auto/cmake/test_add_translation_macro/CMakeLists.txt
new file mode 100644
index 000000000..90e7f67f5
--- /dev/null
+++ b/tests/auto/cmake/test_add_translation_macro/CMakeLists.txt
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(test_add_translation_macro)
+
+find_package(Qt5Core 5.0.0 REQUIRED)
+find_package(Qt5LinguistTools 5.0.0 REQUIRED)
+
+include_directories(
+ ${Qt5Core_INCLUDE_DIRS}
+)
+
+add_definitions(${Qt5Core_DEFINITIONS})
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
+
+set(my_srcs myi18nobject.cpp)
+
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/some_dir")
+
+qt5_add_translation(qm_files myobject_de.ts)
+
+add_executable(test_add_translation ${my_srcs} ${qm_files})
+target_link_libraries(test_add_translation ${Qt5Core_LIBRARIES})
diff --git a/tests/auto/cmake/test_translation_macros/myi18nobject.cpp b/tests/auto/cmake/test_add_translation_macro/myi18nobject.cpp
index d6b0611f7..d6b0611f7 100644
--- a/tests/auto/cmake/test_translation_macros/myi18nobject.cpp
+++ b/tests/auto/cmake/test_add_translation_macro/myi18nobject.cpp
diff --git a/tests/auto/cmake/test_translation_macros/myobject_de.ts b/tests/auto/cmake/test_add_translation_macro/myobject_de.ts
index 3b8f8bb55..240ffb389 100644
--- a/tests/auto/cmake/test_translation_macros/myobject_de.ts
+++ b/tests/auto/cmake/test_add_translation_macro/myobject_de.ts
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
-<TS version="2.0" language="de_DE">
+<TS version="2.1" language="de_DE">
<context>
<name>QObject</name>
<message>
- <location filename="myi18nobject.cpp" line="15"/>
+ <location filename="myi18nobject.cpp" line="49"/>
<source>Hello, world!</source>
- <translation>Hallo, Welt</translation>
+ <translation type="unfinished"></translation>
</message>
</context>
</TS>
diff --git a/tests/auto/cmake/test_translation_macros/some_dir/some_include.h b/tests/auto/cmake/test_add_translation_macro/some_dir/some_include.h
index 24657b9f1..24657b9f1 100644
--- a/tests/auto/cmake/test_translation_macros/some_dir/some_include.h
+++ b/tests/auto/cmake/test_add_translation_macro/some_dir/some_include.h
diff --git a/tests/auto/cmake/test_translation_macros/CMakeLists.txt b/tests/auto/cmake/test_create_translation_macro/CMakeLists.txt
index 14ecb40e3..71cd7450c 100644
--- a/tests/auto/cmake/test_translation_macros/CMakeLists.txt
+++ b/tests/auto/cmake/test_create_translation_macro/CMakeLists.txt
@@ -1,7 +1,6 @@
-
cmake_minimum_required(VERSION 2.8)
-project(test_translation_macros)
+project(test_create_translation_macros)
find_package(Qt5Core 5.0.0 REQUIRED)
find_package(Qt5LinguistTools 5.0.0 REQUIRED)
diff --git a/tests/auto/cmake/test_create_translation_macro/myi18nobject.cpp b/tests/auto/cmake/test_create_translation_macro/myi18nobject.cpp
new file mode 100644
index 000000000..d6b0611f7
--- /dev/null
+++ b/tests/auto/cmake/test_create_translation_macro/myi18nobject.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QCoreApplication>
+#include <QTranslator>
+
+#include "some_include.h"
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+ QTranslator *myappTranslator = new QTranslator;
+ QString localeName = QLocale::system().name();
+ myappTranslator->load("myobject_" + localeName + ".qm", qApp->applicationDirPath());
+ myappTranslator->setObjectName("myobject_" + localeName);
+ app.installTranslator(myappTranslator);
+
+ qDebug() << QObject::tr("Hello, world!");
+ return 0;
+}
diff --git a/tests/auto/cmake/test_create_translation_macro/myobject_de.ts b/tests/auto/cmake/test_create_translation_macro/myobject_de.ts
new file mode 100644
index 000000000..240ffb389
--- /dev/null
+++ b/tests/auto/cmake/test_create_translation_macro/myobject_de.ts
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="de_DE">
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="myi18nobject.cpp" line="49"/>
+ <source>Hello, world!</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/cmake/test_create_translation_macro/some_dir/some_include.h b/tests/auto/cmake/test_create_translation_macro/some_dir/some_include.h
new file mode 100644
index 000000000..24657b9f1
--- /dev/null
+++ b/tests/auto/cmake/test_create_translation_macro/some_dir/some_include.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SOME_INCLUDE_H
+#define SOME_INCLUDE_H
+
+enum {
+ Non_Empty_File
+};
+
+#endif