summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-11-03 21:47:51 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-11-03 22:06:30 +0100
commit9249958a587d773566b88d24bc907028d8553b85 (patch)
tree5dd617748539dc48a1b0b1ba6c42c0d3b84b33c6 /sc/qa/unit
parent910bbf6f1e4c6bed983b51bc611b25a119960809 (diff)
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
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/data/ods/password.odsbin0 -> 10042 bytes
-rw-r--r--sc/qa/unit/filters-test.cxx40
2 files changed, 40 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/password.ods b/sc/qa/unit/data/ods/password.ods
new file mode 100644
index 000000000000..28c5f4940a40
--- /dev/null
+++ b/sc/qa/unit/data/ods/password.ods
Binary files differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index b9e9e239218c..487ee2237009 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"))
{