Kaydet (Commit) 522c0bb5 authored tarafından Jim Raykowski's avatar Jim Raykowski Kaydeden (comit) Thorsten Behrens

uitest for tdf#114724 headings outline tracking in Navigator

Change-Id: I4390c3d33d69ddd93880545f58d0ef81469c960d
Reviewed-on: https://gerrit.libreoffice.org/47865Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst acc1edd6
......@@ -65,6 +65,7 @@ class SwNavigationPI : public PanelLayout,
friend class SwNavigationChild;
friend class SwContentTree;
friend class SwGlobalTree;
friend class SwNavigationPIUIObject;
VclPtr<SwNavHelpToolBox> m_aContentToolBox;
VclPtr<ToolBox> m_aGlobalToolBox;
......@@ -157,6 +158,8 @@ public:
SwView* GetCreateView() const;
void CreateNavigationTool(const tools::Rectangle& rRect, bool bSetFocus, vcl::Window *pParent);
FactoryFunction GetUITestFactory() const override;
};
class SwNavigationChild : public SfxChildWindowContext
......
......@@ -38,6 +38,29 @@ private:
};
class SwNavigationPI;
class SwNavigationPIUIObject : public WindowUIObject
{
VclPtr<SwNavigationPI> mxSwNavigationPI;
public:
SwNavigationPIUIObject(const VclPtr<SwNavigationPI>& xSwNavigationPI);
virtual StringMap get_state() override;
virtual void execute(const OUString& rAction,
const StringMap& rParameters) override;
static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
protected:
OUString get_name() const override;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -12,6 +12,8 @@
#include <edtwin.hxx>
#include <view.hxx>
#include <wrtsh.hxx>
#include <navipi.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
SwEditWinUIObject::SwEditWinUIObject(const VclPtr<SwEditWin>& xEditWin):
WindowUIObject(xEditWin),
......@@ -96,6 +98,19 @@ void SwEditWinUIObject::execute(const OUString& rAction,
getWrtShell(mxEditWin).SelectText(nStartPos, nEndPos);
}
}
else if (rAction == "SIDEBAR")
{
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
DBG_ASSERT(pViewFrm, "SwEditWinUIObject::execute: no viewframe");
pViewFrm->ShowChildWindow(SID_SIDEBAR);
if (rParameters.find("PANEL") != rParameters.end())
{
auto itr = rParameters.find("PANEL");
OUString aVal = itr->second;
::sfx2::sidebar::Sidebar::ShowPanel(aVal, pViewFrm->GetFrame().GetFrameInterface());
}
}
else
WindowUIObject::execute(rAction, rParameters);
}
......@@ -112,4 +127,43 @@ std::unique_ptr<UIObject> SwEditWinUIObject::create(vcl::Window* pWindow)
return std::unique_ptr<UIObject>(new SwEditWinUIObject(pEditWin));
}
SwNavigationPIUIObject::SwNavigationPIUIObject(const VclPtr<SwNavigationPI>& xSwNavigationPI):
WindowUIObject(xSwNavigationPI),
mxSwNavigationPI(xSwNavigationPI)
{
}
StringMap SwNavigationPIUIObject::get_state()
{
StringMap aMap = WindowUIObject::get_state();
aMap["selectioncount"] = OUString::number(mxSwNavigationPI->m_aContentTree->GetSelectionCount());
return aMap;
}
void SwNavigationPIUIObject::execute(const OUString& rAction,
const StringMap& rParameters)
{
if (rAction == "ROOT")
{
mxSwNavigationPI->m_aContentToolBox->TriggerItem(mxSwNavigationPI->m_aContentToolBox->GetItemId("root"));
}
else
WindowUIObject::execute(rAction, rParameters);
}
std::unique_ptr<UIObject> SwNavigationPIUIObject::create(vcl::Window* pWindow)
{
SwNavigationPI* pSwNavigationPI = dynamic_cast<SwNavigationPI*>(pWindow);
assert(pSwNavigationPI);
return std::unique_ptr<UIObject>(new SwNavigationPIUIObject(pSwNavigationPI));
}
OUString SwNavigationPIUIObject::get_name() const
{
return OUString("SwNavigationPIUIObject");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -57,6 +57,8 @@
#include <unomid.h>
#include <memory>
#include <uiobject.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame;
......@@ -433,6 +435,11 @@ void SwNavigationPI::CreateNavigationTool(const tools::Rectangle& rRect, bool bS
}
}
FactoryFunction SwNavigationPI::GetUITestFactory() const
{
return SwNavigationPIUIObject::create;
}
void SwNavHelpToolBox::RequestHelp(const HelpEvent& rHEvt)
{
const sal_uInt16 nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
......
#
# 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/.
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict
import time
from uitest.path import get_srcdir_url
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/uitest/writer_tests/data/" + file_name
class tdf114724(UITestCase):
def test_track_headings_outline(self):
writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf114724.odt"))
xWriterDoc = self.xUITest.getTopFocusWindow()
xWriterEdit = xWriterDoc.getChild("writer_edit")
self.xUITest.executeCommand(".uno:Sidebar")
xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel")
xNavigatorPanel.executeAction("ROOT", tuple())
xWriterEdit.executeAction("FOCUS", tuple())
time.sleep(2)
self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
for _ in range(0,3):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
time.sleep(2)
self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
for _ in range(0,3):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
time.sleep(2)
self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
self.xUITest.executeCommand(".uno:Sidebar")
self.ui_test.close_doc()
......@@ -349,6 +349,10 @@ void WindowUIObject::execute(const OUString& rAction,
return;
}
}
else if (rAction == "FOCUS")
{
mxWindow->GrabFocus();
}
else
{
bHandled = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment