summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-21 14:28:08 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 17:15:32 +0200
commit16382e0c6779305a7460b4182612e4e59561ef6b (patch)
treeff3380921ad2e9ddc1198f11a45ddf1bdeaebb1f
parentda9595dca88ca207b1ac9c2f236230202aaa9500 (diff)
sw: add LOK_CALLBACK_TEXT_VIEW_SELECTION testcase
Fails with 9f66db9c474f71f43d7a3667230241fd4fa4183f (sw lok: add LOK_CALLBACK_TEXT_VIEW_SELECTION, 2016-06-21) reverted. Change-Id: Ide21167ce2dc4287b1860b5f03a6975dc9edd4c6 Reviewed-on: https://gerrit.libreoffice.org/26550 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 45182f36ef263d6fd94cc79bb242fbfb5a471c22)
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx1
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx41
2 files changed, 38 insertions, 4 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 4d3bae20c1dd..60e22fc49596 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1033,7 +1033,6 @@ callback (gpointer pData)
priv->m_aVisibleCursor.y,
priv->m_aVisibleCursor.width,
priv->m_aVisibleCursor.height);
- std::cerr << "debug, LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: i am " << priv->m_nViewId << ", i got " << pCallback->m_aPayload << " for myself" << std::endl;
gtk_widget_queue_draw(GTK_WIDGET(pDocView));
}
break;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 5034537a0c81..699802311fa2 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -226,7 +226,7 @@ void SwTiledRenderingTest::testSetTextSelection()
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
// Move the cursor into the second word.
pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 5, /*bBasicCall=*/false);
- // Create a selection by on the word.
+ // Create a selection on the word.
pWrtShell->SelWrd();
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
// Did we indeed manage to select the second word?
@@ -549,10 +549,14 @@ class ViewCallback
public:
bool m_bOwnCursorInvalidated;
bool m_bViewCursorInvalidated;
+ bool m_bOwnSelectionSet;
+ bool m_bViewSelectionSet;
ViewCallback()
: m_bOwnCursorInvalidated(false),
- m_bViewCursorInvalidated(false)
+ m_bViewCursorInvalidated(false),
+ m_bOwnSelectionSet(false),
+ m_bViewSelectionSet(false)
{
}
@@ -575,6 +579,16 @@ public:
m_bViewCursorInvalidated = true;
}
break;
+ case LOK_CALLBACK_TEXT_SELECTION:
+ {
+ m_bOwnSelectionSet = true;
+ }
+ break;
+ case LOK_CALLBACK_TEXT_VIEW_SELECTION:
+ {
+ m_bViewSelectionSet = true;
+ }
+ break;
}
}
};
@@ -583,7 +597,7 @@ void SwTiledRenderingTest::testViewCursors()
{
comphelper::LibreOfficeKit::setActive();
- createDoc("dummy.fodt");
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
ViewCallback aView1;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
SfxLokHelper::createView();
@@ -596,6 +610,27 @@ void SwTiledRenderingTest::testViewCursors()
// it changed.
CPPUNIT_ASSERT(aView2.m_bViewCursorInvalidated);
+ // Make sure that aView1 gets a view-only selection notification, while
+ // aView2 gets a real selection notification.
+ aView1.m_bOwnSelectionSet = false;
+ aView1.m_bViewSelectionSet = false;
+ aView2.m_bOwnSelectionSet = false;
+ aView2.m_bViewSelectionSet = false;
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ // Move the cursor into the second word.
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 5, /*bBasicCall=*/false);
+ // Create a selection on the word.
+ pWrtShell->SelWrd();
+ SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+ // Did we indeed manage to select the second word?
+ CPPUNIT_ASSERT_EQUAL(OUString("bbb"), pShellCursor->GetText());
+ CPPUNIT_ASSERT(!aView1.m_bOwnSelectionSet);
+ // This failed, aView1 did not get notification about selection changes in
+ // aView2.
+ CPPUNIT_ASSERT(aView1.m_bViewSelectionSet);
+ CPPUNIT_ASSERT(aView2.m_bOwnSelectionSet);
+ CPPUNIT_ASSERT(!aView2.m_bViewSelectionSet);
+
comphelper::LibreOfficeKit::setActive(false);
}