summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-27 14:05:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-28 08:54:42 +0200
commitef531e85d95fe18d553bce1a6926d24c08ffe2bf (patch)
treeb913745a48020c9b1cbaedfc95fdd216b95a98ae /test
parent1eee0abd459a508a6dcf9e71cbf2c1be3725faa7 (diff)
loplugin:oncevar in test..tools
Change-Id: I7b3ccc8f227100ff7fedeaca96a12f135da60bab Reviewed-on: https://gerrit.libreoffice.org/39326 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/source/sheet/xcellrangesquery.cxx12
-rw-r--r--test/source/sheet/xnamedrange.cxx20
-rw-r--r--test/source/sheet/xnamedranges.cxx13
-rw-r--r--test/source/sheet/xspreadsheets2.cxx21
-rw-r--r--test/source/sheet/xstyleloader.cxx3
-rw-r--r--test/source/sheet/xviewpane.cxx3
6 files changed, 28 insertions, 44 deletions
diff --git a/test/source/sheet/xcellrangesquery.cxx b/test/source/sheet/xcellrangesquery.cxx
index 4838c65746de..7496eded47d9 100644
--- a/test/source/sheet/xcellrangesquery.cxx
+++ b/test/source/sheet/xcellrangesquery.cxx
@@ -24,7 +24,7 @@ namespace apitest {
void XCellRangesQuery::testQueryColumnDifference()
{
- OUString aExpected( "Sheet1.B1:C1,Sheet1.B3:C5" );
+ OUString const aExpected( "Sheet1.B1:C1,Sheet1.B3:C5" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
OUString aResult = xRanges->getRangeAddressesAsString();
@@ -34,7 +34,7 @@ void XCellRangesQuery::testQueryColumnDifference()
void XCellRangesQuery::testQueryContentDifference()
{
- OUString aExpected( "Sheet1.B3,Sheet1.C2" );
+ OUString const aExpected( "Sheet1.B3,Sheet1.C2" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
OUString aResult = xRanges->getRangeAddressesAsString();
@@ -54,7 +54,7 @@ void XCellRangesQuery::testQueryEmptyCells()
void XCellRangesQuery::testQueryFormulaCells()
{
- OUString aExpected( "Sheet1.B2" );
+ OUString const aExpected( "Sheet1.B2" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
OUString aResult = xRanges->getRangeAddressesAsString();
@@ -64,7 +64,7 @@ void XCellRangesQuery::testQueryFormulaCells()
void XCellRangesQuery::testQueryIntersection()
{
- OUString aExpected( "Sheet1.D4:E5" );
+ OUString const aExpected( "Sheet1.D4:E5" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
OUString aResult = xRanges->getRangeAddressesAsString();
@@ -74,7 +74,7 @@ void XCellRangesQuery::testQueryIntersection()
void XCellRangesQuery::testQueryRowDifference()
{
- OUString aExpected( "Sheet1.A2:A4,Sheet1.C2:E4" );
+ OUString const aExpected( "Sheet1.A2:A4,Sheet1.C2:E4" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
OUString aResult = xRanges->getRangeAddressesAsString();
@@ -84,7 +84,7 @@ void XCellRangesQuery::testQueryRowDifference()
void XCellRangesQuery::testQueryVisibleCells()
{
- OUString aExpected( "Sheet1.A1:E5" );
+ OUString const aExpected( "Sheet1.A1:E5" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
OUString aResult = xRanges->getRangeAddressesAsString();
diff --git a/test/source/sheet/xnamedrange.cxx b/test/source/sheet/xnamedrange.cxx
index 5353b5416e82..84e4cb1c4875 100644
--- a/test/source/sheet/xnamedrange.cxx
+++ b/test/source/sheet/xnamedrange.cxx
@@ -35,17 +35,15 @@ namespace apitest {
void XNamedRange::testGetContent()
{
- OUString aTestedNamedRangeString("initial1");
- uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
- OUString aExpectedContent("$Sheet1.$B$1");
+ OUString const aExpectedContent("$Sheet1.$B$1");
CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent().equals(aExpectedContent));
}
void XNamedRange::testSetContent()
{
- OUString aTestedNamedRangeString("initial1");
- uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
OUString aExpectedContent;
@@ -69,15 +67,13 @@ void XNamedRange::testSetContent()
void XNamedRange::testGetType()
{
- OUString aTestedNamedRangeString("initial1");
- uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type", sal_Int32(0), xNamedRange->getType());
}
void XNamedRange::testSetType()
{
- OUString aTestedNamedRangeString("initial1");
- uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;
xNamedRange->setType(nType);
@@ -102,8 +98,7 @@ void XNamedRange::testSetType()
void XNamedRange::testGetReferencePosition()
{
- OUString aTestedNamedRangeString("initial2");
- uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial2");
table::CellAddress aCellAddress = xNamedRange->getReferencePosition();
// the expected address is on B1, as it was the active cell when initial2 was created
@@ -114,8 +109,7 @@ void XNamedRange::testGetReferencePosition()
void XNamedRange::testSetReferencePosition()
{
- OUString aTestedNamedRangeString("initial1");
- uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
table::CellAddress aBaseAddress = table::CellAddress(1,2,3);
diff --git a/test/source/sheet/xnamedranges.cxx b/test/source/sheet/xnamedranges.cxx
index 4fee1da0e23c..6983ead594d1 100644
--- a/test/source/sheet/xnamedranges.cxx
+++ b/test/source/sheet/xnamedranges.cxx
@@ -59,31 +59,31 @@ void XNamedRanges::testAddNewByName()
table::CellAddress aBaseAddress = table::CellAddress(0,0,0);
sal_Int32 nType = 0;
- OUString aContent1("D1");
+ OUString const aContent1("D1");
OUString aName1("type_0");
xNamedRanges->addNewByName(aName1, aContent1, aBaseAddress, nType);
CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type 0 - Normal case", xNamedRanges->hasByName(aName1));
nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
- OUString aContent2("D2");
+ OUString const aContent2("D2");
OUString aName2("type_COLUMN_HEADER");
xNamedRanges->addNewByName(aName2, aContent2, aBaseAddress, nType);
CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type COLUMN_HEADER", xNamedRanges->hasByName(aName2));
nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
- OUString aContent3("D3");
+ OUString const aContent3("D3");
OUString aName3("type_FILTER_CRITERIA");
xNamedRanges->addNewByName(aName3, aContent3, aBaseAddress, nType);
CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type FILTER_CRITERIA", xNamedRanges->hasByName(aName3));
nType = ::sheet::NamedRangeFlag::PRINT_AREA;
- OUString aContent4("D4");
+ OUString const aContent4("D4");
OUString aName4("type_PRINT_AREA");
xNamedRanges->addNewByName(aName4, aContent4, aBaseAddress, nType);
CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type PRINT_AREA", xNamedRanges->hasByName(aName4));
nType = ::sheet::NamedRangeFlag::ROW_HEADER;
- OUString aContent5("D5");
+ OUString const aContent5("D5");
OUString aName5("type_ROW_HEADER");
xNamedRanges->addNewByName(aName5, aContent5, aBaseAddress, nType);
CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type ROW_HEADER", xNamedRanges->hasByName(aName5));
@@ -171,8 +171,7 @@ void XNamedRanges::testRemoveByName()
CPPUNIT_ASSERT_EQUAL_MESSAGE("NamedRange initial1 not removed", nNewCount, nInitialCount - 1);
CPPUNIT_ASSERT_MESSAGE("Wrong NamedRange removed, initial1 still present", !xNamedRanges->hasByName(maNameToRemove));
// try to remove non existing
- OUString aNr2("dummyNonExistingNamedRange");
- xNamedRanges->removeByName(aNr2);// an exception should be raised here
+ xNamedRanges->removeByName("dummyNonExistingNamedRange");// an exception should be raised here
}
}
diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
index 7d0e24527685..771bcf6c2e05 100644
--- a/test/source/sheet/xspreadsheets2.cxx
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -148,14 +148,12 @@ void XSpreadsheets2::testImportOverExistingNamedRange()
*/
importSheetToCopy();
- OUString aNamedRangeString("initial1");
-
uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
- uno::Any aNr = xDestNamedRangesNameAccess->getByName(aNamedRangeString);
+ uno::Any aNr = xDestNamedRangesNameAccess->getByName("initial1");
uno::Reference< sheet::XNamedRange > xDestNamedRange(aNr, UNO_QUERY_THROW);
OUString aNrDestContent = xDestNamedRange->getContent();
- OUString aExpectedContent("$Sheet1.$B$1");
+ OUString const aExpectedContent("$Sheet1.$B$1");
std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for initial1", aNrDestContent, aExpectedContent);
@@ -203,7 +201,7 @@ void XSpreadsheets2::testImportNamedRangeRedefinedInSource()
uno::Any aRedefinedInSheetNr = xDestNamedRangesNameAccess->getByName(aRedefinedInSheetNamedRangeString);
uno::Reference< sheet::XNamedRange > xDestRedefinedInSheetNamedRange(aRedefinedInSheetNr, UNO_QUERY_THROW);
OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent();
- OUString aRedefinedInSheetExpectedContent("$Sheet1.$B$2");
+ OUString const aRedefinedInSheetExpectedContent("$Sheet1.$B$2");
std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent, aRedefinedInSheetExpectedContent);
}
@@ -263,17 +261,15 @@ void XSpreadsheets2::testImportCellStyle()
uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier (xDestDoc, UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xFamiliesNameAccess (xFamiliesSupplier->getStyleFamilies(), UNO_QUERY_THROW);
- OUString aCellFamilyName("CellStyles");
- uno::Any aCellStylesFamily = xFamiliesNameAccess->getByName(aCellFamilyName);
+ uno::Any aCellStylesFamily = xFamiliesNameAccess->getByName("CellStyles");
uno::Reference< container::XNameContainer > xCellStylesFamilyNameAccess (aCellStylesFamily, UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("New cell style not present", xCellStylesFamilyNameAccess->hasByName(aDestStyleName));
uno::Any aCellStyle = xCellStylesFamilyNameAccess->getByName(aDestStyleName);
uno::Reference< beans::XPropertySet > xCellStyleProp (aCellStyle, UNO_QUERY_THROW);
- OUString aProperty("VertJustify");
sal_Int32 aVertJustify = 0;
- CPPUNIT_ASSERT(xCellStyleProp->getPropertyValue(aProperty) >>= aVertJustify);
+ CPPUNIT_ASSERT(xCellStyleProp->getPropertyValue("VertJustify") >>= aVertJustify);
CPPUNIT_ASSERT_EQUAL_MESSAGE("New style: VertJustify not set", table::CellVertJustify_CENTER, (table::CellVertJustify)aVertJustify);
}
@@ -296,8 +292,7 @@ uno::Reference< sheet::XSpreadsheetDocument> XSpreadsheets2::getDoc(const OUStri
uno::Reference< sheet::XNamedRanges> XSpreadsheets2::getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument> const & xDoc)
{
uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
- OUString NamedRangesPropertyString("NamedRanges");
- uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(NamedRangesPropertyString), UNO_QUERY_THROW);
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue("NamedRanges"), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xNamedRanges.is());
return xNamedRanges;
@@ -331,9 +326,7 @@ void XSpreadsheets2::importSheetToCopy()
bool XSpreadsheets2::isExternalReference(const OUString& aDestContent, const OUString& aSrcContent )
{
- OUString aStart("'file://");
-
- CPPUNIT_ASSERT(aDestContent.startsWith(aStart));
+ CPPUNIT_ASSERT(aDestContent.startsWith("'file://"));
return (aDestContent.endsWithIgnoreAsciiCase(aSrcContent) // same cell address
&& aDestContent.indexOf(aSrcFileName)>0); // contains source file name
diff --git a/test/source/sheet/xstyleloader.cxx b/test/source/sheet/xstyleloader.cxx
index 717f3e4a90f0..844e620e1d58 100644
--- a/test/source/sheet/xstyleloader.cxx
+++ b/test/source/sheet/xstyleloader.cxx
@@ -76,8 +76,7 @@ void XStyleLoader::checkStyleProperties( uno::Reference< style::XStyleFamiliesSu
uno::Reference< style::XStyle > xMyStyle (xCellStyles->getByName("myStyle"), UNO_QUERY_THROW);
uno::Reference< beans::XPropertySet > xPropSet (xMyStyle, UNO_QUERY_THROW);
- OUString aCellStyleName("CellBackColor");
- uno::Any aBackColor = xPropSet->getPropertyValue(aCellStyleName);
+ uno::Any aBackColor = xPropSet->getPropertyValue("CellBackColor");
uno::Any expectedBackColor(sal_Int32(16724787));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellBackColor" , expectedBackColor, aBackColor);
diff --git a/test/source/sheet/xviewpane.cxx b/test/source/sheet/xviewpane.cxx
index 759531019a27..be0600991194 100644
--- a/test/source/sheet/xviewpane.cxx
+++ b/test/source/sheet/xviewpane.cxx
@@ -36,7 +36,6 @@ void XViewPane::testFirstVisibleRow()
void XViewPane::testVisibleRange()
{
- sal_Int16 nSheet = 0;
sal_Int32 nCol = 5;
sal_Int32 nRow = 3;
uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
@@ -44,7 +43,7 @@ void XViewPane::testVisibleRange()
xViewPane->setFirstVisibleRow(nRow);
table::CellRangeAddress aCellRangeAddress = xViewPane->getVisibleRange();
- CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.Sheet, nSheet);
+ CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.Sheet, short(0));
CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.StartRow, nRow);
CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.StartColumn, nCol);
}