lok context menu: unit test
Change-Id: I244fbf4b98368c7c0d66cdd865e1243639727026 Reviewed-on: https://gerrit.libreoffice.org/23985 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.com>
This commit is contained in:
parent
2e18f598c7
commit
d76b1b5b06
7 changed files with 294 additions and 0 deletions
|
@ -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 \
|
||||
|
|
BIN
desktop/qa/data/blank_presentation.odp
Normal file
BIN
desktop/qa/data/blank_presentation.odp
Normal file
Binary file not shown.
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
Loading…
Reference in a new issue