diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-11-18 00:40:46 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-11-18 22:34:12 +0100 |
commit | 21c437d17b20d72823cdd617785462e342326e28 (patch) | |
tree | c9571d713924a7ef8dcca3ab75456ea55ca3b289 /sc | |
parent | 5455ffb97e93a88d6cf9d471d20566897595b7b8 (diff) |
allow testing of bugfiles in sc's filters-test
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/filters-test.cxx | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index bcda710655d1..03d35c4c4993 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -43,6 +43,7 @@ #include <editeng/justifyitem.hxx> #define CALC_DEBUG_OUTPUT 0 +#define TEST_BUG_FILES 0 #include "helper/csv_handler.hxx" #include "helper/debughelper.hxx" @@ -95,6 +96,8 @@ void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType aConfig.delimiters.push_back(','); aConfig.delimiters.push_back(';'); aConfig.text_qualifier = '"'; + + std::string aContent; loadFile(aFileName, aContent); orcus::csv_parser<csv_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig); @@ -176,6 +179,13 @@ public: //misc tests unrelated to the import filters void testPassword(); +#if TEST_BUG_FILES + //test Bug Files and search for files that crash LibO + void testBugFiles(); + void testBugFilesXLS(); + void testBugFilesXLSX(); +#endif + CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCVEs); CPPUNIT_TEST(testRangeName); @@ -189,6 +199,11 @@ public: CPPUNIT_TEST(testBugFixesXLSX); CPPUNIT_TEST(testPassword); +#if TEST_BUG_FILES + CPPUNIT_TEST(testBugFiles); + CPPUNIT_TEST(testBugFilesXLS); + CPPUNIT_TEST(testBugFilesXLSX); +#endif CPPUNIT_TEST_SUITE_END(); private: @@ -261,6 +276,82 @@ void ScFiltersTest::testCVEs() getURLFromSrc("/sc/qa/unit/data/slk/"), rtl::OUString()); } +#if TEST_BUG_FILES + +void ScFiltersTest::testBugFiles() +{ + rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ; + rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8); + rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugODS/"); + osl::Directory aDir(aDirName); + + CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open()); + osl::DirectoryItem aItem; + osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type); + while (aDir.getNextItem(aItem) == osl::FileBase::E_None) + { + aItem.getFileStatus(aFileStatus); + rtl::OUString sURL = aFileStatus.getFileURL(); + std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; + rtl::OStringBuffer aMessage("Failed loading: "); + aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8)); + ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[0].nFormatType); + //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is()); + if (xDocSh.Is()) + xDocSh->DoClose(); + } +} + +void ScFiltersTest::testBugFilesXLS() +{ + rtl::OUString aFilterName(aFileFormats[1].pFilterName, strlen(aFileFormats[1].pFilterName), RTL_TEXTENCODING_UTF8) ; + rtl::OUString aFilterType(aFileFormats[1].pTypeName, strlen(aFileFormats[1].pTypeName), RTL_TEXTENCODING_UTF8); + rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLS/"); + osl::Directory aDir(aDirName); + + CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open()); + osl::DirectoryItem aItem; + osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type); + while (aDir.getNextItem(aItem) == osl::FileBase::E_None) + { + aItem.getFileStatus(aFileStatus); + rtl::OUString sURL = aFileStatus.getFileURL(); + std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; + rtl::OStringBuffer aMessage("Failed loading: "); + aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8)); + ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[1].nFormatType); + //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is()); + if (xDocSh.Is()) + xDocSh->DoClose(); + } +} + +void ScFiltersTest::testBugFilesXLSX() +{ + rtl::OUString aFilterName(aFileFormats[2].pFilterName, strlen(aFileFormats[2].pFilterName), RTL_TEXTENCODING_UTF8) ; + rtl::OUString aFilterType(aFileFormats[2].pTypeName, strlen(aFileFormats[2].pTypeName), RTL_TEXTENCODING_UTF8); + rtl::OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLSX/"); + osl::Directory aDir(aDirName); + + CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open()); + osl::DirectoryItem aItem; + osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type); + while (aDir.getNextItem(aItem) == osl::FileBase::E_None) + { + aItem.getFileStatus(aFileStatus); + rtl::OUString sURL = aFileStatus.getFileURL(); + std::cout << "File: " << rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; + rtl::OStringBuffer aMessage("Failed loading: "); + aMessage.append(rtl::OUStringToOString(sURL, RTL_TEXTENCODING_UTF8)); + ScDocShellRef xDocSh = load( aFilterName,sURL, rtl::OUString(),aFilterType, aFileFormats[2].nFormatType); + //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is()); + if (xDocSh.Is()) + xDocSh->DoClose(); + } +} + +#endif + namespace { void testRangeNameImpl(ScDocument* pDoc) |