summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.com>2016-02-16 21:23:00 +0530
committerJan Holesovsky <kendy@collabora.com>2016-02-19 08:23:00 +0100
commitf6c96946911db267bc79b4bdb4ced7d7414d3cac (patch)
treef53e98a7bdeefdf738762790211babc9571fd3d7
parent324014c997ab90f5777f772a46e6faf887a00832 (diff)
lok: Add a new sheet selection test
This is a test for commit ab199e4748b45384602479c735dbac538e714d34. Change-Id: I38905cfab8fe1c5721e5fa628ea564f08e0c2ad3
-rw-r--r--desktop/qa/data/sheets.odsbin6946 -> 8898 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx112
2 files changed, 112 insertions, 0 deletions
diff --git a/desktop/qa/data/sheets.ods b/desktop/qa/data/sheets.ods
index 42226b27e00a..0acf86541ba9 100644
--- a/desktop/qa/data/sheets.ods
+++ b/desktop/qa/data/sheets.ods
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index da4e5fb9f547..0c44341b364f 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -85,6 +85,7 @@ public:
void testWriterComments();
void testModifiedStatus();
void testSheetOperations();
+ void testSheetSelections();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -105,6 +106,7 @@ public:
CPPUNIT_TEST(testWriterComments);
CPPUNIT_TEST(testModifiedStatus);
CPPUNIT_TEST(testSheetOperations);
+ CPPUNIT_TEST(testSheetSelections);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -725,6 +727,116 @@ void DesktopLOKTest::testSheetOperations()
comphelper::LibreOfficeKit::setActive(false);
}
+void DesktopLOKTest::testSheetSelections()
+{
+ comphelper::LibreOfficeKit::setActive();
+ LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET);
+ pDocument->pClass->initializeForRendering(pDocument, nullptr);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+ /*
+ * Check if selection data is correct
+ */
+ // Values in twips
+ int row5 = 1150;
+ int col1 = 1100;
+ int col2 = 2200;
+ int col3 = 3300;
+ int col4 = 4400;
+ int col5 = 5500;
+
+ // Select row 5 from column 1 through column 5
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ col1, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEMOVE,
+ col2, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEMOVE,
+ col3, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEMOVE,
+ col4, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEMOVE,
+ col5, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ col5, row5,
+ 1, 1, 0);
+
+ // Copy the contents and check if matches expected data
+ {
+ char* pUsedMimeType = nullptr;
+ char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pUsedMimeType);
+ std::vector<int> pExpected = {5, 6, 7, 8, 9};
+ std::istringstream iss(pCopiedContent);
+ for (uint i = 0; i < pExpected.size(); i++)
+ {
+ std::string token;
+ iss >> token;
+ CPPUNIT_ASSERT_EQUAL(pExpected[i], std::stoi(token));
+ }
+
+ free(pUsedMimeType);
+ free(pCopiedContent);
+ }
+
+ /*
+ * Check if clicking inside the selection deselects the whole selection
+ */
+ int row10 = 2400;
+ // Select starting from row5, col1 to row10, col5
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ col1, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEMOVE,
+ col5, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ col5, row10,
+ 1, 1, 0);
+
+ // Click at row5, col4
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ col4, row5,
+ 1, 1, 0);
+ pDocument->pClass->postMouseEvent(pDocument,
+ LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ col4, row5,
+ 1, 1, 0);
+
+ // Selected text should get deselected and copying should give us
+ // content of only one cell, now
+ {
+ char* pUsedMimeType = nullptr;
+ char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pUsedMimeType);
+ std::vector<int> pExpected = { 8 };
+ std::istringstream iss(pCopiedContent);
+ for (uint i = 0; i < pExpected.size(); i++)
+ {
+ std::string token;
+ iss >> token;
+ CPPUNIT_ASSERT_EQUAL(pExpected[i], std::stoi(token));
+ }
+
+ free(pUsedMimeType);
+ free(pCopiedContent);
+ }
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
CPPUNIT_PLUGIN_IMPLEMENT();