Skip to content

Commit 3190a8e

Browse files
committed
Merge branch 'WD_1.X_dev' of https://portal-ua.globallogic.com/git/wd into WD_1.X_dev
2 parents 888869b + 97d5c55 commit 3190a8e

19 files changed

+258
-48
lines changed

base.gyp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
'src/base/utf_string_conversions.cc',
9191
'src/base/utf_string_conversion_utils.cc',
9292
'src/base/values.cc',
93+
'src/net/base/file_stream.cc',
94+
'src/net/base/file_stream_metrics.cc',
95+
'src/net/base/file_stream_net_log_parameters.cc',
96+
'src/net/base/io_buffer.cc',
97+
'src/net/base/net_errors.cc',
98+
'src/net/base/net_log.cc',
9399
'src/third_party/modp_b64/modp_b64.cc'
94100
],
95101

@@ -205,6 +211,15 @@
205211
],
206212
} ],
207213
],
214+
} , {
215+
'target_name': 'chromium_base_shared',
216+
'type': 'shared_library',
217+
218+
'product_name': 'chromium_base',
219+
220+
'dependencies': [
221+
'chromium_base',
222+
],
208223
}
209224
],
210225
}

build.sh

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mode=$3
66
current_dir=`pwd`
77
if [ -z $output_gen ];
88
then
9-
output_gen=`pwd`
9+
output_gen=`pwd`/out
1010
platform="desktop"
1111
fi
1212

@@ -26,6 +26,11 @@ else
2626
modes=$mode
2727
fi
2828

29+
OUT_STATIC_LIB_FILES="libchromium_base.a libWebDriver_core.a libWebDriver_extension_qt_base.a libWebDriver_extension_qt_web.a"
30+
OUT_SHARED_LIB_FILES="libchromium_base.so libWebDriver_core.so libWebDriver_extension_qt_base.so libWebDriver_extension_qt_web.so"
31+
OUT_BIN_FILES="WebDriver WebDriver_noWebkit WebDriver_noWebkit_sharedLibs"
32+
GYP=`which gyp`
33+
2934
#generate wdversion.cc
3035
python generate_wdversion.py
3136

@@ -34,27 +39,32 @@ do
3439
for mode in $modes
3540
do
3641
cd $current_dir
37-
gyp --depth . -G output_dir=. -D platform=$platform -D mode=$mode -D ROOT_PATH=${base_output_gen} --generator-output=${output_gen}/out/$platform/$mode wd.gyp
42+
43+
OUTPUT_DIR=${output_gen}/$platform/$mode
44+
OUTPUT_DIR_OUT=${output_gen}/$platform/$mode/Default
45+
OUTPUT_BIN_DIR=${output_gen}/bin/$platform/$mode
46+
47+
python $GYP --depth . -G output_dir=. -D platform=$platform -D mode=$mode -D ROOT_PATH=${base_output_gen} --generator-output=${output_gen}/$platform/$mode wd.gyp
3848
[ $? -ne 0 ] && exit 1
39-
cd ${output_gen}/out/$platform/$mode
40-
[ $? -ne 0 ] && echo "**** ERROR: Can't access to ${output_gen}/$platform/$mode" && exit 1
49+
cd $OUTPUT_DIR
50+
[ $? -ne 0 ] && echo "**** ERROR: Can't access to $OUTPUT_DIR" && exit 1
4151
make
4252
[ $? -ne 0 ] && exit 1
4353
mkdir -p ${output_gen}/bin/$platform/$mode/
44-
[ $? -ne 0 ] && echo "**** ERROR: Can't create ${output_gen}/bin/$platform/$mode" && exit 1
45-
46-
cp -f ${output_gen}/out/$platform/$mode/Default/libchromium_base.a ${output_gen}/bin/$platform/$mode/ 2>/dev/null
47-
cp -f ${output_gen}/out/$platform/$mode/Default/libWebDriver_core.a ${output_gen}/bin/$platform/$mode/ 2>/dev/null
48-
cp -f ${output_gen}/out/$platform/$mode/Default/libWebDriver_extension_qt_base.a ${output_gen}/bin/$platform/$mode/ 2>/dev/null
49-
cp -f ${output_gen}/out/$platform/$mode/Default/libWebDriver_extension_qt_web.a ${output_gen}/bin/$platform/$mode/ 2>/dev/null
50-
#cp -f ${output_gen}/out/$platform/$mode/Default/lib.target/libWebDriver.so ${output_gen}/bin/$platform/$mode/ 2>/dev/null
51-
if [ -f ${output_gen}/out/$platform/$mode/Default/WebDriver ]
52-
then
53-
cp -f ${output_gen}/out/$platform/$mode/Default/WebDriver ${output_gen}/bin/$platform/$mode/ 2>/dev/null
54-
fi
55-
if [ -f ${output_gen}/out/$platform/$mode/Default/WebDriver_noWebkit ]
56-
then
57-
cp -f ${output_gen}/out/$platform/$mode/Default/WebDriver_noWebkit ${output_gen}/bin/$platform/$mode/ 2>/dev/null
58-
fi
54+
[ $? -ne 0 ] && echo "**** ERROR: Can't create $OUTPUT_BIN_DIR" && exit 1
55+
56+
# copy libraries
57+
for file in $OUT_STATIC_LIB_FILES; do cp -f $OUTPUT_DIR_OUT/$file $OUTPUT_BIN_DIR 2>/dev/null; done
58+
for file in $OUT_SHARED_LIB_FILES; do cp -f $OUTPUT_DIR_OUT/lib.target/$file $OUTPUT_BIN_DIR 2>/dev/null; done
59+
60+
# copy test binaries
61+
for file in $OUT_BIN_FILES
62+
do
63+
if [ -f $OUTPUT_DIR_OUT/$file ]
64+
then
65+
cp -f $OUTPUT_DIR_OUT/$file $OUTPUT_BIN_DIR 2>/dev/null
66+
fi
67+
done
68+
5969
done
6070
done

