diff --git a/libs/odf/tests/CMakeLists.txt b/libs/odf/tests/CMakeLists.txt index 703c7f1136f..e7de0e2d7a7 100644 --- a/libs/odf/tests/CMakeLists.txt +++ b/libs/odf/tests/CMakeLists.txt @@ -1,56 +1,60 @@ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) include_directories( ${KOODF_INCLUDES} ) # call: koodf_add_unit_test( LINK_LIBRARIES [ [...]] [GUI]) macro(KOODF_ADD_UNIT_TEST _TEST_NAME) ecm_add_test( ${ARGN} TEST_NAME "${_TEST_NAME}" NAME_PREFIX "libs-koodf-" ) endmacro() ########### next target ############### koodf_add_unit_test(TestKoGenStyles TestKoGenStyles.cpp LINK_LIBRARIES koodf KF5::I18n Qt5::Test) ########### next target ############### koodf_add_unit_test(TestOdfSettings TestOdfSettings.cpp LINK_LIBRARIES koodf KF5::I18n Qt5::Test) ########### next target ############### koodf_add_unit_test(TestKoOdfLoadingContext TestKoOdfLoadingContext.cpp LINK_LIBRARIES koodf KF5::I18n Qt5::Test) ########### next target ############### koodf_add_unit_test(TestXmlWriter TestXmlWriter.cpp LINK_LIBRARIES koodf Qt5::Test) ########### next target ############### koodf_add_unit_test(TestXmlReader TestXmlReader.cpp LINK_LIBRARIES koodf Qt5::Test) ########### next target ############### koodf_add_unit_test(TestXmlReaderWithoutSpaces TestXmlReaderWithoutSpaces.cpp LINK_LIBRARIES koodf Qt5::Test) ########### next target ############### koodf_add_unit_test(kodomtest kodomtest.cpp LINK_LIBRARIES koodf Qt5::Test) ########### next target ############### koodf_add_unit_test(TestStorage TestStorage.cpp LINK_LIBRARIES koodf KF5::I18n Qt5::Test) ########### next target ############### koodf_add_unit_test(TestKoUnit TestKoUnit.cpp LINK_LIBRARIES koodf Qt5::Test) ########### next target ############### koodf_add_unit_test(TestNumberStyle TestNumberStyle.cpp LINK_LIBRARIES koodf Qt5::Test) ########### next target ############### koodf_add_unit_test(TestKoElementReference TestKoElementReference.cpp LINK_LIBRARIES koodf Qt5::Test) +########### next target ############### + +koodf_add_unit_test(TestWriteStyleXml TestWriteStyleXml.cpp LINK_LIBRARIES koodf Qt5::Test) + ########### end ############### diff --git a/libs/odf/tests/TestWriteStyleXml.cpp b/libs/odf/tests/TestWriteStyleXml.cpp new file mode 100644 index 00000000000..2bea11d3a62 --- /dev/null +++ b/libs/odf/tests/TestWriteStyleXml.cpp @@ -0,0 +1,75 @@ +/* This file is part of the KDE project + * Copyright (C) 2017 Jos van den Oever + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace writeodf; + +class TestWriteStyleXml : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void testWriteRegionLeft(); +}; + +void TestWriteStyleXml::testWriteRegionLeft() +{ + QBuffer buffer; + buffer.open(QIODevice::WriteOnly); + { + KoXmlWriter writer(&buffer); + writer.startDocument(0); + office_document_styles styles(&writer); + styles.addAttribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0"); + styles.addAttribute("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0"); + styles.addAttribute("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0"); + office_master_styles master_styles(styles.add_office_master_styles()); + style_master_page master_page(master_styles.add_style_master_page("Standard", "Layout")); + style_header header(master_page.add_style_header()); + style_region_left left(header.add_style_region_left()); + text_p p(left.add_text_p()); + p.addTextNode("left"); + } + const QString r = buffer.buffer(); + const QString e = "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " left\n" + " \n" + " \n" + " \n" + " \n" + ""; + QCOMPARE(r, e); +} + +QTEST_GUILESS_MAIN(TestWriteStyleXml) +#include +