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