[Libreoffice-commits] core.git: sw/qa
Varun Dhall
varun.dhall at studentpartner.com
Wed Feb 3 10:06:27 UTC 2016
sw/qa/extras/uiwriter/uiwriter.cxx | 65 +++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
New commits:
commit cdffa289a32ba21ee30906e1268ec5962f1d88d9
Author: Varun Dhall <varun.dhall at studentpartner.com>
Date: Mon Feb 1 17:38:41 2016 +0530
Added Test for checking newly created writer document with AppYield
Change-Id: If331fb2b0c03cd153387ddad7b33bbc28727ac11
Reviewed-on: https://gerrit.libreoffice.org/21995
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 5d49784..53507f6 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -168,6 +168,7 @@ public:
void testTextTableCellNames();
void testShapeAnchorUndo();
void testDde();
+ void testDocModState();
void testTdf94804();
void testTdf34957();
void testTdf89954();
@@ -255,6 +256,7 @@ public:
CPPUNIT_TEST(testTextTableCellNames);
CPPUNIT_TEST(testShapeAnchorUndo);
CPPUNIT_TEST(testDde);
+ CPPUNIT_TEST(testDocModState);
CPPUNIT_TEST(testTdf94804);
CPPUNIT_TEST(testTdf34957);
CPPUNIT_TEST(testTdf89954);
@@ -2739,6 +2741,69 @@ void SwUiWriterTest::testDde()
CPPUNIT_ASSERT(xField->getString().endsWith("asdf"));
}
+//IdleTask class to add a low priority Idle task
+class IdleTask
+{
+ public:
+ bool GetFlag();
+ IdleTask();
+ DECL_LINK_TYPED( FlipFlag, Idle *, void );
+ ~IdleTask() {}
+ private:
+ bool flag;
+ Idle maIdle;
+};
+
+//constructor of IdleTask Class
+IdleTask::IdleTask() : flag( false )
+{
+ //setting the Priority of Idle task to LOW, LOWEST
+ maIdle.SetPriority( SchedulerPriority::LOWEST );
+ //set idle for callback
+ maIdle.SetIdleHdl( LINK( this, IdleTask, FlipFlag) );
+ //starting the idle
+ maIdle.Start();
+}
+
+//GetFlag() of IdleTask Class
+bool IdleTask::GetFlag()
+{
+ //returning the status of current flag
+ return this->flag;
+}
+
+//Callback function of IdleTask Class
+IMPL_LINK_TYPED(IdleTask, FlipFlag, Idle*, , void)
+{
+ //setting the flag to make sure that low priority idle task has been dispatched
+ this->flag = true;
+}
+
+void SwUiWriterTest::testDocModState()
+{
+ //creating a new writer document via the XDesktop(to have more shells etc.)
+ SwDoc* pDoc = createDoc();
+ //creating instance of IdleTask Class
+ IdleTask idleTask;
+ //checking the state of the document via IDocumentState
+ IDocumentState& rState(pDoc->getIDocumentState());
+ //the state should not be modified
+ CPPUNIT_ASSERT(!(rState.IsModified()));
+ //checking the state of the document via SfxObjectShell
+ SwDocShell* pShell(pDoc->GetDocShell());
+ CPPUNIT_ASSERT(!(pShell->IsModified()));
+ //looping around yield until low priority idle task is dispatched and flag is flipped
+ while(!idleTask.GetFlag())
+ {
+ //dispatching all the events via VCL main-loop
+ Application::Yield();
+ }
+ //again checking for the state via IDocumentState
+ CPPUNIT_ASSERT(!(rState.IsModified()));
+ //again checking for the state via SfxObjectShell
+ CPPUNIT_ASSERT(!(pShell->IsModified()));
+}
+
void SwUiWriterTest::testTdf94804()
{
//create new writer document
More information about the Libreoffice-commits
mailing list