Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ else()
add_subdirectory( "${CORE_ROOT_DIR}/OOXML/test" ooxml_test )
add_subdirectory( "${CORE_ROOT_DIR}/OfficeUtils/tests" officeutils_test )
add_subdirectory( "${CORE_ROOT_DIR}/OdfFile/Reader/Converter/SMCustomShape2OOXML/TestSMCustomShape" starmath_smcustomshape_test )
add_subdirectory( "${CORE_ROOT_DIR}/OdfFile/Test/test_odf" test_odf )
endif()

endif()
99 changes: 99 additions & 0 deletions OdfFile/Test/test_odf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
cmake_minimum_required(VERSION 3.10)

project(test_odf)

# OdfFile/Test/test_odf -> three levels under the repository root.
set(CORE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../..")

include(${CORE_ROOT_DIR}/common.cmake)

# test_odf.pro builds only test.cpp + common.cpp (the entrance/motion/audio/
# interactions modules are commented out) and converts an .odp fixture via
# ConvertODF2OOXml() + COfficeFileFormatChecker.
#
# ConvertODF2OOXml() lives in OdfFormatLib, whose ODF->OOXML writer references
# the whole OOXML/MS format-library set (XmlUtils, SimpleTypes, OOX/PPTX/XLS/XLSB
# classes, ...). Those static libraries reference each other and are only ever
# linked together inside x2tlib. Add the x2tlib "library" subdirectory (which
# guard-adds every one of those targets) so they exist, then link the static
# archives below inside a --start-group, mirroring x2tlib's own link. In the
# normal top-level build x2t is configured first, so this is a no-op there.
if(NOT TARGET x2tlib)
add_subdirectory(${CORE_ROOT_DIR}/X2tConverter/build/cmake/library x2tlib)
endif()

# The test reads its fixture via the working-dir-relative path
# "ExampleFiles/motion.odp" (TestEnv passes it straight to convert_single()).
# Stage the committed ExampleFiles next to the binary and run from that dir.
set(_test_odf_run_dir "${CMAKE_CURRENT_BINARY_DIR}/run")

# test.cpp owns main() (InitGoogleTest + AddGlobalTestEnvironment + RUN_ALL_TESTS)
# -> do NOT pass GTEST_MAIN. COfficeFileFormatChecker is compiled from
# OfficeFileFormatChecker2.cpp directly into the target (no format library builds
# it; x2tlib compiles it the same way). FILE_FORMAT_CHECKER_WITH_MACRO is left
# undefined to avoid the heavy PPT dependency chain. unicode_util.cpp/pole.cpp are
# NOT compiled here -- DocxFormatLib provides them, so doing so would duplicate.
add_core_gtest(
NAME test_odf
SOURCES test.cpp
common.cpp
${CORE_ROOT_DIR}/Common/OfficeFileFormatChecker2.cpp
WORKING_DIRECTORY "${_test_odf_run_dir}"
)

# The OOXML/MS format static libraries reference one another, so wrap them in a
# linker group; the remaining converter libraries are shared and linked after.
# This mirrors the static + dynamic lib lists of target_link_libraries(x2tlib).
target_link_libraries(test_odf PRIVATE
-Wl,--start-group
OdfFormatLib
DocFormatLib
PptFormatLib
RtfFormatLib
TxtXmlFormatLib
BinDocument
PPTXFormatLib
DocxFormatLib
XlsbFormatLib
XlsFormatLib
VbaFormatLib
CompoundFileLib
CryptoPPLib
-Wl,--end-group
graphics
kernel
UnicodeConverter
kernel_network
Fb2File
PdfFile
HtmlFile2
EpubFile
XpsFile
OFDFile
DjVuFile
doctrenderer
DocxRenderer
IWorkFile
HWPFile
StarMathConverter
ooxmlsignature
Boost::system
Boost::filesystem
Boost::regex
Boost::date_time
)

# test_odf.pro adds the core root (for rewritten relative includes such as
# "Common/OfficeFileFormatChecker.h") and X2tConverter/src on the include path.
target_include_directories(test_odf PRIVATE
"${CORE_ROOT_DIR}"
"${CORE_ROOT_DIR}/X2tConverter/src"
)

add_custom_command(TARGET test_odf POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${_test_odf_run_dir}"
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/ExampleFiles"
"${_test_odf_run_dir}/ExampleFiles"
COMMENT "Staging test_odf fixtures"
)
36 changes: 9 additions & 27 deletions OdfFile/Test/test_odf/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,34 +224,16 @@
//////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <tchar.h>

#include "D:\ONLYOFFICE\core\Common\OfficeFileFormatChecker.h"
#include "D:\ONLYOFFICE\core\OfficeUtils\src\OfficeUtils.h"
#include "D:\ONLYOFFICE\core\DesktopEditor\common\Directory.h"
#include "D:\ONLYOFFICE\core\OdfFile\Reader\Converter\ConvertOO2OOX.h"
#include "D:\ONLYOFFICE\core\OdfFile\Common\logging.h"

#if defined(_WIN64)
#pragma comment(lib, "D:/ONLYOFFICE/core/Common/3dParty/icu/win_64/build/icuuc.lib")
#pragma comment(lib, "D:/ONLYOFFICE/core/build/lib/win_64/DEBUG/graphics.lib")
#pragma comment(lib, "D:/ONLYOFFICE/core/build/lib/win_64/DEBUG/kernel.lib")
#pragma comment(lib, "D:/ONLYOFFICE/core/build/lib/win_64/DEBUG/UnicodeConverter.lib")
#pragma comment(lib, "D:/ONLYOFFICE/core/build/lib/win_64/DEBUG/CryptoPPLib.lib")

#elif defined (_WIN32)

#if defined(DEBUG)
#pragma comment(lib, "../../../../build/lib/win_32/DEBUG/graphics.lib")
#pragma comment(lib, "../../../../build/lib/win_32/DEBUG/kernel.lib")
#pragma comment(lib, "../../../../build/lib/win_32/DEBUG/UnicodeConverter.dll")
#else
#pragma comment(lib, "../../../../build/lib/win_32/graphics.lib")
#pragma comment(lib, "../../../../build/lib/win_32/kernel.lib")
#pragma comment(lib, "../../../../build/lib/win_32/UnicodeConverter.dll")
#endif
#pragma comment(lib, "../../../../build/bin/icu/win_32/icuuc.lib")
#endif
// Resolved relative to the repository root (the CMake target adds the core
// root to the include path). The original sources used absolute Windows paths
// and a per-platform "#pragma comment(lib, ...)" block; libraries are now
// linked by CMake (see CMakeLists.txt), so those are gone.
#include "Common/OfficeFileFormatChecker.h"
#include "OfficeUtils/src/OfficeUtils.h"
#include "DesktopEditor/common/Directory.h"
#include "OdfFile/Reader/Converter/ConvertOO2OOX.h"
#include "OdfFile/Common/logging.h"

HRESULT convert_single(std::wstring srcFileName)
{
Expand Down
14 changes: 12 additions & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,23 @@ Done:
- [x] `OdfFile/Reader/Converter/SMCustomShape2OOXML/TestSMCustomShape` — dep:
SMCustomShape2OOXML (new CMake library target created for this suite; itself depends on
UnicodeConverter, kernel). No fixtures.
- [x] `OdfFile/Test/test_odf` — deps: OdfFormatLib (for `ConvertODF2OOXml`), kernel,
graphics, UnicodeConverter; `OfficeFileFormatChecker2.cpp`, `pole.cpp` and
`unicode_util.cpp` are compiled into the target (as `x2tTester` does). Owns its
`main()` (so no `GTEST_MAIN`). Builds only `test.cpp` + `common.cpp` — the
entrance/motion/audio/interactions modules are commented out in the `.pro`, so the
suite registers no `TEST()` cases yet; the global `TestEnv` still exercises an
`.odp -> .pptx` conversion in its `SetUp()`. Fixtures under `ExampleFiles/` are
staged next to the binary and the test runs from there (the fixture path
`ExampleFiles/motion.odp` is working-dir-relative). The committed `common.cpp` had
absolute Windows include paths and a `#pragma comment(lib, ...)` block; these were
replaced with repo-relative includes (CMake links the libraries).

### gtest suites to migrate

Runnable headless once migrated (no missing fixtures, no JS engine):

- [ ] `OdfFile/Test/test_odf` — OdfFormatLib dependency chain; own `main`. Fixtures
committed under `test_odf/ExampleFiles/`.
_(none — all migrated; see Done above.)_

Blocked / need extra work (build targets intentionally not created yet):

Expand Down
Loading