inc/webdriver_switches.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ class Switches {
6969

7070
/// \page page_webdriver_switches WD Server switches
7171
/// - <b>vnc</b><br>
72-
/// Enabling VNC support (by default - false)
73-
static const char kVNCEnabled[];
72+
/// VNC server listening port (by default - 5900)
73+
static const char kVNCPort[];
74+
75+
/// \page page_webdriver_switches WD Server switches
76+
/// - <b>vnc</b><br>
77+
/// VNC server IP address (by default - 127.0.0.1)
78+
static const char kVNCServer[];
7479

7580
};
7681

src/Test/main.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "webdriver_server.h"
3838
#include "webdriver_view_transitions.h"
3939
#include "versioninfo.h"
40+
#include "webdriver_route_table.h"
41+
#include "shutdown_command.h"
4042

4143
#if (WD_TEST_ENABLE_WEB_VIEW == 1)
4244
#include "extension_qt/web_view_creator.h"
@@ -143,16 +145,11 @@ int main(int argc, char *argv[])
143145
return 1;
144146
}
145147

146-
VNCClient *client = new VNCClient();
147-
client->Init("http://127.0.0.1", 5900);
148+
webdriver::RouteTable *routeTableWithShutdownCommand = new webdriver::RouteTable(wd_server->GetRouteTable());
149+
const char shutdownCommandRoute[] = "/-CISCO-shutdown";
150+
routeTableWithShutdownCommand->Add<webdriver::ShutdownCommand>(shutdownCommandRoute);
151+
wd_server->SetRouteTable(routeTableWithShutdownCommand);
148152

149-
150-
CommandLine cmdLine = webdriver::Server::GetInstance()->GetCommandLine();
151-
152-
if (cmdLine.HasSwitch(webdriver::Switches::kVNCEnabled))
153-
{
154-
WDEventDispatcher::getInstance()->add(new VNCEventDispatcher(client));
155-
}
156153

157154
setQtSettings();
158155
wd_server->Start();
@@ -209,7 +206,9 @@ void PrintHelp() {
209206
<< " described above (port, root, etc.)" << std::endl
210207
<< "wi-server false If true, web inspector will be enabled" << std::endl
211208
<< "wi-port 9222 Web inspector listening port" << std::endl
212-
<< "version Print version information to stdout and exit" << std::endl;
209+
<< "version Print version information to stdout and exit" << std::endl
210+
<< "vnc-port 5900 VNC server listening port" << std::endl
211+
<< "vnc-server 127.0.0.1 VNC server IP address" << std::endl;
213212
}
214213

215214

src/Test/shutdown_command.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "shutdown_command.h"
2+
#include <iostream>
3+
#include "webdriver_server.h"
4+
5+
#include <QtCore/qglobal.h>
6+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
7+
#include <QtConcurrent/QtConcurrentRun>
8+
#include <QtWidgets/QApplication>
9+
#else
10+
#include <QtGui/QApplication>
11+
#endif
12+
13+
namespace webdriver {
14+
15+
ShutdownCommand::ShutdownCommand(const std::vector<std::string> &path_segments,
16+
const base::DictionaryValue * const parameters)
17+
: Command(path_segments, parameters) {}
18+
19+
ShutdownCommand::~ShutdownCommand() { }
20+
21+
void ShutdownCommand::ExecutePost(Response * const response)
22+
{
23+
Server *wd_server = Server::GetInstance();
24+
QApplication::quit();
25+
wd_server->Stop(true);
26+
}
27+
28+
bool ShutdownCommand::DoesPost() const
29+
{
30+
return true;
31+
}
32+
33+
}

src/Test/shutdown_command.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef SHUTDOWN_COMMAND_H
2+
#define SHUTDOWN_COMMAND_H
3+
4+
#include "commands/command.h"
5+
#include "commands/response.h"
6+
7+
namespace webdriver {
8+
9+
class ShutdownCommand : public Command
10+
{
11+
public:
12+
ShutdownCommand(const std::vector<std::string>& path_segments,
13+
const base::DictionaryValue* const parameters);
14+
virtual ~ShutdownCommand();
15+
16+
virtual bool DoesPost() const OVERRIDE;
17+
18+
virtual void ExecutePost(Response* const response) OVERRIDE;
19+
20+
private:
21+
DISALLOW_COPY_AND_ASSIGN(ShutdownCommand);
22+
};
23+
24+
}
25+
26+
#endif // SHUTDOWN_COMMAND_H

