summaryrefslogtreecommitdiff
path: root/sw/qa/uibase/shells
diff options
context:
space:
mode:
authorTokieSan <eltokhy@aucegypt.edu>2023-04-15 19:05:12 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-05-15 08:56:46 +0200
commit627a601d1fcea0b3198654756d351b0b81600b49 (patch)
treecce07dc111de5981e8273933c7ea775dfcd1f5a4 /sw/qa/uibase/shells
parent4356790bdf493c68ab609468603ec57e98dd2dae (diff)
tdf#148979 Added option to update selected field
Added Uno command UpdateSelectedField, FN_UPDATE_SEL_FIELD to support updating a single selected field Change-Id: Ia1a2387e137f8a672a24056b13234d4275a77ca4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150450 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/uibase/shells')
-rw-r--r--sw/qa/uibase/shells/shells.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index 8c251cb09f87..c962f4a5d65e 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -28,6 +28,7 @@
#include <comphelper/string.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/sequence.hxx>
+#include <osl/thread.hxx>
#include <IDocumentContentOperations.hxx>
#include <cmdid.h>
@@ -1049,6 +1050,34 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testInsertTextFormFieldEndnote)
CPPUNIT_ASSERT_EQUAL(OUString("result"), aActual);
}
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateSelectedField)
+{
+ // Given an empty doc:
+ createSwDoc();
+ SwDoc* pDoc = getSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
+
+ // Insert a time field and select it:
+ dispatchCommand(mxComponent, ".uno:InsertTimeField", {});
+
+ pCursor->SetMark();
+ pCursor->Move(fnMoveBackward);
+
+ OUString aTimeFieldBefore, aTimeFieldAfter;
+ pWrtShell->GetSelectedText(aTimeFieldBefore);
+
+ // Wait for one second:
+ osl::Thread::wait(std::chrono::seconds(1));
+
+ // Update the field at cursor:
+ dispatchCommand(mxComponent, ".uno:UpdateSelectedField", {});
+ pWrtShell->GetSelectedText(aTimeFieldAfter);
+
+ // Check that the selected field has changed:
+ CPPUNIT_ASSERT(aTimeFieldAfter != aTimeFieldBefore);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */