Commits

Anonymous committed d15814d

Swbookmarkfixes01: testing hints

Comments (0)

Files changed (2)

sw/qa/core/PageDescManager/PageDescManagerTest.cxx

 #include <svl/style.hxx>
 #include <editeng/frmdir.hxx>
 #include <set>
+#include <vector>
 
 #define _SWATRSET_HXX
 #include <svl/itemset.hxx>
 
 
 using namespace ::boost;
+using namespace ::std;
 using namespace ::sw::pagedesc;
+using namespace ::sw::style;
 using namespace ::sw::mock;
-
+namespace
+{
+    struct BroadcastRecorder : public SfxListener
+    {
+        typedef pair< SfxBroadcaster*, shared_ptr<const SfxHint> > record_type;
+        typedef vector<record_type> container_type;
+        container_type m_vHints;
+        virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+        {
+            if( const StyleOperationHint* pStyleHint = dynamic_cast<const StyleOperationHint*>(&rHint) )
+                RecordHint(rBC, new StyleOperationHint(*pStyleHint));
+            else if( const CheckPageDescHint* pCeckPDHint = dynamic_cast<const CheckPageDescHint*>(&rHint) )
+                RecordHint(rBC, new CheckPageDescHint(*pCeckPDHint));
+            else if( const PageDescDisposingHint* pPDDisposeHint = dynamic_cast<const PageDescDisposingHint*>(&rHint) )
+                RecordHint(rBC, new PageDescDisposingHint(*pPDDisposeHint));
+            else
+                RecordHint(rBC, new SfxHint(rHint));
+        }
+        void RecordHint(SfxBroadcaster& rBC, const SfxHint* pHint)
+        {
+            record_type aRecord(&rBC, shared_ptr<const SfxHint>(pHint));
+            m_vHints.push_back(aRecord);
+        }
+    };
+}
 namespace sw { namespace test
 {
 
             scoped_ptr<SwAttrPool> m_pPool;
             scoped_ptr<SfxBroadcaster> m_pStyleOperationBroadcaster;
             scoped_ptr<SfxBroadcaster> m_pModelEventBroadcaster;
+            scoped_ptr<BroadcastRecorder> m_pBroadcastRecorder;
             scoped_ptr<IDocumentPageDescAccess> m_pPageDescAccess;
             static const String our_sName;
             static const String our_sOtherName;
         m_pPool.get(),
         m_pStyleOperationBroadcaster.get(),
         m_pModelEventBroadcaster.get()));
+    m_pBroadcastRecorder.reset(new BroadcastRecorder());
+    m_pBroadcastRecorder->StartListening(*m_pStyleOperationBroadcaster);
+    m_pBroadcastRecorder->StartListening(*m_pModelEventBroadcaster);
     CPPUNIT_ASSERT(m_pPageDescAccess.get()!=NULL);
 }
 
     CPPUNIT_ASSERT(pPageDesc!=NULL);
     CPPUNIT_ASSERT(m_pPageDescAccess->GetPageDescCnt() == nPrecount+1);
     CPPUNIT_ASSERT(our_sName == pPageDesc->GetName());
+
+    CPPUNIT_ASSERT(m_pBroadcastRecorder->m_vHints.size() == 0);
 }
 
 void PageDescManagerTest::MakePageDesc_Copy()
     CPPUNIT_ASSERT(pPageDesc->GetPoolHelpId() == USHRT_MAX);
     CPPUNIT_ASSERT(pPageDesc->GetPoolHlpFileId() == UCHAR_MAX);
     CPPUNIT_ASSERT(m_pPageDescAccess->GetPageDescByPoolFmtId(0xdead)==pPageDescTemplate);
+    CPPUNIT_ASSERT(m_pBroadcastRecorder->m_vHints.empty());
 }
 
 void PageDescManagerTest::MakePageDesc_Undo()
     m_pPageDescAccess->MakePageDesc(our_sOtherName);
     CPPUNIT_ASSERT(m_pUndoRedo->m_vUndos.empty());
     CPPUNIT_ASSERT(m_pUndoRedo->m_isModified);
+    CPPUNIT_ASSERT(m_pBroadcastRecorder->m_vHints.empty());
 
     m_pUndoRedo->m_isModified = false;
     m_pUndoRedo->m_vUndos.clear();
     CPPUNIT_ASSERT(m_pUndoRedo->m_vUndos.size()==1);
     CPPUNIT_ASSERT(dynamic_cast<SwUndoPageDescCreate*>(m_pUndoRedo->m_vUndos[0].get())!=NULL);
     CPPUNIT_ASSERT(m_pUndoRedo->m_isModified);
