summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_translation_api
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake/test_translation_api')
-rw-r--r--tests/auto/cmake/test_translation_api/CMakeLists.txt136
-rw-r--r--tests/auto/cmake/test_translation_api/myi18nobject.cpp49
-rw-r--r--tests/auto/cmake/test_translation_api/myobject_de.ts12
-rw-r--r--tests/auto/cmake/test_translation_api/some_dir/some_include.h37
4 files changed, 0 insertions, 234 deletions
diff --git a/tests/auto/cmake/test_translation_api/CMakeLists.txt b/tests/auto/cmake/test_translation_api/CMakeLists.txt
deleted file mode 100644
index ea20ff320..000000000
--- a/tests/auto/cmake/test_translation_api/CMakeLists.txt
+++ /dev/null
@@ -1,136 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-
-project(test_update_translation_macro)
-
-find_package(Qt6 REQUIRED COMPONENTS Core LinguistTools)
-
-function(create_app target)
- add_executable(${target}
- myi18nobject.cpp)
-
- target_include_directories(${target}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/some_dir)
-
- target_link_libraries(${target} Qt6::Core)
-endfunction()
-
-function(expect_target target)
- if(NOT TARGET ${target})
- message(FATAL_ERROR "Expected target '${target}' does not exist.")
- endif()
-endfunction()
-
-function(not_expect_target target)
- if(TARGET ${target})
- message(FATAL_ERROR "Target '${target}' exists unexpectedly.")
- endif()
-endfunction()
-
-function(expect_files_in_list list_var)
- set(file_names "")
- foreach(path IN LISTS "${list_var}")
- get_filename_component(file_name "${path}" NAME)
- list(APPEND file_names "${file_name}")
- endforeach()
- set(found_file_names "")
- foreach(expected_file_name IN LISTS ARGN)
- list(FIND file_names "${expected_file_name}" idx)
- if(idx EQUAL -1)
- message(FATAL_ERROR "Expected file name '${expected_file_name}' is not in "
- "'${list_var}'. Its value is '${${list_var}}'.")
- endif()
- list(APPEND found_file_names "${expected_file_name}")
- endforeach()
- list(REMOVE_ITEM file_names ${found_file_names})
- list(LENGTH file_names n)
- if(NOT n EQUAL 0)
- message(FATAL_ERROR "Unexpected file names in '${list_var}': ${file_names}\n"
- "Value of '${list_var}' is '${${list_var}}'.")
- endif()
-endfunction()
-
-# Test NO_GLOBAL_TARGET for lupdate.
-create_app(app1)
-qt6_add_lupdate(app1
- NO_GLOBAL_TARGET
- TS_FILES myobject_de.ts)
-expect_target(app1_lupdate)
-not_expect_target(app1_lrelease)
-not_expect_target(update_translations)
-not_expect_target(release_translations)
-
-# Test NO_GLOBAL_TARGET for lrelease.
-create_app(app2)
-qt6_add_lrelease(app2
- NO_GLOBAL_TARGET
- TS_FILES myobject_de.ts myobject_en.ts
- QM_FILES_OUTPUT_VARIABLE qm_files)
-not_expect_target(app2_lupdate)
-expect_target(app2_lrelease)
-not_expect_target(update_translations)
-not_expect_target(release_translations)
-expect_files_in_list(qm_files myobject_de.qm myobject_en.qm)
-
-# Typical usage of qt_add_lupdate/qt_add_lrelease. Pass some options for good measure.
-create_app(app3)
-qt6_add_lupdate(app3
- TS_FILES myobject_no.ts myobject_fi.ts
- OPTIONS -source-language en_US)
-qt6_add_lrelease(app3
- TS_FILES myobject_no.ts myobject_fi.ts
- OPTIONS -compress
- QM_FILES_OUTPUT_VARIABLE qm_files2)
-expect_target(app3_lupdate)
-expect_target(app3_lrelease)
-expect_target(release_translations)
-expect_files_in_list(qm_files2 myobject_no.qm myobject_fi.qm)
-
-# Now do the same with qt6_add_translations.
-create_app(app4)
-qt6_add_translations(app4
- TS_FILES myobject_no.ts myobject_fi.ts
- QM_FILES_OUTPUT_VARIABLE qm_files
- LUPDATE_OPTIONS -source-language en_US
- LRELEASE_OPTIONS -compress)
-expect_target(app4_lupdate)
-expect_target(app4_lrelease)
-expect_target(release_translations)
-expect_files_in_list(qm_files myobject_no.qm myobject_fi.qm)
-
-# Typical usage of qt_add_translations with a generated resource.
-create_app(app5)
-qt6_add_translations(app5
- TS_FILES myobject_ru.ts
- RESOURCE_PREFIX "/tränslehschns")
-
-# qt_add_translations on a static lib with a generated resource and the default resource prefix.
-# Extract the created resource targets.
-add_library(staticlib1 STATIC
- myi18nobject.cpp)
-target_include_directories(staticlib1
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/some_dir)
-target_link_libraries(staticlib1 PRIVATE Qt6::Core)
-set(staticlib1_resource_targets "")
-qt6_add_translations(staticlib1
- TS_FILES myobject_da.ts
- OUTPUT_TARGETS staticlib1_resource_targets)
-if("${staticlib1_resource_targets}" STREQUAL "")
- message(FATAL_ERROR "staticlib1_resource_targets is empty.")
-endif()
-
-# Explicitly specify SOURCES.
-create_app(app6)
-qt6_add_translations(app6
- TS_FILES myobject_cs.ts
- SOURCES myi18nobject.cpp)
-
-# Explicitly specify INCLUDE_DIRECTORIES.
-create_app(app7)
-qt6_add_translations(app7
- TS_FILES myobject_nl.ts
- INCLUDE_DIRECTORIES some_dir)
-
-# Build the update_translations target
-add_custom_target(my_all_target
- ALL
- DEPENDS update_translations)
diff --git a/tests/auto/cmake/test_translation_api/myi18nobject.cpp b/tests/auto/cmake/test_translation_api/myi18nobject.cpp
deleted file mode 100644
index eacce70db..000000000
--- a/tests/auto/cmake/test_translation_api/myi18nobject.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include <QCoreApplication>
-#include <QLocale>
-#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();
- if (!myappTranslator->load("myobject_" + localeName + ".qm", qApp->applicationDirPath()))
- return 1;
- myappTranslator->setObjectName("myobject_" + localeName);
- app.installTranslator(myappTranslator);
-
- qDebug() << QObject::tr("Hello, world!");
- return 0;
-}
diff --git a/tests/auto/cmake/test_translation_api/myobject_de.ts b/tests/auto/cmake/test_translation_api/myobject_de.ts
deleted file mode 100644
index fb4ee6f55..000000000
--- a/tests/auto/cmake/test_translation_api/myobject_de.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-<?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="47"/>
- <source>Hello, world!</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-</TS>
diff --git a/tests/auto/cmake/test_translation_api/some_dir/some_include.h b/tests/auto/cmake/test_translation_api/some_dir/some_include.h
deleted file mode 100644
index 627b9e9e3..000000000
--- a/tests/auto/cmake/test_translation_api/some_dir/some_include.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SOME_INCLUDE_H
-#define SOME_INCLUDE_H
-
-enum {
- Non_Empty_File
-};
-
-#endif