mirror of
https://github.com/august-alt/gpui.git
synced 2025-03-13 08:58:39 +03:00
chore: add test for TranslatorStorage
This commit is contained in:
parent
46ab925906
commit
0ae9861008
@ -26,6 +26,7 @@ BuildRequires: libuuid-devel
|
|||||||
BuildRequires: glib2-devel
|
BuildRequires: glib2-devel
|
||||||
BuildRequires: libpcre-devel
|
BuildRequires: libpcre-devel
|
||||||
BuildRequires: libkrb5-devel
|
BuildRequires: libkrb5-devel
|
||||||
|
BuildRequires: libgtest-devel
|
||||||
|
|
||||||
BuildRequires: qt5-base-common
|
BuildRequires: qt5-base-common
|
||||||
BuildRequires: doxygen
|
BuildRequires: doxygen
|
||||||
|
@ -41,6 +41,7 @@ RUN apt-get update \
|
|||||||
libpcre-devel \
|
libpcre-devel \
|
||||||
libkrb5-devel \
|
libkrb5-devel \
|
||||||
libxerces-c-devel \
|
libxerces-c-devel \
|
||||||
|
libgtest-devel \
|
||||||
xsd \
|
xsd \
|
||||||
boost-devel-headers \
|
boost-devel-headers \
|
||||||
desktop-file-utils \
|
desktop-file-utils \
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
add_subdirectory(core)
|
||||||
add_subdirectory(gui)
|
add_subdirectory(gui)
|
||||||
add_subdirectory(io)
|
add_subdirectory(io)
|
||||||
add_subdirectory(model)
|
add_subdirectory(model)
|
||||||
|
4
tests/auto/core/CMakeLists.txt
Normal file
4
tests/auto/core/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
find_package(GPUI COMPONENTS gui core REQUIRED)
|
||||||
|
include_directories(${GPUI_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
add_subdirectory(translatorstorage)
|
28
tests/auto/core/translatorstorage/CMakeLists.txt
Normal file
28
tests/auto/core/translatorstorage/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
find_package(GTest)
|
||||||
|
find_package(Qt5 COMPONENTS Core Gui Test LinguistTools REQUIRED)
|
||||||
|
|
||||||
|
set(TS_FILES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/i18n/test_ru.ts
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/i18n/test_en.ts
|
||||||
|
)
|
||||||
|
|
||||||
|
add_translation(QM_FILES "${TS_FILES}")
|
||||||
|
|
||||||
|
add_translation_resource(RESOURCES_SRC translatorstorage-tests "${QM_FILES}")
|
||||||
|
|
||||||
|
qt5_add_resources(LIB_RESOURCES ${RESOURCES_SRC})
|
||||||
|
|
||||||
|
add_executable(translatorstorage-test
|
||||||
|
translatorstorage-test.cpp
|
||||||
|
|
||||||
|
translatorstorageshadow.h
|
||||||
|
translatorstorageshadow.cpp
|
||||||
|
|
||||||
|
${LIB_RESOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(translatorstorage-test gpui-core Qt5::Core Qt5::Gui Qt5::Test
|
||||||
|
gtest gtest_main)
|
||||||
|
|
||||||
|
|
||||||
|
add_gpui_test(core.translatorstorage-test translatorstorage-test)
|
12
tests/auto/core/translatorstorage/i18n/test_en.ts
Normal file
12
tests/auto/core/translatorstorage/i18n/test_en.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="ru_RU">
|
||||||
|
<context>
|
||||||
|
<name>QObject</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../translatorstorage-test.cpp" line="13"/>
|
||||||
|
<source>test</source>
|
||||||
|
<translation>тест</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
12
tests/auto/core/translatorstorage/i18n/test_ru.ts
Normal file
12
tests/auto/core/translatorstorage/i18n/test_ru.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>QObject</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../translatorstorage-test.cpp" line="13"/>
|
||||||
|
<source>test</source>
|
||||||
|
<translation>test</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
33
tests/auto/core/translatorstorage/translatorstorage-test.cpp
Normal file
33
tests/auto/core/translatorstorage/translatorstorage-test.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTest>
|
||||||
|
|
||||||
|
#include "../../../../src/core/translatorstorage.h"
|
||||||
|
#include "translatorstorageshadow.h"
|
||||||
|
|
||||||
|
TEST(TranslatorStorage, loadTranslators)
|
||||||
|
{
|
||||||
|
QObject::tr("test");
|
||||||
|
|
||||||
|
TranslatorStorage translatorStorage;
|
||||||
|
translatorStorage.loadTranslators("en");
|
||||||
|
|
||||||
|
void *ptr = &translatorStorage;
|
||||||
|
tests::TranslatorStorageShadow *shadowPtr = static_cast<tests::TranslatorStorageShadow *>(ptr);
|
||||||
|
auto loadedTranslations = shadowPtr->d.get()->translators.size();
|
||||||
|
|
||||||
|
EXPECT_EQ(loadedTranslations, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
#include "translatorstorageshadow.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace tests
|
||||||
|
{
|
||||||
|
TranslatorStorageShadow::TranslatorStorageShadow()
|
||||||
|
: d(new TranslatorStorageShadowPrivate)
|
||||||
|
{}
|
||||||
|
|
||||||
|
TranslatorStorageShadow::~TranslatorStorageShadow() {}
|
||||||
|
|
||||||
|
} // namespace tests
|
27
tests/auto/core/translatorstorage/translatorstorageshadow.h
Normal file
27
tests/auto/core/translatorstorage/translatorstorageshadow.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef GPUI_TRANSLATOR_STORAGE_SHADOW_H
|
||||||
|
#define GPUI_TRANSLATOR_STORAGE_SHADOW_H
|
||||||
|
|
||||||
|
#include "../../../../src/core/translatorstorage.h"
|
||||||
|
|
||||||
|
namespace tests
|
||||||
|
{
|
||||||
|
class TranslatorStorageShadowPrivate;
|
||||||
|
|
||||||
|
class TranslatorStorageShadow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TranslatorStorageShadow();
|
||||||
|
~TranslatorStorageShadow();
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::unique_ptr<TranslatorStorageShadowPrivate> d;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TranslatorStorageShadowPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::vector<std::unique_ptr<QTranslator>> translators = {};
|
||||||
|
QString m_errorString = {};
|
||||||
|
};
|
||||||
|
} // namespace tests
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user