summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2016-10-07 21:39:02 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2016-10-07 22:05:11 -0400
commitf37292941fef7375b8bc29783f54e0c64d670a24 (patch)
tree880813e002c5b336c4bb10c1e29b102bf423824c /sc
parent61b76cd8ca6a4a98a2ffe6fb42c73eba561aa87f (diff)
Write test case for it.
Change-Id: I63f8b5d490686f838c0618d670bb21a957690866
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx35
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 37 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index f1d705ff401b..86e2ed6e7f85 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -465,6 +465,41 @@ void Test::testDocStatistics()
m_pDoc->DeleteTab(0); // This may fail in case there is only one sheet in the document.
}
+void Test::testRowForHeight()
+{
+ m_pDoc->InsertTab(0, "Sheet1");
+ m_pDoc->SetRowHeightRange( 0, 9, 0, 100);
+ m_pDoc->SetRowHeightRange(10, 19, 0, 200);
+ m_pDoc->SetRowHeightRange(20, 29, 0, 300);
+
+ // Hide some rows.
+ m_pDoc->SetRowHidden(3, 5, 0, true);
+ m_pDoc->SetRowHidden(8, 12, 0, true);
+
+ struct Check
+ {
+ sal_uLong nHeight;
+ SCROW nRow;
+ };
+
+ std::vector<Check> aChecks = {
+ { 1, 1 },
+ { 99, 1 },
+ { 120, 2 },
+ { 330, 7 },
+ { 420, 13 },
+ { 780, 15 },
+ { 1860, 20 },
+ { 4020, 28 },
+ };
+
+ for (const Check& rCheck : aChecks)
+ {
+ SCROW nRow = m_pDoc->GetRowForHeight(0, rCheck.nHeight);
+ CPPUNIT_ASSERT_EQUAL(rCheck.nRow, nRow);
+ }
+}
+
void Test::testDataEntries()
{
m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index cbc99810634f..2a7a1a259827 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -107,6 +107,7 @@ public:
void testMarkData();
void testInput();
void testDocStatistics();
+ void testRowForHeight();
/**
* The 'data entries' data is a list of strings used for suggestions as
@@ -492,6 +493,7 @@ public:
CPPUNIT_TEST(testMarkData);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testDocStatistics);
+ CPPUNIT_TEST(testRowForHeight);
CPPUNIT_TEST(testDataEntries);
CPPUNIT_TEST(testSelectionFunction);
CPPUNIT_TEST(testFormulaCreateStringFromTokens);