Skip to content

Commit eab68c7

Browse files
author
Mykola Tryshnivskyy
committed
Merge branch 'WD_1.X_dev' of https://portal-ua.globallogic.com/git/wd into WD_1.X_dev
2 parents e84ae02 + 7b6b70d commit eab68c7

15 files changed

+96
-53
lines changed

inc/extension_qt/q_view_executor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class QViewCmdExecutor : public ViewCmdExecutor {
3838
virtual void SendKeys(const string16& keys, Error** error);
3939
virtual void Close(Error** error);
4040
virtual void SwitchTo(Error** error);
41+
virtual void FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error);
4142
virtual void GetAlertMessage(std::string* text, Error** error);
4243
virtual void SetAlertPromptText(const std::string& alert_prompt_text, Error** error);
4344
virtual void AcceptOrDismissAlert(bool accept, Error** error);

inc/extension_qt/wd_event_dispatcher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class WDEventDispatcher
1515
static WDEventDispatcher *getInstance();
1616
void add(EventDispatcher *dispatcher);
1717
QVector<EventDispatcher*>& getDispatchers();
18+
bool dispatch(QEvent *event);
1819

1920
private:
2021
static WDEventDispatcher *_instance;

inc/extension_qt/widget_view_executor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class QWidgetViewCmdExecutor : public QViewCmdExecutor {
6060
virtual void ElementSubmit(const ElementId& element, Error** error) NOT_SUPPORTED_IMPL;
6161
virtual void GetElementText(const ElementId& element, std::string* element_text, Error** error);
6262
virtual void GetElementCssProperty(const ElementId& element, const std::string& property, base::Value** value, Error** error) NOT_SUPPORTED_IMPL;
63-
virtual void FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error);
6463
virtual void FindElements(const ElementId& root_element, const std::string& locator, const std::string& query, std::vector<ElementId>* elements, Error** error);
6564
virtual void ActiveElement(ElementId* element, Error** error);
6665
virtual void SwitchToFrameWithNameOrId(const std::string& name_or_id, Error** error) NOT_SUPPORTED_IMPL;

inc/webdriver_route_table.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ class RouteTable {
138138
bool AddRoute(const std::string& uri_pattern,
139139
const CommandCreatorPtr& creator);
140140

141+
// check custom prefix, should be of the form:
142+
// '-' + vendor prefix + '-' + command name
143+
// return true if prefix correct
144+
bool CheckCustomPrefix(const std::string& prefix);
145+
141146
// return true if pattern1 is bestmatch then pattern2
142147
bool CompareBestMatch(const std::string& uri_pattern1, const std::string& uri_pattern2);
143148

inc/webdriver_switches.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class Switches {
6767
/// Web inspector listening port (by default - 9222)
6868
static const char kWIPort[];
6969

70+
/// \page page_webdriver_switches WD Server switches
71+
/// - <b>vnc</b><br>
72+
/// Enabling VNC support (by default - false)
73+
static const char kVNCEnabled[];
74+
7075
};
7176

7277
} // namespace webdriver

src/Test/main.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include "extension_qt/vnc_event_dispatcher.h"
5454

5555
#include "vnc/vncclient.h"
56+
#include "webdriver_switches.h"
5657

5758
void setQtSettings();
5859
void PrintVersion();
@@ -143,7 +144,13 @@ int main(int argc, char *argv[])
143144
VNCClient *client = new VNCClient();
144145
client->Init("http://127.0.0.1", 5900);
145146

146-
WDEventDispatcher::getInstance()->add(new VNCEventDispatcher(client));
147+
148+
CommandLine cmdLine = webdriver::Server::GetInstance()->GetCommandLine();
149+
150+
if (cmdLine.HasSwitch(webdriver::Switches::kVNCEnabled))
151+
{
152+
WDEventDispatcher::getInstance()->add(new VNCEventDispatcher(client));
153+
}
147154

148155
setQtSettings();
149156
wd_server->Start();

src/vnc/vncclient.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <iostream>
44
#include <QtNetwork/QHostAddress>
55
#include <QtCore/QMap>
6-
#include <X11/keysymdef.h>
76

87
#define MAJOR_INDEX 6
98
#define MINOR_INDEX 10

src/webdriver/extension_qt/q_view_executor.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ void QViewCmdExecutor::SetBounds(const Rect& bounds, Error** error) {
7575
if (NULL == view)
7676
return;
7777

78+
if (!view->isTopLevel()) {
79+
*error = new Error(kUnknownError, "Cant set bounds to non top level view.");
80+
return;
81+
}
82+
7883
view->setGeometry(ConvertRectToQRect(bounds));
7984
}
8085

@@ -185,6 +190,15 @@ void QViewCmdExecutor::SwitchTo(Error** error) {
185190
session_->logger().Log(kInfoLogLevel, "SwitchTo - set current view ("+view_id_.id()+")");
186191
}
187192

193+
void QViewCmdExecutor::FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error) {
194+
std::vector<ElementId> elements;
195+
FindElements(root_element, locator, query, &elements, error);
196+
if (*error == NULL && !elements.empty())
197+
*element = elements[0];
198+
else if(*error == NULL)
199+
*error = new Error(kNoSuchElement);
200+
}
201+
188202
void QViewCmdExecutor::GetAlertMessage(std::string* text, Error** error) {
189203
QWidget* view = getView(view_id_, error);
190204
if (NULL == view)

src/webdriver/extension_qt/wd_event_dispatcher.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,15 @@ QVector<EventDispatcher*>& WDEventDispatcher::getDispatchers()
3030
{
3131
return _dispatchers;
3232
}
33+
34+
bool WDEventDispatcher::dispatch(QEvent *event)
35+
{
36+
bool consumed = false;
37+
QVector<EventDispatcher*> dispatchers = WDEventDispatcher::getInstance()->getDispatchers();
38+
foreach (EventDispatcher* item, dispatchers)
39+
{
40+
consumed |= item->dispatch(event, consumed);
41+
}
42+
43+
return consumed;
44+
}

src/webdriver/extension_qt/web_view_executor.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,8 @@ void QWebViewCmdExecutor::SendKeys(const ElementId& element, const string16& key
330330
std::vector<QKeyEvent>::iterator it = key_events.begin();
331331
while (it != key_events.end()) {
332332

333-
//////////////////////
334-
bool consumed = false;
335-
QVector<EventDispatcher*> dispatchers = WDEventDispatcher::getInstance()->getDispatchers();
336-
foreach (EventDispatcher* item, dispatchers)
337-
{
338-
consumed |= item->dispatch(&(*it), consumed);
339-
}
340-
//////////////////////
333+
bool consumed = WDEventDispatcher::getInstance()->dispatch(&(*it));
334+
341335
if (!consumed)
342336
qApp->sendEvent(view, &(*it));
343337
++it;

0 commit comments

Comments
 (0)