summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-03-10 15:32:33 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-03-10 17:28:53 -0400
commitc59b3d6c5c8096486730007d9b9b053793b90b1e (patch)
treeefd80c5a273bb29bdfef1f781006530092ef7d9a /sc/qa
parent3973ecfe00379e8ed81cee6c4d43601186730065 (diff)
fdo#74747: Write test for this first.
Change-Id: Ia528904405cbb698b9cf08d4a8531c60780e0d9e
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/data/xlsx/shared-formula/text-results.xlsxbin0 -> 8576 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx70
2 files changed, 70 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/shared-formula/text-results.xlsx b/sc/qa/unit/data/xlsx/shared-formula/text-results.xlsx
new file mode 100644
index 000000000000..3f59bc3bdd16
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/shared-formula/text-results.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 5eb4eca94264..b0011b33ac86 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -89,6 +89,7 @@ public:
void testSharedFormulaExportXLS();
void testSharedFormulaExportXLSX();
+ void testSharedFormulaStringResultExportXLSX();
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
@@ -115,6 +116,7 @@ public:
CPPUNIT_TEST(testCellBordersXLSX);
CPPUNIT_TEST(testSharedFormulaExportXLS);
CPPUNIT_TEST(testSharedFormulaExportXLSX);
+ CPPUNIT_TEST(testSharedFormulaStringResultExportXLSX);
CPPUNIT_TEST_SUITE_END();
@@ -1249,6 +1251,74 @@ void ScExportTest::testSharedFormulaExportXLSX()
xDocSh2->DoClose();
}
+void ScExportTest::testSharedFormulaStringResultExportXLSX()
+{
+ struct
+ {
+ bool checkContent( ScDocument* pDoc )
+ {
+ {
+ // B2:B7 should show A,B,....,F.
+ const char* expected[] = { "A", "B", "C", "D", "E", "F" };
+ for (SCROW i = 0; i <= 5; ++i)
+ {
+ ScAddress aPos(1,i+1,0);
+ OUString aStr = pDoc->GetString(aPos);
+ OUString aExpected = OUString::createFromAscii(expected[i]);
+ if (aStr != aExpected)
+ {
+ cerr << "Wrong value in B" << (i+2) << ": expected='" << aExpected << "', actual='" << aStr << "'" << endl;
+ return false;
+ }
+ }
+ }
+
+ {
+ // C2:C7 should show AA,BB,....,FF.
+ const char* expected[] = { "AA", "BB", "CC", "DD", "EE", "FF" };
+ for (SCROW i = 0; i <= 5; ++i)
+ {
+ ScAddress aPos(2,i+1,0);
+ OUString aStr = pDoc->GetString(aPos);
+ OUString aExpected = OUString::createFromAscii(expected[i]);
+ if (aStr != aExpected)
+ {
+ cerr << "Wrong value in C" << (i+2) << ": expected='" << aExpected << "', actual='" << aStr << "'" << endl;
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ } aTest;
+
+ ScDocShellRef xDocSh = loadDoc("shared-formula/text-results.", XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ // Check content without re-calculation, to test cached formula results.
+ bool bRes = aTest.checkContent(pDoc);
+ CPPUNIT_ASSERT_MESSAGE("Content check on the initial document failed.", bRes);
+
+ // Now, re-calculate and check the results.
+ pDoc->CalcAll();
+ bRes = aTest.checkContent(pDoc);
+ CPPUNIT_ASSERT_MESSAGE("Content check on the initial recalculated document failed.", bRes);
+
+ // Reload and check again.
+ ScDocShellRef xDocSh2 = saveAndReload(xDocSh, XLSX);
+ xDocSh->DoClose();
+ CPPUNIT_ASSERT_MESSAGE("Failed to re-load file.", xDocSh2.Is());
+ pDoc = xDocSh2->GetDocument();
+
+ bRes = aTest.checkContent(pDoc);
+ CPPUNIT_ASSERT_MESSAGE("Content check on the reloaded document failed.", bRes);
+
+ xDocSh2->DoClose();
+}
+
ScExportTest::ScExportTest()
: ScBootstrapFixture("/sc/qa/unit/data")
{