diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-10-15 10:15:32 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-10-29 07:12:14 +0100 |
commit | d2242cb1b88cc7d7af1990965925d19557b9f347 (patch) | |
tree | a977db4cb3ac153a60bddb1a1b0f2e0480f024ff /desktop | |
parent | 2077c5e4e10a8254206945520f084e6216464d6a (diff) |
lokit: test for the new signing API functions
Change-Id: I3ab2f3986955eb82451704fc2386b64f208da554
Reviewed-on: https://gerrit.libreoffice.org/61782
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/CppunitTest_desktop_lib.mk | 33 | ||||
-rw-r--r-- | desktop/qa/data/certificate.der | bin | 0 -> 1306 bytes | |||
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 43 |
3 files changed, 45 insertions, 31 deletions
diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk index d0cc7f829cb8..b25ab04bda8d 100644 --- a/desktop/CppunitTest_desktop_lib.mk +++ b/desktop/CppunitTest_desktop_lib.mk @@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,desktop_lib, \ test \ unotest \ utl \ + tl \ vcl \ )) @@ -48,37 +49,7 @@ $(eval $(call gb_CppunitTest_use_ure,desktop_lib)) $(eval $(call gb_CppunitTest_use_vcl,desktop_lib)) -$(eval $(call gb_CppunitTest_use_components,desktop_lib,\ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - dtrans/util/mcnttype \ - filter/source/config/cache/filterconfig1 \ - filter/source/storagefilterdetect/storagefd \ - framework/util/fwk \ - i18npool/util/i18npool \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - sfx2/util/sfx \ - svl/source/fsstor/fsstorage \ - svtools/util/svt \ - sw/util/sw \ - sw/util/swd \ - sc/util/sc \ - sc/util/scd \ - sd/util/sd \ - sd/util/sdd \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - unoxml/source/service/unoxml \ - uui/util/uui \ - vcl/vcl.common \ - xmloff/util/xo \ - i18npool/source/search/i18nsearch \ - filter/source/graphic/graphicfilter \ - linguistic/source/lng \ -)) +$(eval $(call gb_CppunitTest_use_rdb,desktop_lib,services)) $(eval $(call gb_CppunitTest_use_configuration,desktop_lib)) diff --git a/desktop/qa/data/certificate.der b/desktop/qa/data/certificate.der Binary files differnew file mode 100644 index 000000000000..2a750ab281af --- /dev/null +++ b/desktop/qa/data/certificate.der diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 9a8d7b88b0b7..bd8b08f9fac8 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -19,6 +19,8 @@ #include <com/sun/star/text/TextContentAnchorType.hpp> #include <boost/property_tree/json_parser.hpp> +#include <com/sun/star/frame/XStorable.hpp> + #include <vcl/scheduler.hxx> #include <comphelper/processfactory.hxx> #include <rtl/uri.hxx> @@ -116,6 +118,8 @@ public: void testCommentsCallbacksWriter(); void testRunMacro(); void testExtractParameter(); + void testGetSignatureState(); + void testInsertCertificate(); void testABI(); CPPUNIT_TEST_SUITE(DesktopLOKTest); @@ -159,6 +163,8 @@ public: CPPUNIT_TEST(testCommentsCallbacksWriter); CPPUNIT_TEST(testRunMacro); CPPUNIT_TEST(testExtractParameter); + CPPUNIT_TEST(testGetSignatureState); + CPPUNIT_TEST(testInsertCertificate); CPPUNIT_TEST(testABI); CPPUNIT_TEST_SUITE_END(); @@ -2240,6 +2246,43 @@ void DesktopLOKTest::testExtractParameter() comphelper::LibreOfficeKit::setActive(false); } +void DesktopLOKTest::testGetSignatureState() +{ + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); + Scheduler::ProcessEventsToIdle(); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); + CPPUNIT_ASSERT_EQUAL(int(0), nState); + comphelper::LibreOfficeKit::setActive(false); +} + +void DesktopLOKTest::testInsertCertificate() +{ + comphelper::LibreOfficeKit::setActive(); + + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); + + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(mxComponent.is()); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + + OUString aFileURL; + createFileURL("certificate.der", aFileURL); + + SvFileStream aStream(aFileURL, StreamMode::READ); + sal_uInt64 nSize = aStream.remainingSize(); + + std::vector<unsigned char> aCertificate; + aCertificate.resize(nSize); + aStream.ReadBytes(aCertificate.data(), nSize); + + bool bResult = pDocument->m_pDocumentClass->insertCertificate(pDocument, aCertificate.data(), int(aCertificate.size())); + CPPUNIT_ASSERT(bResult); + + comphelper::LibreOfficeKit::setActive(false); +} + namespace { constexpr size_t documentClassOffset(int i) |