Skip to content

Commit f178db9

Browse files
Andrii BoichukAndrii Boichuk
Andrii Boichuk
authored and
Andrii Boichuk
committed
Merge branch 'WD_1.X_dev' of https://portal-ua.globallogic.com/git/wd into WD_1.X_dev
2 parents a5db12b + 052e532 commit f178db9

File tree

7 files changed

+30
-25
lines changed

7 files changed

+30
-25
lines changed

inc/webdriver_route_patterns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class CommandRoutes {
104104
static const char kVisualizerShowPoint[];
105105
static const char kTouchPinchZoom[];
106106
static const char kTouchPinchRotate[];
107+
static const char kShutdown[];
107108

108109
private:
109110
static std::set<std::string> standardCommandRoutes;

src/Test/main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ std::string tests::testDataFolder;
5454
#include "versioninfo.h"
5555
#include "webdriver_route_table.h"
5656
#include "shutdown_command.h"
57+
#include "webdriver_route_patterns.h"
5758

5859
#ifndef OS_IOS
5960
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@@ -259,6 +260,7 @@ int main(int argc, char *argv[])
259260
webdriver::RouteTable *routeTableWithShutdownCommand = new webdriver::RouteTable(wd_server->GetRouteTable());
260261
const char shutdownCommandRoute[] = "/-cisco-shutdown";
261262
routeTableWithShutdownCommand->Add<webdriver::ShutdownCommand>(shutdownCommandRoute);
263+
routeTableWithShutdownCommand->Add<webdriver::ShutdownCommand>(webdriver::CommandRoutes::kShutdown);
262264
wd_server->SetRouteTable(routeTableWithShutdownCommand);
263265

264266
InitVNCClient();

src/webdriver/extension_qt/qml_view_executor.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,12 @@ void QQmlViewCmdExecutor::GetAttribute(const ElementId& element, const std::stri
450450
case QVariant::Double:
451451
val = Value::CreateDoubleValue(propertyValue.toDouble());
452452
break;
453-
case QVariant::String:
454-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
455-
break;
456453
default:
457-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
454+
if (propertyValue.canConvert<QString>()) {
455+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
456+
} else {
457+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
458+
}
458459
}
459460
} else {
460461
session_->logger().Log(kWarningLogLevel, "property not found.");

src/webdriver/extension_qt/quick2_view_executor.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,12 @@ void Quick2ViewCmdExecutor::GetAttribute(const ElementId& element, const std::st
462462
case QVariant::Double:
463463
val = Value::CreateDoubleValue(propertyValue.toDouble());
464464
break;
465-
case QVariant::String:
466-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
467-
break;
468465
default:
469-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
466+
if (propertyValue.canConvert<QString>()) {
467+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
468+
} else {
469+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
470+
}
470471
}
471472
} else {
472473
session_->logger().Log(kWarningLogLevel, "property not found.");

src/webdriver/extension_qt/widget_view_executor.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ void QWidgetViewCmdExecutor::GetAttribute(const ElementId& element, const std::s
461461
case QVariant::Double:
462462
val = Value::CreateDoubleValue(propertyValue.toDouble());
463463
break;
464-
case QVariant::String:
465-
val = Value::CreateStringValue(propertyValue.toString().toStdString());
466-
break;
467464
default:
468-
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
465+
if (propertyValue.canConvert<QString>()) {
466+
val = Value::CreateStringValue(propertyValue.toString().toStdString());
467+
} else {
468+
session_->logger().Log(kWarningLogLevel, "cant handle proprty type.");
469+
}
469470
}
470471
} else {
471472
session_->logger().Log(kWarningLogLevel, "property not found.");

src/webdriver/webdriver_route_patterns.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ bool CommandRoutes::IsStandardRoute(const std::string& pattern) {
8989
standardCommandRoutes.insert(kCiscoPlayerState);
9090
standardCommandRoutes.insert(kCiscoPlayerVolume);
9191
standardCommandRoutes.insert(kCiscoPlayingPosition);
92+
standardCommandRoutes.insert(kShutdown);
9293
}
9394

9495
// check if paatern is presence in set
@@ -183,5 +184,6 @@ const char CommandRoutes::kVisualizerSource[] = "/session/*/-cisco-vis
183184
const char CommandRoutes::kVisualizerShowPoint[] = "/session/*/-cisco-visualizer_show_point";
184185
const char CommandRoutes::kTouchPinchZoom[] = "/session/*/touch/-cisco-pinch-zoom";
185186
const char CommandRoutes::kTouchPinchRotate[] = "/session/*/touch/-cisco-pinch-rotate";
187+
const char CommandRoutes::kShutdown[] = "/shutdown";
186188

187189
} // namespace webdriver

src/webdriver/webdriver_route_table.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ CommandCreatorPtr RouteTable::GetRouteForURL(const std::string& url, std::string
120120
bool RouteTable::AddRoute(const std::string& uri_pattern,
121121
const CommandCreatorPtr& creator) {
122122
// custom command check
123-
if (false){//!CommandRoutes::IsStandardRoute(uri_pattern)) {
123+
if (!CommandRoutes::IsStandardRoute(uri_pattern)) {
124124
std::vector<std::string> url_segments;
125125
base::SplitString(uri_pattern, '/', &url_segments);
126126

@@ -129,17 +129,16 @@ bool RouteTable::AddRoute(const std::string& uri_pattern,
129129
GlobalLogger::Log(kWarningLogLevel, "Custom commands too short");
130130
return false;
131131
}
132-
if (url_segments.size() >= 2
133-
&& url_segments[0].empty() && url_segments[1] != "session") {
134-
if (!CheckCustomPrefix(url_segments[1]))
135-
return false;
136-
} else if (url_segments.size() < 4 || !url_segments[0].empty()
137-
|| url_segments[1] != "session" || url_segments[2] != "*") {
138-
GlobalLogger::Log(kWarningLogLevel, "Invalid custom commands");
132+
bool hasCustomPrefix = false;
133+
for (size_t i = 0; i < url_segments.size(); ++i)
134+
{
135+
hasCustomPrefix = CheckCustomPrefix(url_segments[i]);
136+
if (hasCustomPrefix)
137+
break;
138+
}
139+
if (!hasCustomPrefix) {
140+
GlobalLogger::Log(kWarningLogLevel, "Comand " + uri_pattern +" has no valid custom prefix");
139141
return false;
140-
} else {
141-
if (!CheckCustomPrefix(url_segments[3]))
142-
return false;
143142
}
144143
}
145144
std::vector<webdriver::internal::RouteDetails>::iterator route;
@@ -175,8 +174,6 @@ bool RouteTable::CheckCustomPrefix(const std::string& prefix) {
175174
if (prefix_segments.size() < 3 || !prefix_segments[0].empty() || prefix_segments[2].empty()
176175
|| prefix_segments[1].empty() || !std::isalpha(prefix_segments[1].at(0))) {
177176
#endif //OS_WIN
178-
179-
GlobalLogger::Log(kWarningLogLevel, "Custom prefix invalid");
180177
return false;
181178
}
182179
return true;

0 commit comments

Comments
 (0)