Skip to content

Commit 2175c60

Browse files
Andrii BoichukAndrii Boichuk
authored andcommitted
Merge branch 'WD_1.X_dev' of https://portal-ua.globallogic.com/git/wd into WD_1.X_dev
2 parents 809a82c + e895f10 commit 2175c60

11 files changed

+606
-86
lines changed

inc/extension_qt/declarative_item_view_handle.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "webdriver_view_id.h"
77

88
#include <QtDeclarative/QDeclarativeItem>
9+
#include <QtDeclarative/QDeclarativeView>
910
#include <QtCore/QPointer>
1011
#include <QtCore/QtGlobal>
1112

@@ -14,14 +15,16 @@ namespace webdriver {
1415
class QDeclarativeItemViewHandle : public ViewHandle {
1516
public:
1617
QDeclarativeItemViewHandle();
17-
QDeclarativeItemViewHandle(QDeclarativeItem* view);
18+
QDeclarativeItemViewHandle(QDeclarativeItem* view, QDeclarativeView* container);
1819

1920
virtual bool is_valid() const { return !view_.isNull(); };
2021
virtual bool equals(const ViewHandle* other) const;
2122
QDeclarativeItem* get() { return view_.data(); };
23+
QDeclarativeView* getContainer() { return container_.data(); };
2224

2325
protected:
2426
QPointer<QDeclarativeItem> view_;
27+
QPointer<QDeclarativeView> container_;
2528
//private:
2629
virtual ~QDeclarativeItemViewHandle() {};
2730
};

inc/extension_qt/qml_web_view_executor.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
#include <vector>
66
#include <map>
77

8+
#include "base/memory/scoped_ptr.h"
89
#include "webdriver_view_executor.h"
910
#include "webdriver_error.h"
1011
#include "extension_qt/qdeclarativewebview.h"
1112

1213
#include <QtCore/QDebug>
1314

15+
class QDeclarativeView;
16+
1417
namespace webdriver {
1518

19+
class QWebkitProxy;
20+
1621
class QmlWebViewCmdExecutorCreator : public ViewCmdExecutorCreator {
1722
public:
1823
static const ViewType QML_WEB_VIEW_TYPE;
@@ -132,6 +137,10 @@ class QmlWebViewCmdExecutor : public ViewCmdExecutor {
132137
#endif
133138

134139
private:
140+
scoped_ptr<QWebkitProxy> webkitProxy_;
141+
QDeclarativeWebView* view_;
142+
QDeclarativeView* container_;
143+
135144
DISALLOW_COPY_AND_ASSIGN(QmlWebViewCmdExecutor);
136145
};
137146

inc/extension_qt/web_view_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class QWebViewCmdExecutor : public QViewCmdExecutor {
124124
QWebView* getView(const ViewId& viewId, Error** error);
125125

126126
private:
127-
QWebkitProxy* webkitProxy_;
127+
scoped_ptr<QWebkitProxy> webkitProxy_;
128128
QWebView* view_;
129129

130130
DISALLOW_COPY_AND_ASSIGN(QWebViewCmdExecutor);
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include "WindowWithDeclarativeViewTest.h"
2+
3+
WindowWithDeclarativeViewTestWidget::WindowWithDeclarativeViewTestWidget(QWidget *parent) :
4+
QWidget(parent)
5+
{
6+
setWindowTitle("Test Window");
7+
pLineEdit = new QLineEdit();
8+
pLineEdit->setObjectName("inputURL");
9+
connect(pLineEdit, SIGNAL(returnPressed()), this, SLOT(loadQML()));
10+
11+
pButton = new QPushButton("Go!");
12+
pButton->setObjectName("loadButton");
13+
connect(pButton, SIGNAL(clicked()), this, SLOT(loadQML()));
14+
15+
pLabel = new QLabel("Status");
16+
pLabel->setObjectName("labelStatus");
17+
pLabel->setVisible(true);
18+
19+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
20+
pView = new QQuickView();
21+
#else
22+
pView = new QDeclarativeView();
23+
#endif
24+
25+
pView->setObjectName("declarativeView");
26+
27+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
28+
connect(pView, SIGNAL(statusChanged(QQuickView::Status)), this, SLOT(displayStatus()));
29+
#else
30+
connect(pView, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(displayStatus()));
31+
#endif
32+
33+
QHBoxLayout* hbl = new QHBoxLayout();
34+
hbl->addWidget(pLineEdit);
35+
hbl->addWidget(pButton);
36+
37+
QVBoxLayout *vbl = new QVBoxLayout(this);
38+
vbl->addLayout(hbl);
39+
vbl->addWidget(pLabel);
40+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
41+
QWidget *container = QWidget::createWindowContainer(pView);
42+
vbl->addWidget(container);
43+
#else
44+
vbl->addWidget(pView);
45+
#endif
46+
this->setLayout(vbl);
47+
}
48+
49+
WindowWithDeclarativeViewTestWidget::~WindowWithDeclarativeViewTestWidget() { }
50+
51+
void WindowWithDeclarativeViewTestWidget::loadQML() {
52+
pView->setSource(QUrl(pLineEdit->text()));
53+
pView->show();
54+
}
55+
56+
void WindowWithDeclarativeViewTestWidget::displayStatus() {
57+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
58+
if (pView->status() == QQuickView::Ready)
59+
#else
60+
if (pView->status() == QDeclarativeView::Ready)
61+
#endif
62+
pLabel->setText("Loading successfully");
63+
64+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
65+
if (pView->status() == QQuickView::Error)
66+
#else
67+
if (pView->status() == QDeclarativeView::Error)
68+
#endif
69+
pLabel->setText("Error");
70+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef WINDOWWITHDECLARATIVEVIEWTEST_H
2+
#define WINDOWWITHDECLARATIVEVIEWTEST_H
3+
4+
#include "CommonQtTestHeaders.h"
5+
6+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
7+
#include <QtQuick/QQuickView>
8+
#else
9+
#include <QtDeclarative/QDeclarativeView>
10+
#endif
11+
12+
13+
class WindowWithDeclarativeViewTestWidget : public QWidget
14+
{
15+
Q_OBJECT
16+
public:
17+
explicit WindowWithDeclarativeViewTestWidget(QWidget *parent = 0);
18+
~WindowWithDeclarativeViewTestWidget();
19+
20+
public slots:
21+
void loadQML();
22+
void displayStatus();
23+
24+
private:
25+
QPushButton* pButton;
26+
QLineEdit* pLineEdit;
27+
QLabel *pLabel;
28+
29+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
30+
QQuickView *pView;
31+
#else
32+
QDeclarativeView *pView;
33+
#endif
34+
35+
};
36+
37+
#endif // WINDOWWITHDECLARATIVEVIEWTEST_H

src/Test/main.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ std::string tests::testDataFolder;
3636
#include "VisibilityTest.h"
3737
#include "BasicMouseInterfaceTest.h"
3838

39+
#include "WindowWithDeclarativeViewTest.h"
40+
3941
// Commented VideoTest due to error https://bugreports.qt-project.org/browse/QTBUG-32949
4042
#ifndef OS_IOS
4143
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@@ -130,6 +132,7 @@ int main(int argc, char *argv[])
130132
widgetCreator->RegisterViewClass<StaleElementReferenceTestWidget>("StaleElementReferenceTestWidget");
131133
widgetCreator->RegisterViewClass<VisibilityTestWidget>("VisibilityTestWidget");
132134
widgetCreator->RegisterViewClass<BasicMouseInterfaceTestWidget>("BasicMouseInterfaceTestWidget");
135+
widgetCreator->RegisterViewClass<WindowWithDeclarativeViewTestWidget>("WindowWithDeclarativeViewTestWidget");
133136

134137
#ifndef OS_IOS
135138
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@@ -245,7 +248,6 @@ int main(int argc, char *argv[])
245248
return startError;
246249

247250
setQtSettings();
248-
249251
return app.exec();
250252
}
251253

src/webdriver/extension_qt/declarative_item_view_handle.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
namespace webdriver {
44

55
QDeclarativeItemViewHandle::QDeclarativeItemViewHandle()
6-
: view_((QDeclarativeItem*)NULL) { }
6+
: view_(NULL), container_(NULL) { }
77

8-
QDeclarativeItemViewHandle::QDeclarativeItemViewHandle(QDeclarativeItem* view)
9-
: view_(view) { }
8+
QDeclarativeItemViewHandle::QDeclarativeItemViewHandle(QDeclarativeItem* view, QDeclarativeView* container)
9+
: view_(view), container_(container) { }
1010

1111
bool QDeclarativeItemViewHandle::equals(const ViewHandle* other) const {
1212
const QDeclarativeItemViewHandle* toCompare = dynamic_cast<const QDeclarativeItemViewHandle*>(other);
1313
if (NULL == toCompare) return false;
1414

15-
return view_ == toCompare->view_;
15+
return (view_ == toCompare->view_)&&(container_ == toCompare->container_);
1616
}
1717

1818
} // namespace webdriver

src/webdriver/extension_qt/qml_web_view_enumerator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void QmlWebViewEnumeratorImpl::EnumerateViews(Session* session, std::set<ViewId>
3131
foreach(QDeclarativeItem *child, childs) {
3232
if (isWebView(child)) {
3333
// found
34-
ViewHandlePtr handle(new QDeclarativeItemViewHandle(child));
34+
ViewHandlePtr handle(new QDeclarativeItemViewHandle(child, pView));
3535
ViewId viewId = session->GetViewForHandle(handle);
3636
if (!viewId.is_valid()) {
3737
if (session->AddNewView(handle, &viewId)) {

0 commit comments

Comments
 (0)