From 064e31f7ef1dd2bf18f3674086ebe6fde1ff91a0 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Wed, 4 Mar 2020 18:08:18 +0100 Subject: vcl: add TypeSerializer test for serializing Gradient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibf4d070fa9085bad103c52fa7656e2f8240784df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89997 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/CppunitTest_vcl_type_serializer_test.mk | 50 ++++++++++++++++++++++ vcl/Module_vcl.mk | 1 + vcl/inc/TypeSerializer.hxx | 2 +- vcl/qa/cppunit/TypeSerializerTest.cxx | 66 +++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 vcl/CppunitTest_vcl_type_serializer_test.mk create mode 100644 vcl/qa/cppunit/TypeSerializerTest.cxx (limited to 'vcl') diff --git a/vcl/CppunitTest_vcl_type_serializer_test.mk b/vcl/CppunitTest_vcl_type_serializer_test.mk new file mode 100644 index 000000000000..aa4a36e2ee32 --- /dev/null +++ b/vcl/CppunitTest_vcl_type_serializer_test.mk @@ -0,0 +1,50 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,vcl_type_serializer_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,vcl_type_serializer_test, \ + vcl/qa/cppunit/TypeSerializerTest \ +)) + +$(eval $(call gb_CppunitTest_use_external,vcl_type_serializer_test,boost_headers)) + +$(eval $(call gb_CppunitTest_set_include,vcl_type_serializer_test,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,vcl_type_serializer_test, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + svt \ + test \ + tl \ + unotest \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,vcl_type_serializer_test)) + +$(eval $(call gb_CppunitTest_use_ure,vcl_type_serializer_test)) +$(eval $(call gb_CppunitTest_use_vcl,vcl_type_serializer_test)) + +$(eval $(call gb_CppunitTest_use_components,vcl_type_serializer_test,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + uui/util/uui \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,vcl_type_serializer_test)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 83c493a5afa2..66ca4f01490b 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -206,6 +206,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\ CppunitTest_vcl_widget_definition_reader_test \ CppunitTest_vcl_backend_test \ CppunitTest_vcl_blocklistparser_test \ + CppunitTest_vcl_type_serializer_test \ )) ifeq ($(USING_X11),TRUE) diff --git a/vcl/inc/TypeSerializer.hxx b/vcl/inc/TypeSerializer.hxx index 76842aeee3d2..befd4edd7660 100644 --- a/vcl/inc/TypeSerializer.hxx +++ b/vcl/inc/TypeSerializer.hxx @@ -25,7 +25,7 @@ #include #include -class TypeSerializer : public tools::GenericTypeSerializer +class VCL_DLLPUBLIC TypeSerializer : public tools::GenericTypeSerializer { public: TypeSerializer(SvStream& rStream); diff --git a/vcl/qa/cppunit/TypeSerializerTest.cxx b/vcl/qa/cppunit/TypeSerializerTest.cxx new file mode 100644 index 000000000000..cf5985211076 --- /dev/null +++ b/vcl/qa/cppunit/TypeSerializerTest.cxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include + +#include + +namespace +{ +class TypeSerializerTest : public CppUnit::TestFixture +{ + void testGradient(); + + CPPUNIT_TEST_SUITE(TypeSerializerTest); + CPPUNIT_TEST(testGradient); + CPPUNIT_TEST_SUITE_END(); +}; + +void TypeSerializerTest::testGradient() +{ + Gradient aGradient(GradientStyle::Radial, Color(0xFF, 0x00, 0x00), Color(0x00, 0xFF, 0x00)); + aGradient.SetAngle(900); + aGradient.SetBorder(5); + aGradient.SetOfsX(11); + aGradient.SetOfsY(12); + aGradient.SetStartIntensity(21); + aGradient.SetEndIntensity(22); + aGradient.SetSteps(30); + + SvMemoryStream aStream; + TypeSerializer aSerializer(aStream); + aSerializer.writeGradient(aGradient); + aStream.Seek(STREAM_SEEK_TO_BEGIN); + + Gradient aReadGradient; + aSerializer.readGradient(aReadGradient); + CPPUNIT_ASSERT_EQUAL(GradientStyle::Radial, aReadGradient.GetStyle()); + CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0x00, 0x00), aReadGradient.GetStartColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0x00), aReadGradient.GetEndColor()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(900), aReadGradient.GetAngle()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(5), aReadGradient.GetBorder()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(11), aReadGradient.GetOfsX()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(12), aReadGradient.GetOfsY()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(21), aReadGradient.GetStartIntensity()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(22), aReadGradient.GetEndIntensity()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), aReadGradient.GetSteps()); +} + +} // namespace + +CPPUNIT_TEST_SUITE_REGISTRATION(TypeSerializerTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit