[Libreoffice-commits] .: 2 commits - sc/qa sc/RdbTarget_sc_filters_test.mk

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Thu Nov 3 14:06:57 PDT 2011


 sc/RdbTarget_sc_filters_test.mk  |    3 ++
 sc/qa/unit/data/ods/password.ods |binary
 sc/qa/unit/filters-test.cxx      |   40 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

New commits:
commit 0920750899539e8988cf11ff9a7b76eb44ca3f2e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Nov 3 22:04:28 2011 +0100

    component files for password test
    
    if this breaks a --disable-nss build please revert this patch

diff --git a/sc/RdbTarget_sc_filters_test.mk b/sc/RdbTarget_sc_filters_test.mk
index 827f66c..2c0cb1b 100644
--- a/sc/RdbTarget_sc_filters_test.mk
+++ b/sc/RdbTarget_sc_filters_test.mk
@@ -55,6 +55,9 @@ $(eval $(call gb_RdbTarget_add_components,sc_filters_test,\
     unotools/util/utl \
     unoxml/source/rdf/unordf \
     unoxml/source/service/unoxml \
+    xmlsecurity/util/xsec_xmlsec \
+    xmlsecurity/util/xsec_fw \
+    xmlsecurity/util/xmlsecurity \
 ))
 
 $(eval $(call gb_RdbTarget_add_old_components,sc_filters_test,\
commit 9249958a587d773566b88d24bc907028d8553b85
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Nov 3 21:47:51 2011 +0100

    initial work for a password test
    
    still needs work in:
    - RdbTarget_sc_filters_test -- missing component files to NSS (need to be
    conditional on nss)
    - nssinitializer.cxx:306 -- new environment variable BRAND_PROGRAM_DIR for
    $(BRAND_BASE_DIR)/program that is overriden in the unit test to
    solver/(platform)/lib
    - make the testPassword in filters-test.cxx conditional on NSS
    - LD_LIBRARY_PATH needs an additional entry for
      solver/(platform)/lib/sqlite
    
    password.ods has password test and has been created Nov, 3rd 2011 with a
    master build and should be ODF1.2 conform

diff --git a/sc/qa/unit/data/ods/password.ods b/sc/qa/unit/data/ods/password.ods
new file mode 100644
index 0000000..28c5f49
Binary files /dev/null and b/sc/qa/unit/data/ods/password.ods differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index b9e9e23..487ee22 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -38,6 +38,7 @@
 #include <sfx2/docfile.hxx>
 #include <sfx2/sfxmodelfactory.hxx>
 #include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
 
 #include <editeng/brshitem.hxx>
 #include <editeng/justifyitem.hxx>
@@ -174,6 +175,9 @@ public:
     void testBugFixesXLS();
     void testBugFixesXLSX();
 
+    //misc tests unrelated to the import filters
+    void testPassword();
+
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testCVEs);
     CPPUNIT_TEST(testRangeName);
@@ -185,6 +189,7 @@ public:
     CPPUNIT_TEST(testBugFixesODS);
     CPPUNIT_TEST(testBugFixesXLS);
     CPPUNIT_TEST(testBugFixesXLSX);
+    //CPPUNIT_TEST(testPassword);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -612,6 +617,41 @@ void ScFiltersTest::testBugFixesXLSX()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testPassword()
+{
+    const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("password."));
+    rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 );
+    rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ;
+    rtl::OUString aFileName;
+    createFileURL(aFileNameBase, aFileExtension, aFileName);
+    rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8);
+    std::cout << aFileFormats[0].pName << " Test" << std::endl;
+
+    sal_uInt32 nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
+    SfxFilter* aFilter = new SfxFilter(
+        aFilterName,
+        rtl::OUString(), aFileFormats[0].nFormatType, nFormat, aFilterType, 0, rtl::OUString(),
+        rtl::OUString(), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) );
+    aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+
+    ScDocShellRef xDocSh = new ScDocShell;
+    SfxMedium* pMedium = new SfxMedium(aFileName, STREAM_STD_READWRITE, true);
+    SfxItemSet* pSet = pMedium->GetItemSet();
+    pSet->Put(SfxStringItem(SID_PASSWORD, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test"))));
+    pMedium->SetFilter(aFilter);
+    if (!xDocSh->DoLoad(pMedium))
+    {
+        xDocSh->DoClose();
+        // load failed.
+        xDocSh.Clear();
+    }
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load password.ods", xDocSh.Is());
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data"))
 {


More information about the Libreoffice-commits mailing list