summaryrefslogtreecommitdiff
path: root/sc/qa/perf
diff options
context:
space:
mode:
authorŁukasz Hryniuk <lukasz.hryniuk@wp.pl>2015-09-18 12:40:50 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-20 11:14:44 +0000
commit465f493623aecc2d2559aa52d6f52da12854e8cc (patch)
tree4d1bb2cb1f37afd0a555b3f8cefcdb3a3e069f26 /sc/qa/perf
parent3a3c68aeafb1ed3c02dd863112d49e61727cf84c (diff)
Performance test for Sum
Change-Id: Ia3809dc429efcc441db29be134ce1bfa5b0d4175 Reviewed-on: https://gerrit.libreoffice.org/18704 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/qa/perf')
-rw-r--r--sc/qa/perf/scperfobj.cxx55
-rw-r--r--sc/qa/perf/testdocuments/scMathFunctions.odsbin0 -> 42552 bytes
2 files changed, 49 insertions, 6 deletions
diff --git a/sc/qa/perf/scperfobj.cxx b/sc/qa/perf/scperfobj.cxx
index 4e4e1a893383..9c79e28024d3 100644
--- a/sc/qa/perf/scperfobj.cxx
+++ b/sc/qa/perf/scperfobj.cxx
@@ -20,6 +20,8 @@
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
+#include <com/sun/star/sheet/XCalculatable.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
@@ -50,12 +52,13 @@ public:
virtual void setUp() SAL_OVERRIDE;
virtual void tearDown() SAL_OVERRIDE;
- uno::Reference< uno::XInterface > init();
+ uno::Reference< uno::XInterface > init(const OUString& aFileName);
CPPUNIT_TEST_SUITE(ScPerfObj);
CPPUNIT_TEST(testSheetFindAll);
CPPUNIT_TEST(testSheetNamedRanges);
CPPUNIT_TEST(testSheets);
+ CPPUNIT_TEST(testSum);
CPPUNIT_TEST_SUITE_END();
private:
@@ -67,6 +70,7 @@ private:
void testSheetFindAll();
void testSheetNamedRanges();
void testSheets();
+ void testSum();
};
@@ -78,13 +82,13 @@ ScPerfObj::ScPerfObj()
{
}
-uno::Reference< uno::XInterface > ScPerfObj::init()
+uno::Reference< uno::XInterface > ScPerfObj::init(const OUString& aFileName)
{
if (mxComponent.is())
closeDocument(mxComponent);
OUString aFileURL;
- createFileURL(OUString("scBigFile.ods"), aFileURL);
+ createFileURL(aFileName, aFileURL);
mxComponent = loadFromDesktop(aFileURL);
@@ -115,7 +119,7 @@ void ScPerfObj::tearDown()
void ScPerfObj::testSheetFindAll()
{
- uno::Reference< sheet::XSpreadsheetDocument > xDoc(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(init("scBigFile.ods"), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Problem in document loading" , xDoc.is());
@@ -171,7 +175,7 @@ void ScPerfObj::testSheetFindAll()
void ScPerfObj::testSheetNamedRanges()
{
- uno::Reference< lang::XComponent > xComponent (init(), UNO_QUERY_THROW);
+ uno::Reference< lang::XComponent > xComponent (init("scBigFile.ods"), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComponent, UNO_QUERY_THROW);
// get NamedRanges
@@ -218,7 +222,7 @@ void ScPerfObj::testSheetNamedRanges()
void ScPerfObj::testSheets()
{
- uno::Reference< sheet::XSpreadsheetDocument > xDoc(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(init("scBigFile.ods"), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Problem in document loading" , xDoc.is());
@@ -246,6 +250,45 @@ void ScPerfObj::testSheets()
}
+void ScPerfObj::testSum()
+{
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(init("scMathFunctions.ods"), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Problem in document loading" , xDoc.is());
+ uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
+
+ // get getSheets
+ uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_QUERY_THROW);
+
+ uno::Any rSheet = xSheets->getByName(OUString::createFromAscii("SumSheet"));
+
+ // query for the XSpreadsheet interface
+ uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
+ uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(1, 0);
+
+
+ callgrindStart();
+ xCell->setFormula(OUString::createFromAscii("=SUM(A1:A10000)"));
+ xCalculatable->calculate();
+ callgrindDump("sc:sum_numbers_column");
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Sum" , 504178.0, xCell->getValue());
+
+ // query for the XCellRange interface
+ uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
+ // query the cell range
+ uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName(OUString::createFromAscii("B1"));
+
+ uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
+
+ callgrindStart();
+ xArrayFormulaRange->setArrayFormula("=SUM(A1:A10000=30)");
+ xCalculatable->calculate();
+ callgrindDump("sc:sum_with_array_formula_condition");
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Sum - number of elements equal 30" , 99.0, xCell->getValue());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScPerfObj);
}
diff --git a/sc/qa/perf/testdocuments/scMathFunctions.ods b/sc/qa/perf/testdocuments/scMathFunctions.ods
new file mode 100644
index 000000000000..e87c88a2a923
--- /dev/null
+++ b/sc/qa/perf/testdocuments/scMathFunctions.ods
Binary files differ