Kaydet (Commit) dde9b4d8 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

uitest: some more work for the UI testing

Change-Id: I79193190f8f614b2d6a71032f05a0518eb9d1a1d
üst d5c3f1bf
......@@ -28,6 +28,12 @@
#define OOO_DLLPUBLIC_TEST SAL_DLLPUBLIC_IMPORT
#endif
#if defined DLLIMPLEMENTATION_UITEST
#define UITEST_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
#else
#define UITEST_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
#endif
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -9,20 +9,27 @@
#include <rtl/ustring.hxx>
#include <map>
#include <memory>
#include <vcl/window.hxx>
#include <test/testdllapi.hxx>
enum class UIObjectType
{
WINDOW,
DIALOG,
UNKNOWN
};
typedef std::map<const OUString, OUString> StringMap;
/**
* This class wraps a UI object like vcl::Window and provides
* an interface for the UI testing.
*
* This class should only have virtual methods.
*/
class UIObject
class UITEST_DLLPUBLIC UIObject
{
public:
......@@ -31,16 +38,36 @@ public:
/**
* returns the state of the wrapped UI object
*/
virtual std::map<const OUString, OUString> get_state();
virtual StringMap get_state();
/**
* executes an action on the wrapped UI object,
* possibly with some additional parameters
*/
virtual void execute(const OUString& rAction,
const std::map<const OUString, OUString>& rParameters);
const StringMap& rParameters);
virtual UIObjectType getType() const;
virtual std::unique_ptr<UIObject> get_child(const OUString& rID);
};
class WindowUIObject : public UIObject
{
VclPtr<vcl::Window> mxWindow;
public:
WindowUIObject(VclPtr<vcl::Window> xWindow);
virtual StringMap get_state() override;
virtual void execute(const OUString& rAction,
const StringMap& rParameters) override;
virtual UIObjectType getType() const override;
virtual UIObjectType getType();
virtual std::unique_ptr<UIObject> get_child(const OUString& rID);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -7,6 +7,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <test/testdllapi.hxx>
class UITEST_DLLPUBLIC UITest
{
public:
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -10,7 +10,7 @@
$(eval $(call gb_Library_Library,uitest))
$(eval $(call gb_Library_add_defs,uitest,\
-DOOO_DLLIMPLEMENTATION_UITEST \
-DDLLIMPLEMENTATION_UITEST \
))
$(eval $(call gb_Library_use_sdk_api,uitest))
......
......@@ -9,27 +9,98 @@
#include <test/uiobject.hxx>
#include <iostream>
UIObject::~UIObject()
{
}
std::map<const OUString, OUString> UIObject::get_state()
StringMap UIObject::get_state()
{
std::map<const OUString, OUString> aMap;
StringMap aMap;
aMap["NotImplemented"] = "NotImplemented";
return aMap;
}
void UIObject::execute(const OUString& /*rAction*/,
const std::map<const OUString, OUString>& /*rParameters*/)
const StringMap& /*rParameters*/)
{
// should never be called
throw std::exception();
}
UIObjectType UIObject::getType()
UIObjectType UIObject::getType() const
{
return UIObjectType::UNKNOWN;
}
std::unique_ptr<UIObject> UIObject::get_child(const OUString&)
{
return std::unique_ptr<UIObject>();
}
WindowUIObject::WindowUIObject(VclPtr<vcl::Window> xWindow):
mxWindow(xWindow)
{
}
StringMap WindowUIObject::get_state()
{
StringMap aMap;
aMap["Visible"] = OUString::boolean(mxWindow->IsVisible());
aMap["Enabled"] = OUString::boolean(mxWindow->IsEnabled());
if (mxWindow->GetParent())
aMap["Parent"] = mxWindow->GetParent()->get_id();
return aMap;
}
void WindowUIObject::execute(const OUString& rAction,
const StringMap& rParameters)
{
if (rAction == "SET")
{
for (auto itr = rParameters.begin(); itr != rParameters.end(); ++itr)
{
std::cout << itr->first;
}
}
}
UIObjectType WindowUIObject::getType() const
{
return UIObjectType::WINDOW;
}
namespace {
vcl::Window* findChild(vcl::Window* pParent, const OUString& rID)
{
if (!pParent)
return nullptr;
size_t nCount = pParent->GetChildCount();
for (size_t i = 0; i < nCount; ++i)
{
vcl::Window* pChild = pParent->GetChild(i);
if (pChild && pChild->get_id() == rID)
return pChild;
vcl::Window* pResult = findChild(pChild, rID);
if (pResult)
return pResult;
}
}
}
std::unique_ptr<UIObject> WindowUIObject::get_child(const OUString& rID)
{
vcl::Window* pWindow = findChild(mxWindow.get(), rID);
if (pWindow)
return std::unique_ptr<UIObject>(new WindowUIObject(pWindow));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1829,6 +1829,11 @@ void Window::KeyInput( const KeyEvent& rKEvt )
if (autoacc && cod.GetModifier () != 0x4000) return;
}
if (cod.IsShift() && cod.IsMod1() && cod.GetCode() == KEY_F12)
{
}
NotifyEvent aNEvt( MouseNotifyEvent::KEYINPUT, this, &rKEvt );
if ( !CompatNotify( aNEvt ) )
mpWindowImpl->mbKeyInput = true;
......
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