summaryrefslogtreecommitdiff
path: root/sfx2/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-01-12 14:32:21 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-01-12 21:39:28 +0100
commita746f20cae91a87b8263342fb558a12f2f0d50b2 (patch)
tree67bd2969c8d1d307ddec1c821b70617f4a6874f5 /sfx2/qa
parentcab0427cadddb3aaf1349c66f2fa13a4234ba4b2 (diff)
sfx2 store: add API to allow disabling thumbnails only for a single save
This is similar to the officecfg::Office::Common::Save::Document::GenerateThumbnail config setting, but here we allow configuring this at a per-save basis, not persistently. Change-Id: Ieb5bd57f1d8fc9e211011f2647276d985cf53131 Reviewed-on: https://gerrit.libreoffice.org/47812 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sfx2/qa')
-rw-r--r--sfx2/qa/cppunit/misc/hello.odtbin0 -> 8159 bytes
-rw-r--r--sfx2/qa/cppunit/test_misc.cxx38
2 files changed, 38 insertions, 0 deletions
diff --git a/sfx2/qa/cppunit/misc/hello.odt b/sfx2/qa/cppunit/misc/hello.odt
new file mode 100644
index 000000000000..23ce6a4db9af
--- /dev/null
+++ b/sfx2/qa/cppunit/misc/hello.odt
Binary files differ
diff --git a/sfx2/qa/cppunit/test_misc.cxx b/sfx2/qa/cppunit/test_misc.cxx
index e3cbd8d4748c..5f36b438f089 100644
--- a/sfx2/qa/cppunit/test_misc.cxx
+++ b/sfx2/qa/cppunit/test_misc.cxx
@@ -20,11 +20,17 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
#include <test/bootstrapfixture.hxx>
#include <test/xmltesttools.hxx>
+#include <unotest/macros_test.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/processfactory.hxx>
+#include <sfx2/app.hxx>
using namespace ::com::sun::star;
@@ -34,10 +40,13 @@ namespace {
class MiscTest
: public test::BootstrapFixture
+ , public unotest::MacrosTest
, public XmlTestTools
{
public:
+ virtual void setUp() override;
void testODFCustomMetadata();
+ void testNoThumbnail();
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override
{
@@ -52,11 +61,19 @@ public:
CPPUNIT_TEST_SUITE(MiscTest);
CPPUNIT_TEST(testODFCustomMetadata);
+ CPPUNIT_TEST(testNoThumbnail);
CPPUNIT_TEST_SUITE_END();
private:
};
+void MiscTest::setUp()
+{
+ m_xContext = comphelper::getProcessComponentContext();
+ mxDesktop.set(frame::Desktop::create(m_xContext));
+ SfxApplication::GetOrCreate();
+}
+
void MiscTest::testODFCustomMetadata()
{
uno::Reference<document::XDocumentProperties> const xProps(
@@ -86,6 +103,27 @@ void MiscTest::testODFCustomMetadata()
aTempFile.EnableKillingFile();
}
+void MiscTest::testNoThumbnail()
+{
+ // Load a document.
+ const OUString aURL(m_directories.getURLFromSrc("/sfx2/qa/cppunit/misc/hello.odt"));
+ uno::Reference<lang::XComponent> xComponent
+ = loadFromDesktop(aURL, "com.sun.star.text.TextDocument");
+ CPPUNIT_ASSERT(xComponent.is());
+
+ // Save it with the NoThumbnail option and assert that it has no thumbnail.
+ uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xStorable.is());
+ utl::TempFile aTempFile;
+ uno::Sequence<beans::PropertyValue> aProperties(
+ comphelper::InitPropertySequence({ { "NoThumbnail", uno::makeAny(true) } }));
+ xStorable->storeToURL(aTempFile.GetURL(), aProperties);
+ uno::Reference<packages::zip::XZipFileAccess2> xZipFile
+ = packages::zip::ZipFileAccess::createWithURL(m_xContext, aTempFile.GetURL());
+ CPPUNIT_ASSERT(!xZipFile->hasByName("Thumbnails/thumbnail.png"));
+
+ xComponent->dispose();
+}
CPPUNIT_TEST_SUITE_REGISTRATION(MiscTest);