[Libreoffice-commits] .: starmath/qa

Caolán McNamara caolan at kemper.freedesktop.org
Mon Nov 29 08:49:08 PST 2010


 starmath/qa/cppunit/makefile.mk       |    1 
 starmath/qa/cppunit/test_starmath.cxx |  105 +++++++++++++++++++++++++---------
 2 files changed, 81 insertions(+), 25 deletions(-)

New commits:
commit 0187b10e2935ccf7bbc8106bcccead6eae9683f9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 29 16:48:58 2010 +0000

    implement tmEditAllClipboard equivalent cppunit test

diff --git a/starmath/qa/cppunit/makefile.mk b/starmath/qa/cppunit/makefile.mk
index 0433b20..ff6e81d 100644
--- a/starmath/qa/cppunit/makefile.mk
+++ b/starmath/qa/cppunit/makefile.mk
@@ -114,6 +114,7 @@ $(MISC)/$(TARGET)/services.rdb .ERRREMOVE : $(MISC)/$(TARGET)/udkapi.rdb
         -c $(DLLPRE)fwk$(DLLPOSTFIX)$(DLLPOST) \
         -c $(DLLPRE)tk$(DLLPOSTFIX)$(DLLPOST) \
         -c $(DLLPRE)sfx$(DLLPOSTFIX)$(DLLPOST) \
+        -c $(DLLPRE)vcl$(DLLPOSTFIX)$(DLLPOST) \
         -c i18npool.uno$(DLLPOST)
 
 #Tweak things so that we use the .res files in the solver
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index 9dbba0d..950390a 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -48,8 +48,9 @@ public:
     // tests
     void createDocument();
     void tmEditUndoRedo(SmDocShellRef &rDocShRef);
+    void tmEditAllClipboard(SmEditWindow &rEditWindow);
+    void tmEditMarker(SmEditWindow &rEditWindow);
     void tmEditFailure(SmDocShellRef &rDocShRef);
-    void tmEditMarker(SfxViewFrame &rViewShell);
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(createDocument);
@@ -82,43 +83,88 @@ void Test::tearDown()
     uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
 }
 
-void Test::tmEditMarker(SfxViewFrame &rViewFrame)
+void Test::tmEditMarker(SmEditWindow &rEditWindow)
 {
-    SfxBindings aBindings;
-    SfxDispatcher aDispatcher(&rViewFrame);
-    aBindings.SetDispatcher(&aDispatcher);
-    SmCmdBoxWindow aSmCmdBoxWindow(&aBindings, NULL, NULL);
-    SmEditWindow aEditWindow(aSmCmdBoxWindow);
-    aEditWindow.Flush();
-
     {
         rtl::OUString sMarkedText(RTL_CONSTASCII_USTRINGPARAM("<?> under <?> under <?>"));
-        aEditWindow.SetText(sMarkedText);
-        aEditWindow.Flush();
-        rtl::OUString sFinalText = aEditWindow.GetText();
+        rEditWindow.SetText(sMarkedText);
+        rEditWindow.Flush();
+        rtl::OUString sFinalText = rEditWindow.GetText();
         CPPUNIT_ASSERT_MESSAGE("Should be equal text", sFinalText == sMarkedText);
     }
 
     {
         rtl::OUString sTargetText(RTL_CONSTASCII_USTRINGPARAM("a under b under c"));
 
-        aEditWindow.SelNextMark();
-        aEditWindow.Cut();
-        aEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a")));
+        rEditWindow.SelNextMark();
+        rEditWindow.Cut();
+        rEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a")));
 
-        aEditWindow.SelNextMark();
-        aEditWindow.SelNextMark();
-        aEditWindow.Cut();
-        aEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("c")));
+        rEditWindow.SelNextMark();
+        rEditWindow.SelNextMark();
+        rEditWindow.Cut();
+        rEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("c")));
 
-        aEditWindow.SelPrevMark();
-        aEditWindow.Cut();
-        aEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("b")));
+        rEditWindow.SelPrevMark();
+        rEditWindow.Cut();
+        rEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("b")));
 
-        aEditWindow.Flush();
-        rtl::OUString sFinalText = aEditWindow.GetText();
+        rEditWindow.Flush();
+        rtl::OUString sFinalText = rEditWindow.GetText();
         CPPUNIT_ASSERT_MESSAGE("Should be a under b under c", sFinalText == sTargetText);
     }
+
+    {
+        rEditWindow.SetText(rtl::OUString());
+        rEditWindow.Flush();
+    }
+}
+
+void Test::tmEditAllClipboard(SmEditWindow &rEditWindow)
+{
+    rtl::OUString sOriginalText(RTL_CONSTASCII_USTRINGPARAM("a over b"));
+
+    {
+        rEditWindow.SetText(sOriginalText);
+        rEditWindow.Flush();
+        rtl::OUString sFinalText = rEditWindow.GetText();
+        CPPUNIT_ASSERT_MESSAGE("Should be equal text", sFinalText == sOriginalText);
+    }
+
+    {
+        rEditWindow.SelectAll();
+        rEditWindow.Cut();
+        rEditWindow.Flush();
+        rtl::OUString sFinalText = rEditWindow.GetText();
+        CPPUNIT_ASSERT_MESSAGE("Should be empty", !sFinalText.getLength());
+    }
+
+    {
+        rEditWindow.Paste();
+        rEditWindow.Flush();
+        rtl::OUString sFinalText = rEditWindow.GetText();
+        CPPUNIT_ASSERT_MESSAGE("Should be equal text", sFinalText == sOriginalText);
+    }
+
+    {
+        rEditWindow.SelectAll();
+        rEditWindow.Copy();
+    }
+
+    {
+        rtl::OUString sExpectedText(RTL_CONSTASCII_USTRINGPARAM("a over ba over b"));
+
+        rEditWindow.Paste();
+        rEditWindow.Paste();
+        rEditWindow.Flush();
+        rtl::OUString sFinalText = rEditWindow.GetText();
+        CPPUNIT_ASSERT_MESSAGE("Should be equal text", sFinalText == sExpectedText);
+    }
+
+    {
+        rEditWindow.SetText(rtl::OUString());
+        rEditWindow.Flush();
+    }
 }
 
 void Test::tmEditFailure(SmDocShellRef &rDocShRef)
@@ -215,7 +261,16 @@ void Test::createDocument()
 
     tmEditUndoRedo(xDocShRef);
     tmEditFailure(xDocShRef);
-    tmEditMarker(*pViewFrame);
+
+    SfxBindings aBindings;
+    SfxDispatcher aDispatcher(pViewFrame);
+    aBindings.SetDispatcher(&aDispatcher);
+    SmCmdBoxWindow aSmCmdBoxWindow(&aBindings, NULL, NULL);
+    SmEditWindow aEditWindow(aSmCmdBoxWindow);
+    aEditWindow.Flush();
+
+    tmEditMarker(aEditWindow);
+    tmEditAllClipboard(aEditWindow);
 
     xDocShRef.Clear();
 }


More information about the Libreoffice-commits mailing list