diff options
Diffstat (limited to 'sw/qa/uibase/shells')
-rw-r--r-- | sw/qa/uibase/shells/shells.cxx | 29 |
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: */ |