Skip to content

Commit 57c2cf3

Browse files
committed
added stubs for qml web view executor
1 parent bc0378c commit 57c2cf3

File tree

4 files changed

+568
-1
lines changed

4 files changed

+568
-1
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#ifndef WEBDRIVER_QML_WEB_VIEW_EXECUTOR_H
2+
#define WEBDRIVER_QML_WEB_VIEW_EXECUTOR_H
3+
4+
#include <string>
5+
#include <vector>
6+
#include <map>
7+
8+
#include "webdriver_view_executor.h"
9+
#include "webdriver_error.h"
10+
#include "extension_qt/qdeclarativewebview.h"
11+
12+
#include <QtCore/QDebug>
13+
14+
namespace webdriver {
15+
16+
class QmlWebViewCmdExecutorCreator : public ViewCmdExecutorCreator {
17+
public:
18+
static const ViewType QML_WEB_VIEW_TYPE;
19+
20+
QmlWebViewCmdExecutorCreator();
21+
virtual ~QmlWebViewCmdExecutorCreator();
22+
23+
virtual ViewCmdExecutor* CreateExecutor(Session* session, ViewId viewId) const;
24+
virtual bool CanHandleView(Session* session, ViewId viewId, ViewType* viewType = NULL) const;
25+
private:
26+
27+
DISALLOW_COPY_AND_ASSIGN(QmlWebViewCmdExecutorCreator);
28+
};
29+
30+
#define NOT_SUPPORTED_IMPL {*error = new Error(kCommandNotSupported, "Current view doesnt support this command.");}
31+
32+
class QmlWebViewCmdExecutor : public ViewCmdExecutor {
33+
public:
34+
explicit QmlWebViewCmdExecutor(Session* session, ViewId viewId);
35+
virtual ~QmlWebViewCmdExecutor();
36+
37+
virtual void CanHandleUrl(const std::string& url, bool* can, Error **error);
38+
virtual void GetTitle(std::string* title, Error **error);
39+
virtual void GetWindowName(std::string* name, Error ** error);
40+
virtual void GetBounds(Rect *bounds, Error **error);
41+
virtual void SetBounds(const Rect& bounds, Error** error) NOT_SUPPORTED_IMPL;
42+
virtual void Maximize(Error** error) NOT_SUPPORTED_IMPL;
43+
virtual void GetScreenShot(std::string* png, Error** error);
44+
virtual void GoForward(Error** error);
45+
virtual void GoBack(Error** error);
46+
virtual void Reload(Error** error);
47+
virtual void GetSource(std::string* source, Error** error);
48+
virtual void SendKeys(const string16& keys, Error** error);
49+
virtual void SendKeys(const ElementId& element, const string16& keys, Error** error);
50+
virtual void Close(Error** error) NOT_SUPPORTED_IMPL;
51+
virtual void MouseDoubleClick(Error** error);
52+
virtual void MouseButtonUp(Error** error);
53+
virtual void MouseButtonDown(Error** error);
54+
virtual void MouseClick(MouseButton button, Error** error);
55+
virtual void MouseMove(const int x_offset, const int y_offset, Error** error);
56+
virtual void MouseMove(const ElementId& element, int x_offset, const int y_offset, Error** error);
57+
virtual void MouseMove(const ElementId& element, Error** error);
58+
virtual void ClickElement(const ElementId& element, Error** error);
59+
virtual void GetAttribute(const ElementId& element, const std::string& key, base::Value** value, Error** error);
60+
virtual void ClearElement(const ElementId& element, Error** error);
61+
virtual void IsElementDisplayed(const ElementId& element, bool ignore_opacity, bool* is_displayed, Error** error);
62+
virtual void IsElementEnabled(const ElementId& element, bool* is_enabled, Error** error);
63+
virtual void ElementEquals(const ElementId& element1, const ElementId& element2, bool* is_equal, Error** error);
64+
virtual void GetElementLocation(const ElementId& element, Point* location, Error** error);
65+
virtual void GetElementLocationInView(const ElementId& element, Point* location, Error** error);
66+
virtual void GetElementTagName(const ElementId& element, std::string* tag_name, Error** error);
67+
virtual void IsOptionElementSelected(const ElementId& element, bool* is_selected, Error** error);
68+
virtual void SetOptionElementSelected(const ElementId& element, bool selected, Error** error);
69+
virtual void GetElementSize(const ElementId& element, Size* size, Error** error);
70+
virtual void ElementSubmit(const ElementId& element, Error** error);
71+
virtual void GetElementText(const ElementId& element, std::string* element_text, Error** error);
72+
virtual void GetElementCssProperty(const ElementId& element, const std::string& property, base::Value** value, Error** error);
73+
virtual void FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error);
74+
virtual void FindElements(const ElementId& root_element, const std::string& locator, const std::string& query, std::vector<ElementId>* elements, Error** error);
75+
virtual void ActiveElement(ElementId* element, Error** error);
76+
virtual void SwitchTo(Error** error);
77+
virtual void SwitchToFrameWithNameOrId(const std::string& name_or_id, Error** error);
78+
virtual void SwitchToFrameWithIndex(int index, Error** error);
79+
virtual void SwitchToFrameWithElement(const ElementId& element, Error** error);
80+
virtual void SwitchToTopFrame(Error** error);
81+
virtual void SwitchToTopFrameIfCurrentFrameInvalid(Error** error);
82+
virtual void NavigateToURL(const std::string& url, bool sync, Error** error);
83+
virtual void GetURL(std::string* url, Error** error);
84+
virtual void ExecuteScript(const std::string& script, const base::ListValue* const args, base::Value** value, Error** error);
85+
virtual void ExecuteAsyncScript(const std::string& script, const base::ListValue* const args, base::Value** value, Error** error);
86+
virtual void GetAppCacheStatus(int* status, Error** error);
87+
virtual void GetCookies(const std::string& url, base::ListValue** cookies, Error** error);
88+
virtual void SetCookie(const std::string& url, base::DictionaryValue* cookie_dict, Error** error);
89+
virtual void DeleteCookie(const std::string& url, const std::string& cookie_name, Error** error);
90+
virtual void GetStorageKeys(StorageType type, base::ListValue** keys, Error** error);
91+
virtual void SetStorageItem(StorageType type, const std::string& key, const std::string& value, Error** error);
92+
virtual void ClearStorage(StorageType type, Error** error);
93+
virtual void GetStorageItem(StorageType type, const std::string& key, std::string* value, Error** error);
94+
virtual void RemoveStorageItem(StorageType type, const std::string& key, std::string* value, Error** error);
95+
virtual void GetStorageSize(StorageType type, int* size, Error** error);
96+
virtual void GetGeoLocation(base::DictionaryValue** geolocation, Error** error) NOT_SUPPORTED_IMPL;
97+
virtual void SetGeoLocation(const base::DictionaryValue* geolocation, Error** error) NOT_SUPPORTED_IMPL;
98+
virtual void TouchClick(const ElementId& element, Error **error);
99+
virtual void TouchDoubleClick(const ElementId& element, Error **error);
100+
virtual void TouchDown(const int &x, const int &y, Error **error);
101+
virtual void TouchUp(const int &x, const int &y, Error **error);
102+
virtual void TouchMove(const int &x, const int &y, Error **error);
103+
virtual void TouchLongClick(const ElementId& element, Error **error);
104+
virtual void TouchScroll(const int &xoffset, const int &yoffset, Error **error);
105+
virtual void TouchScroll(const ElementId &element, const int &xoffset, const int &yoffset, Error **error);
106+
virtual void TouchFlick(const int &xSpeed, const int &ySpeed, Error **error);
107+
virtual void TouchFlick(const ElementId &element, const int &xoffset, const int &yoffset, const int &speed, Error **error);
108+
virtual void GetBrowserLog(base::ListValue** browserLog, Error **error);
109+
virtual void GetPlayerState(const ElementId& element, PlayerState*, Error**);
110+
virtual void SetPlayerState(const ElementId& element, PlayerState, Error**);
111+
virtual void GetPlayerVolume(const ElementId& element, double*, Error**);
112+
virtual void SetPlayerVolume(const ElementId& element, double, Error**);
113+
virtual void GetPlayingPosition(const ElementId& element, double*, Error**);
114+
virtual void SetPlayingPosition(const ElementId& element, double, Error**);
115+
virtual void SetMute(const ElementId& element, bool, Error**);
116+
virtual void GetMute(const ElementId& element, bool*, Error**);
117+
virtual void VisualizerSource(std::string* source, Error** error);
118+
virtual void VisualizerShowPoint(Error** error);
119+
virtual void GetAlertMessage(std::string* text, Error** error) NOT_SUPPORTED_IMPL;
120+
virtual void SetAlertPromptText(const std::string& alert_prompt_text, Error** error) NOT_SUPPORTED_IMPL;
121+
virtual void AcceptOrDismissAlert(bool accept, Error** error) NOT_SUPPORTED_IMPL;
122+
virtual void SetOrientation(const std::string &orientation, Error **error) NOT_SUPPORTED_IMPL;
123+
virtual void GetOrientation(std::string *orientation, Error **error);
124+
125+
protected:
126+
QDeclarativeWebView* getView(const ViewId& viewId, Error** error);
127+
Rect ConvertQRectToRect(const QRect &rect);
128+
QRect ConvertRectToQRect(const Rect &rect);
129+
QPoint ConvertPointToQPoint(const Point &p);
130+
Qt::MouseButton ConvertMouseButtonToQtMouseButton(MouseButton button);
131+
132+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
133+
QTouchDevice touchDevice;
134+
#endif
135+
136+
private:
137+
DISALLOW_COPY_AND_ASSIGN(QmlWebViewCmdExecutor);
138+
};
139+
140+
} // namespace webdriver
141+
142+
#endif // WEBDRIVER_QML_WEB_VIEW_EXECUTOR_H

src/Test/main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#if (WD_TEST_ENABLE_WEB_VIEW == 1)
6262
#include "extension_qt/qdeclarativewebview.h"
6363
#include "extension_qt/qml_web_view_enumerator.h"
64+
#include "extension_qt/qml_web_view_executor.h"
6465
#endif
6566
#endif
6667
#endif //OS_IOS
@@ -171,6 +172,7 @@ int main(int argc, char *argv[])
171172
qmlRegisterRevision<QDeclarativeWebView, 0>("CiscoQtWebKit", 1, 0);
172173
qmlRegisterRevision<QDeclarativeWebView, 1>("CiscoQtWebKit", 1, 1);
173174
webdriver::ViewEnumerator::AddViewEnumeratorImpl(new webdriver::QmlWebViewEnumeratorImpl());
175+
webdriver::ViewCmdExecutorFactory::GetInstance()->AddViewCmdExecutorCreator(new webdriver::QmlWebViewCmdExecutorCreator());
174176
#endif
175177

176178
#endif

0 commit comments

Comments
 (0)