Kaydet (Commit) 7d754a84 authored tarafından Michael Stahl's avatar Michael Stahl

sc: ensure global variables in tests are cleared before shutdown

If the destructors run from exit handlers, they could access already
deleted globals from VCL etc. and crash.

Change-Id: I265046e95998a4384e1ce0f1f205d03c078a40a9
üst 3da82561
......@@ -105,7 +105,10 @@ void ScAnnontationObj::setUp()
void ScAnnontationObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -63,6 +63,7 @@ void ScAnnotationShapeObj::tearDown()
{
mxField.clear();
closeDocument(mxComponent);
mxComponent.clear();
}
UnoApiTest::tearDown();
......
......@@ -89,7 +89,10 @@ void ScAnnontationsObj::setUp()
void ScAnnontationsObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -119,7 +119,10 @@ void ScCellRangeObj::setUp()
void ScCellRangeObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -78,7 +78,10 @@ void ScDatabaseRangeObj::setUp()
void ScDatabaseRangeObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -94,7 +94,10 @@ void ScDataPilotFieldObj::setUp()
void ScDataPilotFieldObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -148,7 +148,10 @@ void ScDataPilotTableObj::setUp()
void ScDataPilotTableObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -87,6 +87,7 @@ void ScEditFieldObj_Cell::tearDown()
{
mxField.clear();
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
......
......@@ -85,6 +85,7 @@ void ScEditFieldObj_Header::tearDown()
mxField.clear();
mxRightText.clear();
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
......
......@@ -64,7 +64,10 @@ void ScModelObj::setUp()
void ScModelObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
UnoApiTest::tearDown();
}
......
......@@ -102,7 +102,10 @@ void ScNamedRangeObj::setUp()
void ScNamedRangeObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -80,7 +80,10 @@ void ScNamedRangesObj::setUp()
void ScNamedRangesObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -79,7 +79,10 @@ void ScOutlineObj::setUp()
void ScOutlineObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -109,9 +109,15 @@ void ScStyleLoaderObj::tearDown()
if (nTest == NUMBER_OF_TESTS)
{
if (mxSourceComponent.is())
{
closeDocument(mxSourceComponent);
mxSourceComponent.clear();
}
if (mxTargetComponent.is())
{
closeDocument(mxTargetComponent);
mxTargetComponent.clear();
}
}
CalcUnoApiTest::tearDown();
}
......
......@@ -102,7 +102,10 @@ void ScTableSheetsObj::setUp()
void ScTableSheetsObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
......
......@@ -37,12 +37,12 @@ const OUString rowLevel2 = "OutlineSheet.A3:A27";
const OUString rowLevel3 = "OutlineSheet.A5:A24";
const OUString rowLevel4 = "OutlineSheet.A7:A21";
uno::Reference< sheet::XSpreadsheet > aSheetGlobal;
OUString getVisibleAdress(const OUString& aLevelRangeString)
OUString getVisibleAdress(
uno::Reference<sheet::XSpreadsheet> const& xSheet,
const OUString& aLevelRangeString)
{
uno::Reference<table::XCellRange> aSheetRangeAccess(aSheetGlobal, UNO_QUERY_THROW);
uno::Reference<table::XCellRange> aSheetRangeAccess(xSheet, UNO_QUERY_THROW);
uno::Reference<table::XCellRange> aLevelRange = aSheetRangeAccess->getCellRangeByName(aLevelRangeString);
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(aLevelRange,UNO_QUERY_THROW);
......@@ -53,10 +53,12 @@ OUString getVisibleAdress(const OUString& aLevelRangeString)
}
table::CellRangeAddress getAddressFromRangeString(const OUString& aStringAddress)
table::CellRangeAddress getAddressFromRangeString(
uno::Reference<sheet::XSpreadsheet> const& xSheet,
const OUString& aStringAddress)
{
uno::Reference< table::XCellRange > aSheetRangeAccess(aSheetGlobal, UNO_QUERY_THROW);
uno::Reference< table::XCellRange > aSheetRangeAccess(xSheet, UNO_QUERY_THROW);
uno::Reference<table::XCellRange> aRange = aSheetRangeAccess->getCellRangeByName(aStringAddress);
uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(aRange, UNO_QUERY_THROW);
......@@ -72,19 +74,19 @@ void XSheetOutline::testHideDetail()
uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
aSheetGlobal = aSheet;
// Column level 2
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(colLevel2);
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, colLevel2);
aSheetOutline->hideDetail(aLevelRangeAddress);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Column level 2 not hidden", getVisibleAdress(colLevel2), OUString(""));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Column level 2 not hidden",
getVisibleAdress(aSheet, colLevel2), OUString(""));
// Row Level 2
aLevelRangeAddress = getAddressFromRangeString(rowLevel2);
aLevelRangeAddress = getAddressFromRangeString(aSheet, rowLevel2);
aSheetOutline->hideDetail(aLevelRangeAddress);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Row level 2 not hidden", getVisibleAdress(rowLevel2), OUString(""));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Row level 2 not hidden",
getVisibleAdress(aSheet, rowLevel2), OUString(""));
}
......@@ -93,21 +95,22 @@ void XSheetOutline::testShowDetail()
uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
aSheetGlobal = aSheet;
aSheetOutline->showDetail(getAddressFromRangeString(colLevel1));
aSheetOutline->showDetail(getAddressFromRangeString(rowLevel1));
aSheetOutline->showDetail(getAddressFromRangeString(aSheet, colLevel1));
aSheetOutline->showDetail(getAddressFromRangeString(aSheet, rowLevel1));
// Row Level 2
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(rowLevel2);
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, rowLevel2);
aSheetOutline->showDetail(aLevelRangeAddress);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Row level 2 still hidden", getVisibleAdress(rowLevel2), rowLevel2);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Row level 2 still hidden",
getVisibleAdress(aSheet, rowLevel2), rowLevel2);
// Column Level 2
aLevelRangeAddress = getAddressFromRangeString(colLevel2);
aLevelRangeAddress = getAddressFromRangeString(aSheet, colLevel2);
aSheetOutline->showDetail(aLevelRangeAddress);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Column level 2 still hidden", getVisibleAdress(colLevel2), colLevel2);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Column level 2 still hidden",
getVisibleAdress(aSheet, colLevel2), colLevel2);
}
......@@ -117,20 +120,18 @@ void XSheetOutline::testShowLevel()
uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
aSheetGlobal = aSheet;
table::CellRangeAddress aLevelRangeAddress;
// test columns
table::CellRangeAddress aLevel1 = getAddressFromRangeString(colLevel1);
table::CellRangeAddress aLevel2 = getAddressFromRangeString(colLevel2);
table::CellRangeAddress aLevel3 = getAddressFromRangeString(colLevel3);
table::CellRangeAddress aLevel4 = getAddressFromRangeString(colLevel4);
table::CellRangeAddress aLevel1 = getAddressFromRangeString(aSheet, colLevel1);
table::CellRangeAddress aLevel2 = getAddressFromRangeString(aSheet, colLevel2);
table::CellRangeAddress aLevel3 = getAddressFromRangeString(aSheet, colLevel3);
table::CellRangeAddress aLevel4 = getAddressFromRangeString(aSheet, colLevel4);
aSheetOutline->showDetail(getAddressFromRangeString(colLevel1));
aSheetOutline->showDetail(getAddressFromRangeString(colLevel2));
aSheetOutline->showDetail(getAddressFromRangeString(rowLevel1));
aSheetOutline->showDetail(getAddressFromRangeString(aSheet, colLevel1));
aSheetOutline->showDetail(getAddressFromRangeString(aSheet, colLevel2));
aSheetOutline->showDetail(getAddressFromRangeString(aSheet, rowLevel1));
aSheetOutline->hideDetail(aLevel1);
aSheetOutline->hideDetail(aLevel2);
......@@ -139,14 +140,14 @@ void XSheetOutline::testShowLevel()
aSheetOutline->showLevel(2, table::TableOrientation_COLUMNS);
std::cout << " verifiy showLevel col apres" << OUStringToOString(getVisibleAdress("OutlineSheet.A1:Z30"), RTL_TEXTENCODING_UTF8).getStr() << std::endl;
std::cout << " verifiy showLevel col apres" << OUStringToOString(getVisibleAdress(aSheet, "OutlineSheet.A1:Z30"), RTL_TEXTENCODING_UTF8).getStr() << std::endl;
// verify that level 2 and level 1 are shown --> column 0..3 & column 22..26
// level 3 & 4 are hidden --> column 4..19
CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString("OutlineSheet.A1:D1"), getVisibleAdress("OutlineSheet.A1:D1"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString("OutlineSheet.V1:Z1"), getVisibleAdress("OutlineSheet.V1:Z1"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString(""), getVisibleAdress(colLevel3));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString("OutlineSheet.A1:D1"), getVisibleAdress(aSheet, "OutlineSheet.A1:D1"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString("OutlineSheet.V1:Z1"), getVisibleAdress(aSheet, "OutlineSheet.V1:Z1"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString(""), getVisibleAdress(aSheet, colLevel3));
/* FIXME !!
......@@ -191,25 +192,23 @@ void XSheetOutline::testGroup()
uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
aSheetGlobal = aSheet;
// Column level 2
OUString aNewString = "OutlineSheet.AB1:AG1";
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aNewString);
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_COLUMNS);
aSheetOutline->hideDetail(aLevelRangeAddress);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testGroup Column still visible", getVisibleAdress(aNewString), OUString(""));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testGroup Column still visible", getVisibleAdress(aSheet, aNewString), OUString(""));
// Row Level 2
aNewString = "OutlineSheet.A50:A60";
aLevelRangeAddress = getAddressFromRangeString(aNewString);
aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_ROWS);
aSheetOutline->hideDetail(aLevelRangeAddress);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testGroup Row still visible", getVisibleAdress(aNewString), OUString(""));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testGroup Row still visible", getVisibleAdress(aSheet, aNewString), OUString(""));
}
......@@ -218,11 +217,9 @@ void XSheetOutline::testUngroup()
uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
aSheetGlobal = aSheet;
// New Column level
OUString aNewString = "OutlineSheet.BB1:BG1";
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aNewString);
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_COLUMNS);
aSheetOutline->hideDetail(aLevelRangeAddress);
......@@ -231,11 +228,11 @@ void XSheetOutline::testUngroup()
aSheetOutline->showDetail(aLevelRangeAddress);
// should remain hidden ?
CPPUNIT_ASSERT_EQUAL_MESSAGE("testUnGroup Column becomes visible after ungroup", getVisibleAdress(aNewString), OUString(""));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testUnGroup Column becomes visible after ungroup", getVisibleAdress(aSheet, aNewString), OUString(""));
// New Row level
aNewString = "OutlineSheet.A70:A80";
aLevelRangeAddress = getAddressFromRangeString(aNewString);
aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_ROWS);
aSheetOutline->hideDetail(aLevelRangeAddress);
......@@ -244,7 +241,7 @@ void XSheetOutline::testUngroup()
aSheetOutline->showDetail(aLevelRangeAddress);
// should remain hidden ?
CPPUNIT_ASSERT_EQUAL_MESSAGE("testUnGroup Row becomes visible after ungroup", getVisibleAdress(aNewString), OUString(""));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testUnGroup Row becomes visible after ungroup", getVisibleAdress(aSheet, aNewString), OUString(""));
}
......@@ -257,17 +254,15 @@ void XSheetOutline::testClearOutline()
uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
aSheetGlobal = aSheet;
aSheetOutline->clearOutline();
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(colLevel1);
table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, colLevel1);
aSheetOutline->hideDetail(aLevelRangeAddress);
aLevelRangeAddress = getAddressFromRangeString(rowLevel1);
aLevelRangeAddress = getAddressFromRangeString(aSheet, rowLevel1);
aSheetOutline->hideDetail(aLevelRangeAddress);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testClearOutline Columns are hidden after clear", getVisibleAdress(colLevel1), colLevel1);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testClearOutline Rows are hidden after clear", getVisibleAdress(rowLevel1), rowLevel1);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testClearOutline Columns are hidden after clear", getVisibleAdress(aSheet, colLevel1), colLevel1);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testClearOutline Rows are hidden after clear", getVisibleAdress(aSheet, rowLevel1), rowLevel1);
}
......
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