summaryrefslogtreecommitdiff
path: root/desktop/qa/desktop_lib/test_desktop_lib.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/qa/desktop_lib/test_desktop_lib.cxx')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx76
1 files changed, 76 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a8a9a9d8b7ea..a3f3ddac0cc4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -48,6 +48,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <unotools/datetime.hxx>
+#include <unotools/syslocaleoptions.hxx>
#include <comphelper/string.hxx>
#include <comphelper/scopeguard.hxx>
#include <cairo.h>
@@ -63,6 +64,30 @@ using namespace desktop;
class DesktopLOKTest : public UnoApiTest
{
+ class Resetter
+ {
+ private:
+ std::function<void ()> m_Func;
+
+ public:
+ Resetter(std::function<void ()> const& rFunc)
+ : m_Func(rFunc)
+ {
+ }
+ ~Resetter()
+ {
+ try
+ {
+ m_Func();
+ }
+ catch (...) // has to be reliable
+ {
+ fprintf(stderr, "resetter failed with exception\n");
+ abort();
+ }
+ }
+ };
+
public:
DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
m_nSelectionBeforeSearchResult(0),
@@ -149,6 +174,7 @@ public:
void testSignDocument_PEM_PDF();
void testTextSelectionHandles();
void testComplexSelection();
+ void testSpellcheckerMultiView();
void testDialogPaste();
void testShowHideDialog();
void testDialogInput();
@@ -209,6 +235,7 @@ public:
#endif
CPPUNIT_TEST(testTextSelectionHandles);
CPPUNIT_TEST(testComplexSelection);
+ CPPUNIT_TEST(testSpellcheckerMultiView);
CPPUNIT_TEST(testDialogPaste);
CPPUNIT_TEST(testShowHideDialog);
CPPUNIT_TEST(testDialogInput);
@@ -2783,6 +2810,55 @@ void DesktopLOKTest::testMetricField()
CPPUNIT_ASSERT_EQUAL(aMap["VALUE"], aRet["Value"]);
}
+void DesktopLOKTest::testSpellcheckerMultiView()
+{
+ static const OUString aLangISO("en-US");
+ SvtSysLocaleOptions aSysLocaleOptions;
+ aSysLocaleOptions.SetLocaleConfigString(aLangISO);
+ aSysLocaleOptions.SetUILocaleConfigString(aLangISO);
+ comphelper::LibreOfficeKit::setLanguageTag(aLangISO, true);
+
+ auto aSavedSettings = Application::GetSettings();
+ std::unique_ptr<Resetter> pResetter(
+ new Resetter([&]() { Application::SetSettings(aSavedSettings); }));
+ AllSettings aSettings(aSavedSettings);
+ aSettings.SetLanguageTag(aLangISO, true);
+ Application::SetSettings(aSettings);
+
+ LibLODocument_Impl* pDocument = loadDoc("sheet_with_image.ods", LOK_DOCTYPE_SPREADSHEET);
+ pDocument->pClass->setViewLanguage(pDocument, 0, "en-US"); // For spellchecking.
+ pDocument->pClass->initializeForRendering(pDocument, nullptr);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, com::sun::star::awt::Key::ESCAPE);
+
+ // Start spellchecking.
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:SpellDialog", nullptr, false);
+
+ // Uncommenting this will result in a deadlock.
+ // Because the language configuration above is not effective, and no
+ // language is actually set, the spell-dialog finds no misspelled
+ // words, and displays a message box, which must be dismissed to
+ // continue.
+ // Need to fix the language configuration issue to enable this.
+ // Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument));
+
+ // Now create another view.
+ const int nViewId = pDocument->m_pDocumentClass->createView(pDocument);
+ CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViewsCount(pDocument));
+
+ // And destroy it.
+ pDocument->m_pDocumentClass->destroyView(pDocument, nViewId);
+
+ // We should survive the destroyed view.
+ CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument));
+}
+
namespace {
constexpr size_t classOffset(int i)