diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-09-06 21:53:39 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-09-06 23:53:43 +0200 |
commit | 4432b06ff40146352a4d21f8b4d612bcc72d7176 (patch) | |
tree | 9706240405ef64521deeefdb291cc066c50f791a | |
parent | 67b374980f340faa2695001984aaf98886a32fad (diff) |
initital work for a unit test for calc's basic features
the SC_DLLPUBLIC changes in document.hxx are only necessary until we can
link statically against sc
-rw-r--r-- | sc/inc/document.hxx | 4 | ||||
-rw-r--r-- | sc/qa/unit/data/ods/universal-content.ods | bin | 0 -> 8764 bytes | |||
-rw-r--r-- | sc/qa/unit/filters-test.cxx | 63 |
3 files changed, 59 insertions, 8 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index a73a39183699..53d796d3d80b 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -801,7 +801,7 @@ public: sal_Bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; /** Returns the pointer to a cell note object at the passed cell address. */ - ScPostIt* GetNote( const ScAddress& rPos ); + SC_DLLPUBLIC ScPostIt* GetNote( const ScAddress& rPos ); /** Sets the passed note at the cell with the passed cell address. */ void TakeNote( const ScAddress& rPos, ScPostIt*& rpNote ); /** Returns and forgets the cell note object at the passed cell address. */ @@ -822,7 +822,7 @@ public: sal_Bool ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark, sal_Bool bRefresh = false ); - sal_Bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow, + SC_DLLPUBLIC sal_Bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab, sal_Bool bRefresh = false ); sal_Bool ExtendMerge( ScRange& rRange, sal_Bool bRefresh = false ); diff --git a/sc/qa/unit/data/ods/universal-content.ods b/sc/qa/unit/data/ods/universal-content.ods Binary files differnew file mode 100644 index 000000000000..f3a23a94965a --- /dev/null +++ b/sc/qa/unit/data/ods/universal-content.ods diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 087e26c8e78e..b0b01a3df2b3 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -56,6 +56,8 @@ #include <sfx2/sfxmodelfactory.hxx> #include "docsh.hxx" +#include "document.hxx" +#include "postit.hxx" const int indeterminate = 2; @@ -82,11 +84,14 @@ public: */ void testCVEs(); - void testODSs(); + //ods filter tests + void testRangeName(); + void testContent(); CPPUNIT_TEST_SUITE(FiltersTest); CPPUNIT_TEST(testCVEs); - CPPUNIT_TEST(testODSs); + CPPUNIT_TEST(testRangeName); + CPPUNIT_TEST(testContent); CPPUNIT_TEST_SUITE_END(); private: @@ -190,13 +195,13 @@ void FiltersTest::testCVEs() } -void FiltersTest::testODSs() +void FiltersTest::testRangeName() { - rtl::OUString aString1(RTL_CONSTASCII_USTRINGPARAM("calc8")); - rtl::OUString aString2 = m_aSrcRoot + rtl::OUString( + rtl::OUString aFilter(RTL_CONSTASCII_USTRINGPARAM("calc8")); + rtl::OUString aFileName = m_aSrcRoot + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data/ods/named-ranges-global.ods")); - ScDocShellRef xDocSh = load( aString1, aString2 , rtl::OUString(), ODS_FORMAT_TYPE); + ScDocShellRef xDocSh = load( aFilter, aFileName , rtl::OUString(), ODS_FORMAT_TYPE); CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-global.ods.", xDocSh.Is()); @@ -227,6 +232,52 @@ void FiltersTest::testODSs() CPPUNIT_ASSERT_MESSAGE("range name Sheet2.local1 should reference Sheet1.A5", aValue == 5); } +void FiltersTest::testContent() +{ + //this test checks for some basic functions in calc import + rtl::OUString aFilterName(RTL_CONSTASCII_USTRINGPARAM("calc8")); + rtl::OUString aFileName = m_aSrcRoot + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data/ods/universal-content.ods")); + ScDocShellRef xDocSh = load ( aFilterName, aFileName, rtl::OUString(), ODS_FORMAT_TYPE); + + CPPUNIT_ASSERT_MESSAGE("Failed to load universal-content.ods", xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + double aValue; + //check value import + pDoc->GetValue(0,0,0,aValue); + CPPUNIT_ASSERT_MESSAGE("value not imported correctly", aValue == 1); + pDoc->GetValue(0,1,0,aValue); + CPPUNIT_ASSERT_MESSAGE("value not imported correctly", aValue == 2); + rtl::OUString aString; + pDoc->GetString(1,0,0,aString); + //check string import + CPPUNIT_ASSERT_MESSAGE("string imported not correctly", aString == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("String1"))); + pDoc->GetString(1,1,0,aString); + CPPUNIT_ASSERT_MESSAGE("string not imported correctly", aString == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("String2"))); + //check basic formula import + pDoc->GetValue(2,0,0,aValue); + CPPUNIT_ASSERT_MESSAGE("=2*3", aValue==6); + pDoc->GetValue(2,1,0,aValue); + CPPUNIT_ASSERT_MESSAGE("=2+3", aValue==5); + pDoc->GetValue(2,2,0,aValue); + CPPUNIT_ASSERT_MESSAGE("=2-3", aValue==-1); + pDoc->GetValue(2,3,0,aValue); + CPPUNIT_ASSERT_MESSAGE("=C1+C2", aValue==11); + //check merged cells import + SCCOL nCol = 4; + SCROW nRow = 1; + pDoc->ExtendMerge(4, 1, nCol, nRow, 0, false); + std::cout << nCol << " " << nRow << std::endl; + CPPUNIT_ASSERT_MESSAGE("merged cells are not imported", nCol == 5 && nRow == 2); + //check notes import + ScAddress aAddress(7, 2, 0); + ScPostIt* pNote = pDoc->GetNote(aAddress); + CPPUNIT_ASSERT_MESSAGE("note not imported", pNote); + CPPUNIT_ASSERT_MESSAGE("note text not imported correctly", pNote->GetText() == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test"))); + //add additional checks here +} + FiltersTest::FiltersTest() : m_aSrcRoot(RTL_CONSTASCII_USTRINGPARAM("file://")) { |