summaryrefslogtreecommitdiff
path: root/vcl/source/uitest/uiobject.cxx
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-01-09 05:13:47 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-06-18 17:01:27 +0200
commitd79f69ca93ace838201ff575200b7587dc082160 (patch)
tree4bf4033bfee06ed36e76cc7c51cd6cb67ea5b663 /vcl/source/uitest/uiobject.cxx
parent41160b5ed4be15bf0e57ff9ebd492429a14ebb71 (diff)
uitest: set text through key events in ui tests
This is much closer to what happens when a user inputs some text and ensures that the modify handler is called. At some point we need to introduce a general keyboard handling. This includes functions like DEL, RETURN, ... Change-Id: I0561d8ff83bbf93c460be82634b4d3a23b42b68b
Diffstat (limited to 'vcl/source/uitest/uiobject.cxx')
-rw-r--r--vcl/source/uitest/uiobject.cxx27
1 files changed, 26 insertions, 1 deletions
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 94e3a7d2e65a..869f0474f64b 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -10,7 +10,10 @@
#include "uitest/uiobject_impl.hxx"
#include "uitest/factory.hxx"
+#include <vcl/event.hxx>
+
#include <iostream>
+#include <vector>
#define DUMP_UITEST(x) SAL_INFO("vcl.uitest", x)
@@ -241,6 +244,22 @@ EditUIObject::EditUIObject(VclPtr<Edit> xEdit):
{
}
+namespace {
+
+std::vector<KeyEvent> generate_key_events_from_text(const OUString& rStr)
+{
+ std::vector<KeyEvent> aEvents;
+ vcl::KeyCode aCode;
+ for (sal_Int32 i = 0, n = rStr.getLength();
+ i != n; ++i)
+ {
+ aEvents.push_back(KeyEvent(rStr[i], aCode));
+ }
+ return aEvents;
+}
+
+}
+
void EditUIObject::execute(const OUString& rAction,
const StringMap& rParameters)
{
@@ -249,7 +268,13 @@ void EditUIObject::execute(const OUString& rAction,
if (rParameters.find("TEXT") != rParameters.end())
{
assert(rParameters.size() == 1); // only the text
- mxEdit->SetText(rParameters.find("TEXT")->second);
+ const OUString& rText = rParameters.find("TEXT")->second;
+ auto aKeyEvents = generate_key_events_from_text(rText);
+ for (auto itr = aKeyEvents.begin(), itrEnd = aKeyEvents.end();
+ itr != itrEnd; ++itr)
+ {
+ mxEdit->KeyInput(*itr);
+ }
}
else if (rParameters.find("SELECTION") != rParameters.end())
{