Kaydet (Commit) f6b9e4a8 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

lok: Unit test for passing table borders via jsonToPropertyValuesVector.

Change-Id: Iadc0d76a1903d76fcd84f316d4796cc1dec13277
Reviewed-on: https://gerrit.libreoffice.org/56150
Tested-by: Jenkins
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 666edd05
......@@ -19,6 +19,8 @@ $(eval $(call gb_CppunitTest_use_external,desktop_lok_init,boost_headers))
$(eval $(call gb_CppunitTest_use_sdk_api,desktop_lok_init))
$(eval $(call gb_CppunitTest_use_ure,desktop_lok_init))
$(eval $(call gb_CppunitTest_set_include,desktop_lok_init,\
-I$(SRCDIR)/desktop/source/inc \
-I$(SRCDIR)/desktop/inc \
......
......@@ -18,12 +18,13 @@
#include <string>
#include <stdio.h>
#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <vcl/scheduler.hxx>
#include <tools/color.hxx>
#include <lib/init.hxx>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/table/BorderLineStyle.hpp>
using namespace css;
/// Unit tests for desktop/source/lib/init.cxx internals.
......@@ -33,9 +34,11 @@ public:
LOKInitTest() {}
void testJsonToPropertyValues();
void testJsonToPropertyValuesBorder();
CPPUNIT_TEST_SUITE(LOKInitTest);
CPPUNIT_TEST(testJsonToPropertyValues);
CPPUNIT_TEST(testJsonToPropertyValuesBorder);
CPPUNIT_TEST_SUITE_END();
};
......@@ -71,6 +74,96 @@ void LOKInitTest::testJsonToPropertyValues()
aArgs, comphelper::containerToSequence(desktop::jsonToPropertyValuesVector(arguments)));
}
void LOKInitTest::testJsonToPropertyValuesBorder()
{
const char arguments[]
= "{"
"\"OuterBorder\": {"
"\"type\" : \"[]any\","
"\"value\" : ["
"{ \"type\" : \"com.sun.star.table.BorderLine2\", \"value\" : { \"Color\" : { \"type\" : "
"\"com.sun.star.util.Color\", \"value\" : 0 }, \"InnerLineWidth\" : { \"type\" : "
"\"short\", \"value\" : 0 }, \"OuterLineWidth\" : { \"type\" : \"short\", \"value\" : 1 "
"}, \"LineDistance\" : { \"type\" : \"short\", \"value\" : 0 }, \"LineStyle\" : { "
"\"type\" : \"short\", \"value\" : 0 }, \"LineWidth\" : { \"type\" : \"unsigned long\", "
"\"value\" : 1 } } },"
"{ \"type\" : \"com.sun.star.table.BorderLine2\", \"value\" : { \"Color\" : { \"type\" : "
"\"com.sun.star.util.Color\", \"value\" : 0 }, \"InnerLineWidth\" : { \"type\" : "
"\"short\", \"value\" : 0 }, \"OuterLineWidth\" : { \"type\" : \"short\", \"value\" : 1 "
"}, \"LineDistance\" : { \"type\" : \"short\", \"value\" : 0 }, \"LineStyle\" : { "
"\"type\" : \"short\", \"value\" : 0 }, \"LineWidth\" : { \"type\" : \"unsigned long\", "
"\"value\" : 1 } } },"
"{ \"type\" : \"com.sun.star.table.BorderLine2\", \"value\" : { \"Color\" : { \"type\" : "
"\"com.sun.star.util.Color\", \"value\" : 0 }, \"InnerLineWidth\" : { \"type\" : "
"\"short\", \"value\" : 0 }, \"OuterLineWidth\" : { \"type\" : \"short\", \"value\" : 1 "
"}, \"LineDistance\" : { \"type\" : \"short\", \"value\" : 0 }, \"LineStyle\" : { "
"\"type\" : \"short\", \"value\" : 0 }, \"LineWidth\" : { \"type\" : \"unsigned long\", "
"\"value\" : 1 } } },"
"{ \"type\" : \"com.sun.star.table.BorderLine2\", \"value\" : { \"Color\" : { \"type\" : "
"\"com.sun.star.util.Color\", \"value\" : 0 }, \"InnerLineWidth\" : { \"type\" : "
"\"short\", \"value\" : 0 }, \"OuterLineWidth\" : { \"type\" : \"short\", \"value\" : 1 "
"}, \"LineDistance\" : { \"type\" : \"short\", \"value\" : 0 }, \"LineStyle\" : { "
"\"type\" : \"short\", \"value\" : 0 }, \"LineWidth\" : { \"type\" : \"unsigned long\", "
"\"value\" : 1 } } },"
"{ \"type\" : \"long\", \"value\" : 0 },"
"{ \"type\" : \"long\", \"value\" : 0 },"
"{ \"type\" : \"long\", \"value\" : 0 },"
"{ \"type\" : \"long\", \"value\" : 0 },"
"{ \"type\" : \"long\", \"value\" : 0 }"
"]"
"},"
"\"InnerBorder\":{"
"\"type\" : \"[]any\","
"\"value\" : ["
"{ \"type\" : \"com.sun.star.table.BorderLine2\", \"value\" : { \"Color\" : { \"type\" : "
"\"com.sun.star.util.Color\", \"value\" : 0 }, \"InnerLineWidth\" : { \"type\" : "
"\"short\", \"value\" : 0 }, \"OuterLineWidth\" : { \"type\" : \"short\", \"value\" : 1 "
"}, \"LineDistance\" : { \"type\" : \"short\", \"value\" : 0 }, \"LineStyle\" : { "
"\"type\" : \"short\", \"value\" : 0 }, \"LineWidth\" : { \"type\" : \"unsigned long\", "
"\"value\" : 1 } } },"
"{ \"type\" : \"com.sun.star.table.BorderLine2\", \"value\" : { \"Color\" : { \"type\" : "
"\"com.sun.star.util.Color\", \"value\" : 0 }, \"InnerLineWidth\" : { \"type\" : "
"\"short\", \"value\" : 0 }, \"OuterLineWidth\" : { \"type\" : \"short\", \"value\" : 1 "
"}, \"LineDistance\" : { \"type\" : \"short\", \"value\" : 0 }, \"LineStyle\" : { "
"\"type\" : \"short\", \"value\" : 0 }, \"LineWidth\" : { \"type\" : \"unsigned long\", "
"\"value\" : 1 } } },"
"{ \"type\" : \"short\", \"value\" : 0 },"
"{ \"type\" : \"short\", \"value\" : 127 },"
"{ \"type\" : \"long\", \"value\" : 0 }"
"]"
"}}";
// see SvxBoxItem::QueryValue for details
uno::Sequence<uno::Any> aOuterSeq(9);
table::BorderLine2 aLine(sal_Int32(COL_BLACK), 0, 1, 0, table::BorderLineStyle::SOLID, 1);
aOuterSeq[0] <<= aLine; // left
aOuterSeq[1] <<= aLine; // right
aOuterSeq[2] <<= aLine; // bottom
aOuterSeq[3] <<= aLine; // top
aOuterSeq[4] <<= static_cast<sal_Int32>(0);
aOuterSeq[5] <<= static_cast<sal_Int32>(0);
aOuterSeq[6] <<= static_cast<sal_Int32>(0);
aOuterSeq[7] <<= static_cast<sal_Int32>(0);
aOuterSeq[8] <<= static_cast<sal_Int32>(0);
// see SvxBoxInfoItem::QueryValue() for details
uno::Sequence<uno::Any> aInnerSeq(5);
aInnerSeq[0] <<= aLine; // horizontal
aInnerSeq[1] <<= aLine; // vertical
aInnerSeq[2] <<= static_cast<sal_Int16>(0);
aInnerSeq[3] <<= static_cast<sal_Int16>(0x7F);
aInnerSeq[4] <<= static_cast<sal_Int32>(0);
uno::Sequence<beans::PropertyValue> aArgs(2);
aArgs[0].Name = "OuterBorder";
aArgs[0].Value <<= aOuterSeq;
aArgs[1].Name = "InnerBorder";
aArgs[1].Value <<= aInnerSeq;
assertSequencesEqual(
aArgs, comphelper::containerToSequence(desktop::jsonToPropertyValuesVector(arguments)));
}
CPPUNIT_TEST_SUITE_REGISTRATION(LOKInitTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment