summaryrefslogtreecommitdiff
path: root/vcl/source/uitest/uiobject.cxx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-09-17 10:18:23 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2020-09-18 13:22:46 +0200
commit49667a6950709856b9a1a5d59ca78fdf682a53f4 (patch)
tree555e17eac9a081d5540492ee5d15dcfc88691472 /vcl/source/uitest/uiobject.cxx
parent433996f47b5354c0d936b07ba95440ac3354c620 (diff)
jsdialog: use window only if visible
When there is a name conflict we should take currently visible window. Change-Id: Iaccf03a78b083ecaca0ee6aa538674a6de093a4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102903 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102983 Tested-by: Jenkins
Diffstat (limited to 'vcl/source/uitest/uiobject.cxx')
-rw-r--r--vcl/source/uitest/uiobject.cxx33
1 files changed, 28 insertions, 5 deletions
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 8e3097d7d702..b768a80622d0 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -391,7 +391,7 @@ OUString WindowUIObject::get_type() const
namespace {
-vcl::Window* findChild(vcl::Window* pParent, const OUString& rID)
+vcl::Window* findChild(vcl::Window* pParent, const OUString& rID, bool bRequireVisible = false)
{
if (!pParent)
return nullptr;
@@ -403,12 +403,16 @@ vcl::Window* findChild(vcl::Window* pParent, const OUString& rID)
for (size_t i = 0; i < nCount; ++i)
{
vcl::Window* pChild = pParent->GetChild(i);
- if (pChild && pChild->get_id() == rID)
+ if (pChild && pChild->get_id() == rID
+ && (!bRequireVisible || pChild->IsVisible()))
return pChild;
- vcl::Window* pResult = findChild(pChild, rID);
- if (pResult)
- return pResult;
+ if (!bRequireVisible || pChild->IsVisible())
+ {
+ vcl::Window* pResult = findChild(pChild, rID);
+ if (pResult)
+ return pResult;
+ }
}
return nullptr;
@@ -458,6 +462,25 @@ std::unique_ptr<UIObject> WindowUIObject::get_child(const OUString& rID)
return aFunction(pWindow);
}
+std::unique_ptr<UIObject> WindowUIObject::get_visible_child(const OUString& rID)
+{
+ // in a first step try the real children before moving to the top level parent
+ // This makes it easier to handle cases with the same ID as there is a way
+ // to resolve conflicts
+ vcl::Window* pWindow = findChild(mxWindow.get(), rID, true);
+ if (!pWindow)
+ {
+ vcl::Window* pDialogParent = get_top_parent(mxWindow.get());
+ pWindow = findChild(pDialogParent, rID, true);
+ }
+
+ if (!pWindow)
+ throw css::uno::RuntimeException("Could not find child with id: " + rID);
+
+ FactoryFunction aFunction = pWindow->GetUITestFactory();
+ return aFunction(pWindow);
+}
+
std::set<OUString> WindowUIObject::get_children() const
{
vcl::Window* pDialogParent = get_top_parent(mxWindow.get());