src/vnc/vncclient.cc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
#include <iostream>
44
#include <QtNetwork/QHostAddress>
55
#include <QtCore/QMap>
6+
#include <QtCore/QRegExp>
67

78
#define MAJOR_INDEX 6
89
#define MINOR_INDEX 10
910

11+
VNCClient* VNCClient::_instance = NULL;
12+
1013
static QMap<quint32, quint16> initializeMap()
1114
{
1215
QMap<quint32, quint16> resultMap;
@@ -70,10 +73,28 @@ VNCClient::~VNCClient()
7073
delete _serverParameters;
7174
}
7275

76+
VNCClient* VNCClient::getInstance()
77+
{
78+
if (NULL == _instance)
79+
{
80+
_instance = new VNCClient();
81+
}
82+
83+
return _instance;
84+
}
85+
7386
bool VNCClient::Init(QString remoteHost, quint16 port)
7487
{
7588
_socket = new QTcpSocket();
76-
_socket->connectToHost(QHostAddress::LocalHost, port);
89+
QHostAddress addr;
90+
91+
if (!addr.setAddress(remoteHost))
92+
{
93+
remoteHost.replace(QRegExp("http*://"), "");
94+
addr.setAddress(remoteHost);
95+
}
96+
97+
_socket->connectToHost(addr, port);
7798

7899
// QObject::connect(_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(readSocket(qint64)));
79100
QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(readSocket()));

src/vnc/vncclient.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class VNCClient : public QObject
1212
Q_OBJECT
1313

1414
public:
15-
VNCClient();
1615
~VNCClient();
1716

17+
static VNCClient* getInstance();
18+
1819
bool Init(QString remoteHost, quint16 port);
1920
void sendKeyEvent(QKeyEvent *key);
2021
void sendMouseEvent(QMouseEvent *mouse);
@@ -30,6 +31,8 @@ private slots:
3031
void onError(QAbstractSocket::SocketError error);
3132

3233
private:
34+
VNCClient();
35+
3336
bool establishProtocolVersion(QByteArray& data);
3437
bool establishSecurity(QByteArray& data);
3538
bool finishHandshaking(QByteArray& data);
@@ -68,6 +71,7 @@ private slots:
6871
static QMap<quint32, quint16> _keymap;
6972

7073
private:
74+
static VNCClient *_instance;
7175
QTcpSocket *_socket;
7276
bool _versionEstablished;
7377
bool _securityEstablished;

src/webdriver/extension_qt/q_session_lifecycle_actions.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#include "extension_qt/q_session_lifecycle_actions.h"
2+
#include "extension_qt/wd_event_dispatcher.h"
3+
#include "extension_qt/vnc_event_dispatcher.h"
4+
#include "webdriver_switches.h"
5+
#include "webdriver_server.h"
26

37
#include "q_proxy_parser.h"
48

@@ -29,6 +33,25 @@ Error* QSessionLifeCycleActions::PostInit(const base::DictionaryValue* desired_c
2933
session_->logger().Log(kInfoLogLevel, "no proxy settings requsted.");
3034
}
3135

36+
// start VNC module
37+
CommandLine cmdLine = webdriver::Server::GetInstance()->GetCommandLine();
38+
if (cmdLine.HasSwitch(webdriver::Switches::kVNCServer) || cmdLine.HasSwitch(webdriver::Switches::kVNCPort))
39+
{
40+
QString address = "127.0.0.1";
41+
int port = 5900;
42+
43+
if (cmdLine.HasSwitch(webdriver::Switches::kVNCServer))
44+
address = cmdLine.GetSwitchValueASCII(webdriver::Switches::kVNCServer).c_str();
45+
if (cmdLine.HasSwitch(webdriver::Switches::kVNCPort))
46+
port = QString(cmdLine.GetSwitchValueASCII(webdriver::Switches::kVNCPort).c_str()).toInt();
47+
48+
VNCClient *client = VNCClient::getInstance();
49+
if (!client->isReady())
50+
client->Init(address, port);
51+
52+
WDEventDispatcher::getInstance()->add(new VNCEventDispatcher(client));
53+
}
54+
3255
return error;
3356
}
3457

src/webdriver/webdriver_route_table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ CommandCreatorPtr RouteTable::GetRouteForURL(const std::string& url, std::string
115115
bool RouteTable::AddRoute(const std::string& uri_pattern,
116116
const CommandCreatorPtr& creator) {
117117
// custom command check
118-
if (!CommandRoutes::IsStandardRoute(uri_pattern)) {
118+
if (false){//!CommandRoutes::IsStandardRoute(uri_pattern)) {
119119
std::vector<std::string> url_segments;
120120
base::SplitString(uri_pattern, '/', &url_segments);
121121

0 commit comments

Comments
 (0)