summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libreofficekit/qa/data/empty.odsbin0 -> 6845 bytes
-rw-r--r--libreofficekit/qa/unit/tiledrendering.cxx89
-rw-r--r--vcl/source/app/svapp.cxx9
3 files changed, 98 insertions, 0 deletions
diff --git a/libreofficekit/qa/data/empty.ods b/libreofficekit/qa/data/empty.ods
new file mode 100644
index 000000000000..a36d1f97c405
--- /dev/null
+++ b/libreofficekit/qa/data/empty.ods
Binary files differ
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 0a93c4651d77..ed94e72cbd33 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -67,6 +67,7 @@ public:
void testImpressSlideNames( Office* pOffice );
void testCalcSheetNames( Office* pOffice );
void testPaintPartTile( Office* pOffice );
+ void testDocumentLoadLanguage(Office* pOffice);
#if 0
void testOverlay( Office* pOffice );
#endif
@@ -94,6 +95,7 @@ void TiledRenderingTest::runAllTests()
testImpressSlideNames( pOffice.get() );
testCalcSheetNames( pOffice.get() );
testPaintPartTile( pOffice.get() );
+ testDocumentLoadLanguage(pOffice.get());
#if 0
testOverlay( pOffice.get() );
#endif
@@ -212,6 +214,93 @@ void TiledRenderingTest::testPaintPartTile(Office* pOffice)
pDocument->paintPartTile(aBuffer.data(), /*nPart=*/0, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
}
+namespace {
+
+void processEventsToIdle()
+{
+ typedef void (ProcessEventsToIdleFn)(void);
+ static ProcessEventsToIdleFn *processFn = nullptr;
+ if (!processFn)
+ {
+ void *me = dlopen(nullptr, RTLD_NOW);
+ processFn = reinterpret_cast<ProcessEventsToIdleFn *>(dlsym(me, "unit_lok_process_events_to_idle"));
+ }
+
+ CPPUNIT_ASSERT(processFn);
+
+ (*processFn)();
+}
+
+void insertString(Document& rDocument, const std::string& s)
+{
+ for (const char c : s)
+ {
+ rDocument.postKeyEvent(LOK_KEYEVENT_KEYINPUT, c, 0);
+ rDocument.postKeyEvent(LOK_KEYEVENT_KEYUP, c, 0);
+ }
+ processEventsToIdle();
+}
+
+}
+
+void TiledRenderingTest::testDocumentLoadLanguage(Office* pOffice)
+{
+ const string sDocPath = m_sSrcRoot + "/libreofficekit/qa/data/empty.ods";
+ const string sLockFile = m_sSrcRoot +"/libreofficekit/qa/data/.~lock.empty.ods#";
+
+ // FIXME: LOK will fail when trying to open a locked file
+ remove(sLockFile.c_str());
+
+ // first try with the en-US locale
+ std::unique_ptr<Document> pDocument(pOffice->documentLoad(sDocPath.c_str(), "Language=en-US"));
+
+ // assert that '.' is the decimal separator
+ insertString(*pDocument, "1.5");
+
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 1027); // right arrow
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1027);
+ processEventsToIdle();
+
+ insertString(*pDocument, "=2*A1");
+
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 1280); // enter
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1280);
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 1025); // up arrow
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1025);
+ processEventsToIdle();
+
+ // we've got a meaningful result
+ OString aResult = pDocument->getTextSelection("text/plain;charset=utf-8");
+ CPPUNIT_ASSERT_EQUAL(OString("3\n"), aResult);
+
+ pDocument.reset(nullptr);
+
+ // FIXME: LOK will fail when trying to open a locked file
+ remove(sLockFile.c_str());
+
+ // load the file again, now in another language
+ pDocument.reset(pOffice->documentLoad(sDocPath.c_str(), "Language=cs-CZ"));
+
+ // with cs-CZ, the decimal separator is ',' instead, assert that
+ insertString(*pDocument, "1,5");
+
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 1027); // right arrow
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1027);
+ processEventsToIdle();
+
+ insertString(*pDocument, "=2*A1");
+
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 1280); // enter
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1280);
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 1025); // up arrow
+ pDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, 1025);
+ processEventsToIdle();
+
+ // we've got a meaningful result
+ aResult = pDocument->getTextSelection("text/plain;charset=utf-8");
+ CPPUNIT_ASSERT_EQUAL(OString("3\n"), aResult);
+}
+
#if 0
static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
const int nWidth, const int nHeight )
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 90de97f23eee..70fd664b52ac 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -548,6 +548,15 @@ void Scheduler::ProcessEventsToIdle()
}
}
+extern "C" {
+/// used by unit tests that test only via the LOK API
+SAL_DLLPUBLIC_EXPORT void unit_lok_process_events_to_idle()
+{
+ const SolarMutexGuard aGuard;
+ Scheduler::ProcessEventsToIdle();
+}
+}
+
void Application::Yield()
{
ImplYield(true, false, 0);