Skip to content

Commit

Permalink
JimEvans: Changing the shared WebDriver C++ server component to use s…
Browse files Browse the repository at this point in the history
…trings in serialized commands instead of integers. Testing does not seem to indicate this will introduce a performance issue, and it makes logs more intelligible when logging the raw JSON of a received command. As far as anyone can determine, the only consumer of this component is the IEDriverServer.exe, so this should be a completely internal change.

r18285
  • Loading branch information
jimevans committed Dec 9, 2012
1 parent d426628 commit 2ccf8f1
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 292 deletions.
178 changes: 90 additions & 88 deletions cpp/IEDriver/IECommandExecutor.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cpp/IEDriver/IECommandExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class IECommandExecutor : public CWindowImpl<IECommandExecutor> {
typedef std::tr1::unordered_map<std::string, ElementHandle> ElementMap;
typedef std::tr1::unordered_map<std::string, BrowserHandle> BrowserMap;
typedef std::map<std::string, std::wstring> ElementFindMethodMap;
typedef std::map<int, CommandHandlerHandle> CommandHandlerMap;
typedef std::map<std::string, CommandHandlerHandle> CommandHandlerMap;

void AddManagedBrowser(BrowserHandle browser_wrapper);

Expand Down
7 changes: 4 additions & 3 deletions cpp/webdriver-server/command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
// limitations under the License.

#include "command.h"
#include "command_types.h"
#include "logging.h"

namespace webdriver {

Command::Command() : command_type_(0) {
Command::Command() : command_type_(webdriver::CommandType::NoCommand) {
}

Command::~Command() {
Expand All @@ -41,8 +42,8 @@ void Command::Populate(const std::string& json_command) {
<< "JSON command: '" << json_command << "'";
}

this->command_type_ = root.get("command", 0).asInt();
if (this->command_type_ != 0) {
this->command_type_ = root.get("command", webdriver::CommandType::NoCommand).asString();
if (this->command_type_ != webdriver::CommandType::NoCommand) {
Json::Value locator_parameter_object = root["locator"];
Json::Value::iterator it = locator_parameter_object.begin();
Json::Value::iterator end = locator_parameter_object.end();
Expand Down
4 changes: 2 additions & 2 deletions cpp/webdriver-server/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Command {
virtual ~Command(void);
void Populate(const std::string& json_command);

int command_type(void) const { return this->command_type_; }
std::string command_type(void) const { return this->command_type_; }
LocatorMap locator_parameters(void) const {
return this->locator_parameters_;
}
Expand All @@ -42,7 +42,7 @@ class Command {

private:
// The type of command this represents.
int command_type_;
std::string command_type_;
// Locator parameters derived from the URL of the command request.
LocatorMap locator_parameters_;
// Command parameters passed as JSON in the body of the request.
Expand Down
164 changes: 82 additions & 82 deletions cpp/webdriver-server/command_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,93 +18,93 @@

namespace webdriver {

enum CommandType {
NoCommand,
Status,
GetSessionList,
NewSession,
GetSessionCapabilities,
Close,
Quit,
Get,
GoBack,
GoForward,
Refresh,
AddCookie,
GetAllCookies,
DeleteCookie,
DeleteAllCookies,
FindElement,
FindElements,
FindChildElement,
FindChildElements,
DescribeElement,
ClearElement,
ClickElement,
SendKeysToElement,
SubmitElement,
GetCurrentWindowHandle,
GetWindowHandles,
SwitchToWindow,
SwitchToFrame,
GetActiveElement,
GetCurrentUrl,
GetPageSource,
GetTitle,
ExecuteScript,
ExecuteAsyncScript,
GetElementText,
GetElementValue,
GetElementTagName,
IsElementSelected,
IsElementEnabled,
IsElementDisplayed,
GetElementLocation,
GetElementLocationOnceScrolledIntoView,
GetElementSize,
GetElementAttribute,
GetElementValueOfCssProperty,
ElementEquals,
Screenshot,
ImplicitlyWait,
SetAsyncScriptTimeout,
SetTimeout,
GetOrientation,
SetOrientation,
namespace CommandType {
const std::string NoCommand = "noCommand";
const std::string Status = "status";
const std::string GetSessionList = "getSessionList";
const std::string NewSession = "newSession";
const std::string GetSessionCapabilities = "getSessionCapabilities";
const std::string Close = "close";
const std::string Quit = "quit";
const std::string Get = "get";
const std::string GoBack = "goBack";
const std::string GoForward = "goForward";
const std::string Refresh = "refresh";
const std::string AddCookie = "addCookie";
const std::string GetAllCookies = "getAllCookies";
const std::string DeleteCookie = "deleteCookie";
const std::string DeleteAllCookies = "deleteAllCookies";
const std::string FindElement = "findElement";
const std::string FindElements = "findElements";
const std::string FindChildElement = "findChildElement";
const std::string FindChildElements = "findChildElements";
const std::string DescribeElement = "describeElement";
const std::string ClearElement = "clearElement";
const std::string ClickElement = "clickElement";
const std::string SendKeysToElement = "sendKeysToElement";
const std::string SubmitElement = "submit";
const std::string GetCurrentWindowHandle = "getCurrentWindowHandle";
const std::string GetWindowHandles = "getWindowHandles";
const std::string SwitchToWindow = "switchToWindow";
const std::string SwitchToFrame = "switchToFrame";
const std::string GetActiveElement = "getActiveElement";
const std::string GetCurrentUrl = "getCurrentUrl";
const std::string GetPageSource = "getPageSource";
const std::string GetTitle = "getTitle";
const std::string ExecuteScript = "executeScript";
const std::string ExecuteAsyncScript = "executeAsyncScript";
const std::string GetElementText = "getElementText";
const std::string GetElementValue = "getElementValue";
const std::string GetElementTagName = "getElementTagName";
const std::string IsElementSelected = "isElementSelected";
const std::string IsElementEnabled = "isElementEnabled";
const std::string IsElementDisplayed = "isElementDisplayed";
const std::string GetElementLocation = "getElementLocation";
const std::string GetElementLocationOnceScrolledIntoView = "getElementLocationInView";
const std::string GetElementSize = "getElementSize";
const std::string GetElementAttribute = "getAttribute";
const std::string GetElementValueOfCssProperty = "getValueOfCssProperty";
const std::string ElementEquals = "elementEquals";
const std::string Screenshot = "screenshot";
const std::string ImplicitlyWait = "implicitlyWait";
const std::string SetAsyncScriptTimeout = "setAsyncScriptTimeout";
const std::string SetTimeout = "setTimeout";
const std::string GetOrientation = "getOrientation";
const std::string SetOrientation = "setOrientation";

GetWindowSize,
SetWindowSize,
GetWindowPosition,
SetWindowPosition,
MaximizeWindow,
const std::string GetWindowSize = "getWindowSize";
const std::string SetWindowSize = "setWindowSize";
const std::string GetWindowPosition = "getWindowPosition";
const std::string SetWindowPosition = "setWindowPosition";
const std::string MaximizeWindow = "maximizeWindow";

AcceptAlert,
DismissAlert,
GetAlertText,
SendKeysToAlert,
const std::string AcceptAlert = "acceptAlert";
const std::string DismissAlert = "dismissAlert";
const std::string GetAlertText = "getAlertText";
const std::string SendKeysToAlert = "sendKeysToAlert";

SendKeysToActiveElement,
MouseMoveTo,
MouseClick,
MouseDoubleClick,
MouseButtonDown,
MouseButtonUp,
const std::string SendKeysToActiveElement = "sendKeysToActiveElement";
const std::string MouseMoveTo = "mouseMoveTo";
const std::string MouseClick = "mouseClick";
const std::string MouseDoubleClick = "mouseDoubleClick";
const std::string MouseButtonDown = "mouseButtonDown";
const std::string MouseButtonUp = "mouseButtonUp";

ListAvailableImeEngines,
GetActiveImeEngine,
IsImeActivated,
ActivateImeEngine,
DeactivateImeEngine,
const std::string ListAvailableImeEngines = "listAvailableImeEngines";
const std::string GetActiveImeEngine = "getActiveImeEngine";
const std::string IsImeActivated = "isImeActivated";
const std::string ActivateImeEngine = "activateImeEngine";
const std::string DeactivateImeEngine = "deactivateImeEngine";

TouchClick,
TouchDown,
TouchUp,
TouchMove,
TouchScroll,
TouchDoubleClick,
TouchLongClick,
TouchFlick
};
const std::string TouchClick = "touchClick";
const std::string TouchDown = "touchDown";
const std::string TouchUp = "touchUp";
const std::string TouchMove = "touchMove";
const std::string TouchScroll = "touchScroll";
const std::string TouchDoubleClick = "touchDoubleClick";
const std::string TouchLongClick = "touchLongClick";
const std::string TouchFlick = "touchFlick";
}

} // namespace webdriver

Expand Down
Loading

0 comments on commit 2ccf8f1

Please sign in to comment.