diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-02-11 15:05:24 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-02-11 17:21:59 +0100 |
commit | 423fb7b73673cb0fa19359bcdbe0156dcc34b01c (patch) | |
tree | 8adb3a105e3b9f2a7fff180338c6051877353a53 /sc/qa | |
parent | 484a5dcc0e0b749f58d631b957fb6f380160b7a3 (diff) |
refactor filters-test and move each test in own method
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/filters-test.cxx | 107 |
1 files changed, 63 insertions, 44 deletions
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 3697c39cf86b..4e40f57f521a 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -102,8 +102,10 @@ public: void testCVEs(); //ods, xls, xlsx filter tests - void testRangeName(); // only test ods here, xls and xlsx in subsequent_filters-test - void testContent(); + void testRangeNameODS(); // only test ods here, xls and xlsx in subsequent_filters-test + void testContentODS(); + void testContentXLS(); + void testContentXLSX(); #if TEST_BUG_FILES //goes recursively through all files in this dir and tries to open them @@ -116,8 +118,10 @@ public: CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCVEs); - CPPUNIT_TEST(testRangeName); - CPPUNIT_TEST(testContent); + CPPUNIT_TEST(testRangeNameODS); + CPPUNIT_TEST(testContentODS); + CPPUNIT_TEST(testContentXLS); + CPPUNIT_TEST(testContentXLSX); #if TEST_BUG_FILES CPPUNIT_TEST(testBugFiles); @@ -127,6 +131,7 @@ public: CPPUNIT_TEST_SUITE_END(); private: + ScDocShellRef loadDoc(const rtl::OUString& rName, sal_Int32 nFormat); uno::Reference<uno::XInterface> m_xCalcComponent; ::rtl::OUString m_aBaseString; }; @@ -278,31 +283,33 @@ void testRangeNameImpl(ScDocument* pDoc) } -void ScFiltersTest::testRangeName() +ScDocShellRef ScFiltersTest::loadDoc(const rtl::OUString& rName, sal_Int32 nFormat) +{ + rtl::OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 ); + rtl::OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; + rtl::OUString aFileName; + createFileURL( rName, aFileExtension, aFileName ); + rtl::OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); + ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[nFormat].nFormatType); + CPPUNIT_ASSERT(xDocSh.Is()); + return xDocSh; +} + +void ScFiltersTest::testRangeNameODS() { const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("named-ranges-global.")); - //XLSX does not work yet - for (sal_uInt32 i = 0; i < 1; ++i) - { - rtl::OUString aFileExtension(aFileFormats[i].pName, strlen(aFileFormats[i].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[i].pFilterName, strlen(aFileFormats[i].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; - createFileURL( aFileNameBase, aFileExtension, aFileName ); - rtl::OUString aFilterType(aFileFormats[i].pTypeName, strlen(aFileFormats[i].pTypeName), RTL_TEXTENCODING_UTF8); - std::cout << aFileFormats[i].pName << " Test" << std::endl; - ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[i].nFormatType); - xDocSh->DoHardRecalc(true); - - CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-globals.*", xDocSh.Is()); - ScDocument* pDoc = xDocSh->GetDocument(); - testRangeNameImpl(pDoc); - - rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2.")); - rtl::OUString aCSVPath; - createCSVPath( aSheet2CSV, aCSVPath ); - testFile( aCSVPath, pDoc, 1); - xDocSh->DoClose(); - } + ScDocShellRef xDocSh = loadDoc(aFileNameBase, 1); + xDocSh->DoHardRecalc(true); + + CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-globals.*", xDocSh.Is()); + ScDocument* pDoc = xDocSh->GetDocument(); + testRangeNameImpl(pDoc); + + rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2.")); + rtl::OUString aCSVPath; + createCSVPath( aSheet2CSV, aCSVPath ); + testFile( aCSVPath, pDoc, 1); + xDocSh->DoClose(); } namespace { @@ -345,25 +352,37 @@ void testContentImpl(ScDocument* pDoc) //same code for ods, xls, xlsx } -void ScFiltersTest::testContent() +void ScFiltersTest::testContentODS() { const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("universal-content.")); - for (sal_uInt32 i = 0; i < 3; ++i) - { - rtl::OUString aFileExtension(aFileFormats[i].pName, strlen(aFileFormats[i].pName), RTL_TEXTENCODING_UTF8 ); - rtl::OUString aFilterName(aFileFormats[i].pFilterName, strlen(aFileFormats[i].pFilterName), RTL_TEXTENCODING_UTF8) ; - rtl::OUString aFileName; - createFileURL(aFileNameBase, aFileExtension, aFileName); - rtl::OUString aFilterType(aFileFormats[i].pTypeName, strlen(aFileFormats[i].pTypeName), RTL_TEXTENCODING_UTF8); - std::cout << aFileFormats[i].pName << " Test" << std::endl; - ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[i].nFormatType); - xDocSh->DoHardRecalc(true); - - CPPUNIT_ASSERT_MESSAGE("Failed to load universal-content.*", xDocSh.Is()); - ScDocument* pDoc = xDocSh->GetDocument(); - testContentImpl(pDoc); - xDocSh->DoClose(); - } + ScDocShellRef xDocSh = loadDoc(aFileNameBase, 0); + xDocSh->DoHardRecalc(true); + + ScDocument* pDoc = xDocSh->GetDocument(); + testContentImpl(pDoc); + xDocSh->DoClose(); +} + +void ScFiltersTest::testContentXLS() +{ + const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("universal-content.")); + ScDocShellRef xDocSh = loadDoc(aFileNameBase, 1); + xDocSh->DoHardRecalc(true); + + ScDocument* pDoc = xDocSh->GetDocument(); + testContentImpl(pDoc); + xDocSh->DoClose(); +} + +void ScFiltersTest::testContentXLSX() +{ + const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("universal-content.")); + ScDocShellRef xDocSh = loadDoc(aFileNameBase, 2); + xDocSh->DoHardRecalc(true); + + ScDocument* pDoc = xDocSh->GetDocument(); + testContentImpl(pDoc); + xDocSh->DoClose(); } ScFiltersTest::ScFiltersTest() |