+    CPPUNIT_ASSERT(m_pBroadcastRecorder->m_vHints.empty());
 }
 
 void PageDescManagerTest::GetPageDescCnt()
     m_pPageDescAccess->MakePageDesc(our_sName);
     CPPUNIT_ASSERT(m_pPageDescAccess->GetPageDescByName(our_sName)!=NULL);
     CPPUNIT_ASSERT(m_pPageDescAccess->GetPageDescByName(our_sOtherName)==NULL);
+    CPPUNIT_ASSERT(m_pBroadcastRecorder->m_vHints.empty());
 }
 
 void PageDescManagerTest::GetPageDescByPoolFmtId()
     pPageDesc->SetPoolFmtId(nId);
     CPPUNIT_ASSERT(m_pPageDescAccess->GetPageDescByPoolFmtId(nId)==pPageDesc);
     CPPUNIT_ASSERT(m_pPageDescAccess->GetPageDescByPoolFmtId(nOtherId)==NULL);
+    CPPUNIT_ASSERT(m_pBroadcastRecorder->m_vHints.empty());
 }
 
 void PageDescManagerTest::GetDefaultPageDesc()
     m_pPageDescAccess->MakePageDesc(our_sThirdName);
     m_pPageDescAccess->MakePageDesc(our_sFourthName);
     CPPUNIT_ASSERT(m_pPageDescAccess->GetDefaultPageDesc()==pPageDesc);
+    CPPUNIT_ASSERT(m_pBroadcastRecorder->m_vHints.empty());
 }
 
 void PageDescManagerTest::DelPageDesc()
     m_pPageDescAccess->DelPageDesc(our_sOtherName);
     CPPUNIT_ASSERT(--nCount==m_pPageDescAccess->GetPageDescCnt());
     CPPUNIT_ASSERT(m_pPageDescAccess->GetPageDescByName(our_sOtherName)==NULL);
+    const BroadcastRecorder::container_type* pHints(&m_pBroadcastRecorder->m_vHints);
+    CPPUNIT_ASSERT(pHints->size() == 1);
+    CPPUNIT_ASSERT((*pHints)[0].first == m_pModelEventBroadcaster.get());
+    CPPUNIT_ASSERT(dynamic_cast<const PageDescDisposingHint*>((*pHints)[0].second.get()));
 
     nCount = m_pPageDescAccess->GetPageDescCnt();
     m_pPageDescAccess->DelPageDesc(m_pPageDescAccess->GetDefaultPageDesc()->GetName());
     CPPUNIT_ASSERT(nCount==m_pPageDescAccess->GetPageDescCnt());
     CPPUNIT_ASSERT(m_pPageDescAccess->GetDefaultPageDesc());
+    CPPUNIT_ASSERT(pHints->size() == 1);
 }
 
 void PageDescManagerTest::DelPageDesc_Undo()
     CPPUNIT_ASSERT(!m_pPageDescAccess->GetPageDescByName(our_sThirdName));
     CPPUNIT_ASSERT(!m_pPageDescAccess->GetPageDescByName(our_sFourthName));
     CPPUNIT_ASSERT(m_pPageDescAccess->GetDefaultPageDesc());
+
+    const BroadcastRecorder::container_type* pHints(&m_pBroadcastRecorder->m_vHints);
+    CPPUNIT_ASSERT(pHints->size() == 3);
+    CPPUNIT_ASSERT((*pHints)[0].first == m_pModelEventBroadcaster.get());
+    CPPUNIT_ASSERT((*pHints)[1].first == m_pModelEventBroadcaster.get());
+    CPPUNIT_ASSERT((*pHints)[2].first == m_pModelEventBroadcaster.get());
+    CPPUNIT_ASSERT(dynamic_cast<const PageDescDisposingHint*>((*pHints)[0].second.get()));
+    CPPUNIT_ASSERT(dynamic_cast<const PageDescDisposingHint*>((*pHints)[1].second.get()));
+    CPPUNIT_ASSERT(dynamic_cast<const PageDescDisposingHint*>((*pHints)[2].second.get()));
 }
 
 namespace
         {
             m_vNames.insert(pPageDesc->GetName());
         }
-        ::std::set<String> m_vNames;
+        set<String> m_vNames;
     };
 }
 
 void PageDescManagerTest::ForEach()
 {
     Setup();
-    ::std::set<String> vNames;
+    set<String> vNames;
     m_pPageDescAccess->MakePageDesc(our_sName);
     m_pPageDescAccess->MakePageDesc(our_sOtherName);
     m_pPageDescAccess->MakePageDesc(our_sThirdName);

sw/source/ui/wrtsh/makefile.mk

         $(SLO)$/move.obj \
         $(SLO)$/select.obj \
         $(SLO)$/wrtsh1.obj \
-        $(SLO)$/wrtsh1.obj \
-        $(SLO)$/wrtsh2.obj \
         $(SLO)$/wrtsh2.obj \
         $(SLO)$/wrtsh3.obj \
         $(SLO)$/wrtsh4.obj \
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.