Kaydet (Commit) 90af4f50 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

fdo#58307: Write export test for this to ensure it won't go away...

Change-Id: I01ebdfab7d6098402e2911713b0eb51e2003047c
üst 5063f31c
...@@ -569,7 +569,7 @@ public: ...@@ -569,7 +569,7 @@ public:
SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName ); SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const; SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
std::vector<OUString> GetAllTableNames() const; SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const;
OUString GetCopyTabName(SCTAB nTab) const; OUString GetCopyTabName(SCTAB nTab) const;
......
...@@ -87,6 +87,8 @@ public: ...@@ -87,6 +87,8 @@ public:
void testCellBordersXLS(); void testCellBordersXLS();
void testCellBordersXLSX(); void testCellBordersXLSX();
void testSheetTabColorsXLSX();
void testSharedFormulaExportXLS(); void testSharedFormulaExportXLS();
void testSharedFormulaExportXLSX(); void testSharedFormulaExportXLSX();
void testSharedFormulaStringResultExportXLSX(); void testSharedFormulaStringResultExportXLSX();
...@@ -114,6 +116,7 @@ public: ...@@ -114,6 +116,7 @@ public:
CPPUNIT_TEST(testSheetProtectionXLSX); CPPUNIT_TEST(testSheetProtectionXLSX);
CPPUNIT_TEST(testCellBordersXLS); CPPUNIT_TEST(testCellBordersXLS);
CPPUNIT_TEST(testCellBordersXLSX); CPPUNIT_TEST(testCellBordersXLSX);
CPPUNIT_TEST(testSheetTabColorsXLSX);
CPPUNIT_TEST(testSharedFormulaExportXLS); CPPUNIT_TEST(testSharedFormulaExportXLS);
CPPUNIT_TEST(testSharedFormulaExportXLSX); CPPUNIT_TEST(testSharedFormulaExportXLSX);
CPPUNIT_TEST(testSharedFormulaStringResultExportXLSX); CPPUNIT_TEST(testSharedFormulaStringResultExportXLSX);
...@@ -1089,6 +1092,71 @@ void ScExportTest::testCellBordersXLSX() ...@@ -1089,6 +1092,71 @@ void ScExportTest::testCellBordersXLSX()
testExcelCellBorders(XLSX); testExcelCellBorders(XLSX);
} }
void ScExportTest::testSheetTabColorsXLSX()
{
struct
{
bool checkContent( ScDocument* pDoc )
{
std::vector<OUString> aTabNames = pDoc->GetAllTableNames();
// green, red, blue, yellow (from left to right).
if (aTabNames.size() != 4)
{
cerr << "There should be exactly 4 sheets." << endl;
return false;
}
const char* pNames[] = { "Green", "Red", "Blue", "Yellow" };
for (size_t i = 0, n = SAL_N_ELEMENTS(pNames); i < n; ++i)
{
OUString aExpected = OUString::createFromAscii(pNames[i]);
if (aExpected != aTabNames[i])
{
cerr << "incorrect sheet name: expected='" << aExpected <<"', actual='" << aTabNames[i] << "'" << endl;
return false;
}
}
const ColorData aXclColors[] =
{
0x0000B050, // green
0x00FF0000, // red
0x000070C0, // blue
0x00FFFF00, // yellow
};
for (size_t i = 0, n = SAL_N_ELEMENTS(aXclColors); i < n; ++i)
{
if (aXclColors[i] != pDoc->GetTabBgColor(i).GetColor())
{
cerr << "wrong sheet color for sheet " << i << endl;
return false;
}
}
return true;
}
} aTest;
ScDocShellRef xDocSh = loadDoc("sheet-tab-color.", XLSX);
CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
bool bRes = aTest.checkContent(pDoc);
CPPUNIT_ASSERT_MESSAGE("Failed on the initial content check.", bRes);
ScDocShellRef xDocSh2 = saveAndReload(xDocSh, XLSX);
CPPUNIT_ASSERT_MESSAGE("Failed to reload file.", xDocSh2.Is());
xDocSh->DoClose();
pDoc = xDocSh2->GetDocument();
bRes = aTest.checkContent(pDoc);
CPPUNIT_ASSERT_MESSAGE("Failed on the content check after reload.", bRes);
xDocSh2->DoClose();
}
void ScExportTest::testSharedFormulaExportXLS() void ScExportTest::testSharedFormulaExportXLS()
{ {
struct struct
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment