[Libreoffice-commits] core.git: desktop/CppunitTest_desktop_lib.mk desktop/qa test/Package_unittest.mk test/user-template

Pranav Kant pranavk at collabora.com
Tue Apr 12 14:41:17 UTC 2016


 desktop/CppunitTest_desktop_lib.mk                                             |    2 
 desktop/qa/data/blank_presentation.odp                                         |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx                                    |  147 ++++++++++
 test/Package_unittest.mk                                                       |    3 
 test/user-template/user/config/soffice.cfg/modules/scalc/popupmenu/cell.xml    |   40 ++
 test/user-template/user/config/soffice.cfg/modules/simpress/popupmenu/page.xml |   49 +++
 test/user-template/user/config/soffice.cfg/modules/swriter/popupmenu/text.xml  |   53 +++
 7 files changed, 294 insertions(+)

New commits:
commit d76b1b5b06c064938986c0b921b8d537fdf8bf4c
Author: Pranav Kant <pranavk at collabora.com>
Date:   Fri Apr 8 20:08:38 2016 +0530

    lok context menu: unit test
    
    Change-Id: I244fbf4b98368c7c0d66cdd865e1243639727026
    Reviewed-on: https://gerrit.libreoffice.org/23985
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.com>

diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk
index 931b33f..9ce2a03 100644
--- a/desktop/CppunitTest_desktop_lib.mk
+++ b/desktop/CppunitTest_desktop_lib.mk
@@ -68,6 +68,8 @@ $(eval $(call gb_CppunitTest_use_components,desktop_lib,\
     sw/util/swd \
     sc/util/sc \
     sc/util/scd \
+    sd/util/sd \
+    sd/util/sdd \
     toolkit/util/tk \
     ucb/source/core/ucb1 \
     ucb/source/ucp/file/ucpfile1 \
diff --git a/desktop/qa/data/blank_presentation.odp b/desktop/qa/data/blank_presentation.odp
new file mode 100644
index 0000000..157901f
Binary files /dev/null and b/desktop/qa/data/blank_presentation.odp differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a00fde4..0f7bcbc 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -87,6 +87,9 @@ public:
     void testModifiedStatus();
     void testSheetOperations();
     void testSheetSelections();
+    void testContextMenuCalc();
+    void testContextMenuWriter();
+    void testContextMenuImpress();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
     CPPUNIT_TEST(testGetStyles);
@@ -109,6 +112,9 @@ public:
     CPPUNIT_TEST(testModifiedStatus);
     CPPUNIT_TEST(testSheetOperations);
     CPPUNIT_TEST(testSheetSelections);
+    CPPUNIT_TEST(testContextMenuCalc);
+    CPPUNIT_TEST(testContextMenuWriter);
+    CPPUNIT_TEST(testContextMenuImpress);
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference<lang::XComponent> mxComponent;
@@ -125,6 +131,10 @@ public:
     // for testModifiedStatus
     osl::Condition m_aStateChangedCondition;
     bool m_bModified;
+
+    // for testContextMenu{Calc, Writer}
+    osl::Condition m_aContextMenuCondition;
+    boost::property_tree::ptree m_aContextMenuResult;
 };
 
 LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
@@ -140,6 +150,9 @@ LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDoc
     case LOK_DOCTYPE_SPREADSHEET:
         aService = "com.sun.star.sheet.SpreadsheetDocument";
         break;
+    case LOK_DOCTYPE_PRESENTATION:
+        aService = "com.sun.star.presentation.PresentationDocument";
+        break;
     default:
         CPPUNIT_ASSERT(false);
         break;
@@ -209,6 +222,14 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
         }
     }
     break;
+    case LOK_CALLBACK_CONTEXT_MENU:
+    {
+        m_aContextMenuResult.clear();
+        std::stringstream aStream(pPayload);
+        boost::property_tree::read_json(aStream, m_aContextMenuResult);
+        m_aContextMenuCondition.set();
+    }
+    break;
     }
 }
 
@@ -872,6 +893,132 @@ void DesktopLOKTest::testSheetSelections()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+namespace {
+
+    void verifyContextMenuStructure(boost::property_tree::ptree& aRoot)
+    {
+        for (const auto& aItemPair: aRoot)
+        {
+            // This is an array, so no key
+            CPPUNIT_ASSERT_EQUAL(std::string(aItemPair.first.data()), std::string(""));
+
+            boost::property_tree::ptree aItemValue = aItemPair.second;
+            boost::optional<boost::property_tree::ptree&> aText = aItemValue.get_child_optional("text");
+            boost::optional<boost::property_tree::ptree&> aType = aItemValue.get_child_optional("type");
+            boost::optional<boost::property_tree::ptree&> aCommand = aItemValue.get_child_optional("command");
+            boost::optional<boost::property_tree::ptree&> aSubmenu = aItemValue.get_child_optional("menu");
+            boost::optional<boost::property_tree::ptree&> aEnabled = aItemValue.get_child_optional("enabled");
+            boost::optional<boost::property_tree::ptree&> aChecktype = aItemValue.get_child_optional("checktype");
+            boost::optional<boost::property_tree::ptree&> aChecked = aItemValue.get_child_optional("checked");
+
+            // type is omnipresent
+            CPPUNIT_ASSERT( aType );
+
+            // seperator doesn't have any other attribs
+            if ( aType.get().data() == "separator" )
+            {
+                CPPUNIT_ASSERT( !aText && !aCommand && !aSubmenu && !aEnabled && !aChecktype && !aChecked );
+            }
+            else if ( aType.get().data() == "command" )
+            {
+                CPPUNIT_ASSERT( aCommand && aText );
+            }
+            else if ( aType.get().data() == "menu")
+            {
+                CPPUNIT_ASSERT( aSubmenu && aText );
+                verifyContextMenuStructure( aSubmenu.get() );
+            }
+
+            if ( aChecktype )
+            {
+                CPPUNIT_ASSERT( aChecktype.get().data() == "radio" ||
+                                aChecktype.get().data() == "checkmark" ||
+                                aChecktype.get().data() == "auto" );
+
+                CPPUNIT_ASSERT( aChecked &&
+                                ( aChecked.get().data() == "true" || aChecked.get().data() == "false" ) );
+            }
+        }
+
+    }
+
+} // end anonymous namespace
+
+void DesktopLOKTest::testContextMenuCalc()
+{
+    comphelper::LibreOfficeKit::setActive();
+    LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET);
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
+    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+    // Values in twips
+    int row5 = 1150;
+    int col1 = 1100;
+
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+                                      col1, row5,
+                                      1, 4, 0);
+
+    TimeValue aTimeValue = {2 , 0}; // 2 seconds max
+    m_aContextMenuCondition.wait(aTimeValue);
+
+    CPPUNIT_ASSERT( !m_aContextMenuResult.empty() );
+    boost::optional<boost::property_tree::ptree&> aMenu = m_aContextMenuResult.get_child_optional("menu");
+    CPPUNIT_ASSERT( aMenu );
+    verifyContextMenuStructure( aMenu.get() );
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
+void DesktopLOKTest::testContextMenuWriter()
+{
+    comphelper::LibreOfficeKit::setActive();
+    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt", LOK_DOCTYPE_TEXT);
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
+    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+    Point aRandomPoint(1150, 1100);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+                                      aRandomPoint.X(), aRandomPoint.Y(),
+                                      1, 4, 0);
+
+    TimeValue aTimeValue = {2 , 0}; // 2 seconds max
+    m_aContextMenuCondition.wait(aTimeValue);
+
+    CPPUNIT_ASSERT( !m_aContextMenuResult.empty() );
+    boost::optional<boost::property_tree::ptree&> aMenu = m_aContextMenuResult.get_child_optional("menu");
+    CPPUNIT_ASSERT( aMenu );
+    verifyContextMenuStructure( aMenu.get() );
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
+void DesktopLOKTest::testContextMenuImpress()
+{
+    comphelper::LibreOfficeKit::setActive();
+    LibLODocument_Impl* pDocument = loadDoc("blank_presentation.odp", LOK_DOCTYPE_PRESENTATION);
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
+    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+    Point aRandomPoint(1150, 1100);
+    pDocument->pClass->postMouseEvent(pDocument,
+                                      LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+                                      aRandomPoint.X(), aRandomPoint.Y(),
+                                      1, 4, 0);
+
+    TimeValue aTimeValue = {2 , 0}; // 2 seconds max
+    m_aContextMenuCondition.wait(aTimeValue);
+
+    CPPUNIT_ASSERT( !m_aContextMenuResult.empty() );
+    boost::optional<boost::property_tree::ptree&> aMenu = m_aContextMenuResult.get_child_optional("menu");
+    CPPUNIT_ASSERT( aMenu );
+    verifyContextMenuStructure( aMenu.get() );
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/test/Package_unittest.mk b/test/Package_unittest.mk
index 77c4593..8001731 100644
--- a/test/Package_unittest.mk
+++ b/test/Package_unittest.mk
@@ -21,5 +21,8 @@ $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/sta
 $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/crdbus50.bau,user/autotext/en-US/crdbus50.bau))
 $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/.dummy,empty-directory-dummy))
 $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autocorr/acor_en-US.dat,user/autocorr/acor_fr.dat))
