Skip to content

Commit 1eb1dc6

Browse files
committed
Merge branch 'WD_1.X_dev' of https://portal-ua.globallogic.com/git/wd into WD_1.X_dev
2 parents 329ce03 + ea03ede commit 1eb1dc6

File tree

13 files changed

+2329
-2018
lines changed

13 files changed

+2329
-2018
lines changed

inc/extension_qt/web_view_executor.h

Lines changed: 4 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include "extension_qt/q_view_executor.h"
55
#include "webdriver_logging.h"
66

7-
#include <QtCore/QtGlobal>
8-
97
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
108
#include <QtWebKitWidgets/QWebView>
119
#include <QtWebKit/QWebHistory>
@@ -19,88 +17,7 @@ namespace webdriver {
1917

2018
class FramePath;
2119
class ValueParser;
22-
23-
class QPageLoader : public QObject {
24-
Q_OBJECT
25-
public:
26-
explicit QPageLoader(QWebView* view) :
27-
QObject(NULL) {webView = view; is_loading = false;}
28-
29-
void loadPage(QUrl url);
30-
void reloadPage();
31-
bool isLoading() {return is_loading;}
32-
33-
signals:
34-
void loaded();
35-
36-
public slots:
37-
void pageLoadStarted();
38-
void pageLoadFinished();
39-
private:
40-
bool is_loading;
41-
QWebView* webView;
42-
43-
};
44-
45-
//Notify automation module about end of execution of async script
46-
class JSNotifier : public QObject
47-
{
48-
Q_OBJECT
49-
50-
public:
51-
JSNotifier();
52-
QVariant getResult();
53-
bool IsCompleted();
54-
55-
56-
public slots:
57-
void setResult(QVariant result);
58-
59-
signals:
60-
void completed();
61-
62-
private:
63-
QVariant res;
64-
bool isCompleted;
65-
};
66-
67-
class JSLogger : public QObject
68-
{
69-
Q_OBJECT
70-
71-
public:
72-
JSLogger();
73-
base::ListValue* getLog();
74-
void SetMinLogLevel(LogLevel level);
75-
76-
public slots:
77-
void log(QVariant message);
78-
void warn(QVariant message);
79-
void error(QVariant message);
80-
81-
private:
82-
InMemoryLog browserLog;
83-
Logger browserLogger;
84-
};
85-
86-
class BrowserLogHandler : public QObject
87-
{
88-
Q_OBJECT
89-
90-
public:
91-
BrowserLogHandler(QObject* parent);
92-
base::ListValue* getLog();
93-
void SetMinLogLevel(LogLevel level);
94-
void loadConsoleJS(const QWebView* view);
95-
void loadJSLogObject(QWebFrame *frame);
96-
97-
public slots:
98-
void loadJSLogObject();
99-
void loadConsoleJS();
100-
101-
private:
102-
JSLogger jslogger;
103-
};
20+
class QWebkitProxy;
10421

10522
class QWebViewCmdExecutorCreator : public ViewCmdExecutorCreator {
10623
public:
@@ -203,97 +120,11 @@ class QWebViewCmdExecutor : public QViewCmdExecutor {
203120

204121
protected:
205122
QWebView* getView(const ViewId& viewId, Error** error);
206-
QWebFrame* FindFrameByPath(QWebFrame* parent, const FramePath &frame_path);
207-
QWebFrame* GetFrame(QWebView* view, const FramePath& frame_path);
208-
Error* ExecuteScriptAndParse(QWebFrame* frame,
209-
const std::string& anonymous_func_script,
210-
const std::string& script_name,
211-
const base::ListValue* args,
212-
const ValueParser* parser);
213-
Error* ExecuteAsyncScript(QWebFrame* frame,
214-
const std::string& script,
215-
const base::ListValue* const args,
216-
base::Value** value);
217-
Error* ExecuteScript(QWebFrame* frame,
218-
const std::string& script,
219-
const base::ListValue* const args,
220-
base::Value** value);
221-
Error* ExecuteScriptAndParseValue(QWebFrame* frame,
222-
const std::string& script,
223-
base::Value** script_result, bool isAsync);
224-
Error* ExecuteScriptImpl(QWebFrame* frame,
225-
const std::string &script,
226-
std::string *result,
227-
bool isAsync);
228-
229-
Error* FindElementsHelper(QWebFrame* frame,
230-
const ElementId& root_element,
231-
const std::string& locator,
232-
const std::string& query,
233-
bool find_one,
234-
std::vector<ElementId>* elements);
235-
236-
Error* ExecuteFindElementScriptAndParse(
237-
QWebFrame* frame,
238-
const ElementId& root_element,
239-
const std::string& locator,
240-
const std::string& query,
241-
bool find_one,
242-
std::vector<ElementId>* elements);
243-
244-
Error* GetElementRegionInViewHelper(
245-
QWebFrame* frame,
246-
const ElementId& element,
247-
const Rect& region,
248-
bool center,
249-
bool verify_clickable_at_middle,
250-
Point* location);
251-
252-
Error* GetElementRegionInView(
253-
QWebView* view,
254-
const ElementId& element,
255-
const Rect& region,
256-
bool center,
257-
bool verify_clickable_at_middle,
258-
Point* location);
259-
260-
Error* VerifyElementIsClickable(
261-
QWebFrame* frame,
262-
const ElementId& element,
263-
const Point& location);
264-
265-
Error* GetElementBorder(QWebFrame* frame,
266-
const ElementId& element,
267-
int* border_left,
268-
int* border_top);
269-
270-
Error* GetElementEffectiveStyle(
271-
QWebFrame* frame,
272-
const ElementId& element,
273-
const std::string& prop,
274-
std::string* value);
275-
276-
QWebFrame* FindFrameByMeta(QWebFrame* parent, const FramePath &frame_path);
277-
278-
void AddIdToCurrentFrame(QWebView* view, const FramePath &frame_path);
279-
280-
Error* SwitchToFrameWithJavaScriptLocatedFrame(
281-
QWebView* view,
282-
QWebFrame* frame,
283-
const std::string& script,
284-
base::ListValue* args);
285-
286-
Error* GetElementFirstClientRect(QWebFrame* frame,
287-
const ElementId& element,
288-
Rect* rect);
289-
290-
Error* GetClickableLocation(QWebView* view, const ElementId& element, Point* location);
291-
292-
Error* ToggleOptionElement(const ElementId& element);
293-
294-
void AddBrowserLoggerToView(QWebView* view);
295123

296124
private:
125+
QWebkitProxy* webkitProxy_;
126+
QWebView* view_;
127+
297128
DISALLOW_COPY_AND_ASSIGN(QWebViewCmdExecutor);
298129
friend class QWebViewVisualizerSourceCommand;
299130
friend class QWebViewVisualizerShowPointCommand;

inc/webdriver_basic_types.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ enum MouseButton {
2020
kRightButton = 2
2121
};
2222

23+
/// @enum StorageType storage types
24+
enum StorageType {
25+
kLocalStorageType = 0,
26+
kSessionStorageType
27+
};
28+
29+
///@enum PlayerState possible states
30+
enum PlayerState{
31+
Stopped = 0,
32+
Playing = 1,
33+
Paused = 2
34+
};
35+
2336
class Point {
2437
public:
2538
Point();

inc/webdriver_view_executor.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,6 @@ class Rect;
5959
class Point;
6060
class Size;
6161

62-
/// @enum StorageType storage types
63-
enum StorageType {
64-
kLocalStorageType = 0,
65-
kSessionStorageType
66-
};
67-
68-
///@enum PlayerState possible states
69-
enum PlayerState{
70-
Stopped = 0,
71-
Playing = 1,
72-
Paused = 2
73-
};
74-
75-
7662
/// base class for custom view's executors
7763
class ViewCmdExecutor{
7864
public:

src/Test/TestVariables.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef TESTVARIABLES_H
2+
#define TESTVARIABLES_H
3+
4+
#include <string>
5+
6+
namespace tests {
7+
extern std::string testDataFolder;
8+
}
9+
10+
#endif // TESTVARIABLES_H

src/Test/VideoTest.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ VideoTestWidget::VideoTestWidget(QWidget *parent) :
77
this->setMinimumSize(400, 400);
88
this->setMaximumSize(800, 800);
99
mediaPlayer = new QMediaPlayer(NULL, QMediaPlayer::VideoSurface);
10-
videoWidget = new QVideoWidget;
10+
videoWidget = new QVideoWidget();
1111
videoWidget->setObjectName("videoPlayer");
1212

13-
playButton = new QPushButton;
13+
playButton = new QPushButton();
1414
playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
1515
playButton->setEnabled(false);
1616
connect(playButton, SIGNAL(clicked()), this, SLOT(play()));
@@ -32,27 +32,33 @@ VideoTestWidget::VideoTestWidget(QWidget *parent) :
3232

3333
QWidget *centralWidget = new QWidget();
3434
this->setCentralWidget(centralWidget);
35-
QVBoxLayout *centralWidgetLayout = new QVBoxLayout;
35+
QVBoxLayout *centralWidgetLayout = new QVBoxLayout();
3636
centralWidget->setLayout(centralWidgetLayout);
3737

3838
centralWidgetLayout->addWidget(videoWidget);
39-
QHBoxLayout *controlsLayout = new QHBoxLayout;
39+
QHBoxLayout *controlsLayout = new QHBoxLayout();
4040
centralWidgetLayout->addLayout(controlsLayout);
4141
controlsLayout->addWidget(playButton);
4242
controlsLayout->addWidget(positionSlider);
4343
controlsLayout->addWidget(volumeSlider);
4444

45-
QString fileName = QDir::currentPath() + "/TestData/TestVideo.ogv";
45+
QString videoPath(tests::testDataFolder.c_str());
46+
if(!videoPath.isEmpty()){
47+
if(!videoPath.endsWith("/"))
48+
videoPath.append("/");
49+
videoPath += "TestVideo.ogv";
50+
}
4651

47-
if (!fileName.isEmpty()) {
48-
mediaPlayer->setMedia(QUrl::fromLocalFile(fileName));
52+
QUrl videoUrl = QUrl::fromLocalFile(videoPath);
53+
if (!videoUrl.isEmpty() && videoUrl.isValid()) {
54+
mediaPlayer->setMedia(videoUrl);
4955
durationChanged(mediaPlayer->duration());
5056
positionChanged(mediaPlayer->position());
5157
volumeChanged(mediaPlayer->volume());
5258
playButton->setEnabled(true);
59+
QSize resolution = mediaPlayer->media().canonicalResource().resolution();
60+
this->setGeometry(0,0, resolution.width(), resolution.height());
5361
}
54-
QSize resolution = mediaPlayer->media().canonicalResource().resolution();
55-
this->setGeometry(0,0, resolution.width(), resolution.height());
5662

5763
mediaPlayer->setVideoOutput(this->videoWidget);
5864
}

src/Test/VideoTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <QtMultimedia/QMediaPlayer>
77
#include <QtNetwork/QNetworkRequest>
88

9+
#include "TestVariables.h"
10+
911
class VideoTestWidget;
1012
class QAbstractButton;
1113
class QMediaPlayer;

src/Test/main.cc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
#include <iostream>
1818

19+
#include "TestVariables.h"
20+
std::string tests::testDataFolder;
21+
22+
1923
#include "WindowTest.h"
2024
#include "ClickTest.h"
2125
#include "ElementAttributeTest.h"
@@ -206,8 +210,20 @@ int main(int argc, char *argv[])
206210
return 0;
207211
}
208212

213+
// check if --test_data_folder CL argument is present
214+
std::string testDataFolderSwitch = "test_data_folder";
215+
if (cmd_line.HasSwitch(testDataFolderSwitch)) {
216+
std::cout << "HasSwitch"<<std::endl;
217+
tests::testDataFolder = cmd_line.GetSwitchValueASCII(testDataFolderSwitch);
218+
std::cout << "HasSwitch "<< tests::testDataFolder << std::endl;
219+
} else {
220+
std::cout << "Hasn'tSwitch"<<std::endl;
221+
tests::testDataFolder = "./";
222+
std::cout << "Hasn'tSwitch"<<std::endl;
223+
}
224+
209225
#if defined(OS_WIN)
210-
#if (QT_VERSION == QT_VERSION_CHECK(5, 1, 0))
226+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
211227
system("qtenv2.bat vsvars");
212228
#else //QT_VERSION
213229
system("qtvars.bat vsvars");

0 commit comments

Comments
 (0)