+$(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/modules/scalc/popupmenu/cell.xml,user/config/soffice.cfg/modules/scalc/popupmenu/cell.xml))
+$(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/modules/swriter/popupmenu/text.xml,user/config/soffice.cfg/modules/swriter/popupmenu/text.xml))
+$(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/modules/simpress/popupmenu/page.xml,user/config/soffice.cfg/modules/simpress/popupmenu/page.xml))
 
 # vim: set noet sw=4 ts=4:
diff --git a/test/user-template/user/config/soffice.cfg/modules/scalc/popupmenu/cell.xml b/test/user-template/user/config/soffice.cfg/modules/scalc/popupmenu/cell.xml
new file mode 100644
index 0000000..57ecd28
--- /dev/null
+++ b/test/user-template/user/config/soffice.cfg/modules/scalc/popupmenu/cell.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
+  <menu:menuitem menu:id=".uno:Cut"/>
+  <menu:menuitem menu:id=".uno:Copy"/>
+  <menu:menuitem menu:id=".uno:Paste"/>
+  <menu:menuitem menu:id=".uno:PasteSpecial"/>
+  <menu:menu menu:id=".uno:PasteOnly">
+    <menu:menupopup>
+      <menu:menuitem menu:id=".uno:PasteOnlyText"/>
+      <menu:menuitem menu:id=".uno:PasteOnlyValue"/>
+      <menu:menuitem menu:id=".uno:PasteOnlyFormula"/>
+    </menu:menupopup>
+  </menu:menu>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:ResetAttributes"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:FormatCellDialog"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:InsertCell"/>
+  <menu:menuitem menu:id=".uno:DeleteCell"/>
+  <menu:menuitem menu:id=".uno:Delete"/>
+  <menu:menuitem menu:id=".uno:MergeCells"/>
+  <menu:menuitem menu:id=".uno:SplitCell"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:InsertAnnotation"/>
+  <menu:menuitem menu:id=".uno:EditAnnotation"/>
+  <menu:menuitem menu:id=".uno:DeleteNote"/>
+  <menu:menuitem menu:id=".uno:ShowNote"/>
+  <menu:menuitem menu:id=".uno:HideNote"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:DataSelect"/>
+</menu:menupopup>
diff --git a/test/user-template/user/config/soffice.cfg/modules/simpress/popupmenu/page.xml b/test/user-template/user/config/soffice.cfg/modules/simpress/popupmenu/page.xml
new file mode 100644
index 0000000..02ff497
--- /dev/null
+++ b/test/user-template/user/config/soffice.cfg/modules/simpress/popupmenu/page.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
+  <menu:menuitem menu:id=".uno:Cut"/>
+  <menu:menuitem menu:id=".uno:Copy"/>
+  <menu:menuitem menu:id=".uno:Paste"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:SlideSetup"/>
+  <menu:menuitem menu:id=".uno:SelectBackground"/>
+  <menu:menuitem menu:id=".uno:SaveBackground"/>
+  <menu:menu menu:id=".uno:SlideFeaturesMenu">
+    <menu:menupopup>
+      <menu:menuitem menu:id=".uno:HideSlide"/>
+      <menu:menuitem menu:id=".uno:ShowSlide"/>
+      <menu:menuseparator/>
+      <menu:menuitem menu:id=".uno:DisplayMasterBackground"/>
+      <menu:menuitem menu:id=".uno:DisplayMasterObjects"/>
+      <menu:menuitem menu:id=".uno:MasterLayouts"/>
+      <menu:menuseparator/>
+      <menu:menuitem menu:id=".uno:PresentationLayout"/>
+    </menu:menupopup>
+  </menu:menu>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:ShowRuler"/>
+  <menu:menu menu:id=".uno:GridMenu">
+    <menu:menupopup>
+      <menu:menuitem menu:id=".uno:GridVisible"/>
+      <menu:menuitem menu:id=".uno:GridUse"/>
+      <menu:menuitem menu:id=".uno:GridFront"/>
+    </menu:menupopup>
+  </menu:menu>
+  <menu:menu menu:id=".uno:SnapLinesMenu">
+    <menu:menupopup>
+      <menu:menuitem menu:id=".uno:HelplinesVisible"/>
+      <menu:menuitem menu:id=".uno:HelplinesUse"/>
+      <menu:menuitem menu:id=".uno:HelplinesFront"/>
+    </menu:menupopup>
+  </menu:menu>
+  <menu:menuitem menu:id=".uno:CapturePoint"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:LeaveGroup"/>
+</menu:menupopup>
diff --git a/test/user-template/user/config/soffice.cfg/modules/swriter/popupmenu/text.xml b/test/user-template/user/config/soffice.cfg/modules/swriter/popupmenu/text.xml
new file mode 100644
index 0000000..a6a6021
--- /dev/null
+++ b/test/user-template/user/config/soffice.cfg/modules/swriter/popupmenu/text.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu">
+  <menu:menuitem menu:id=".uno:Cut"/>
+  <menu:menuitem menu:id=".uno:Copy"/>
+  <menu:menuitem menu:id=".uno:Paste"/>
+  <menu:menu menu:id=".uno:PasteSpecialMenu">
+    <menu:menupopup>
+      <menu:menuitem menu:id=".uno:PasteUnformatted"/>
+      <menu:menuitem menu:id=".uno:PasteSpecial"/>
+    </menu:menupopup>
+  </menu:menu>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:NumberingStart"/>
+  <menu:menuitem menu:id=".uno:ContinueNumbering"/>
+  <menu:menuitem menu:id=".uno:IncrementLevel"/>
+  <menu:menuitem menu:id=".uno:DecrementLevel"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:FontDialog"/>
+  <menu:menuitem menu:id=".uno:ParagraphDialog"/>
+  <menu:menuitem menu:id=".uno:OutlineBullet"/>
+  <menu:menuitem menu:id=".uno:PageDialog"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:UpdateCurIndex"/>
+  <menu:menuitem menu:id=".uno:EditCurIndex"/>
+  <menu:menuitem menu:id=".uno:RemoveTableOf"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:FieldDialog"/>
+  <menu:menuitem menu:id=".uno:EditFootnote"/>
+  <menu:menuitem menu:id=".uno:IndexEntryDialog"/>
+  <menu:menuitem menu:id=".uno:AuthoritiesEntryDialog"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:AcceptTrackedChange"/>
+  <menu:menuitem menu:id=".uno:RejectTrackedChange"/>
+  <menu:menuitem menu:id=".uno:NextTrackedChange"/>
+  <menu:menuitem menu:id=".uno:PreviousTrackedChange"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:EditStyle"/>
+  <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
+  <menu:menuitem menu:id=".uno:EditHyperlink"/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
+  <menu:menuitem menu:id=".uno:RemoveHyperlink"/>
+  <menu:menuitem menu:id=".uno:OpenSmartTagMenuOnCursor"/>
+  <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
+</menu:menupopup>


More information about the Libreoffice-commits mailing list