Skip to content

Commit ad7fdf9

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 5476ca8 + e7fcdd4 commit ad7fdf9

File tree

6 files changed

+104
-35
lines changed

6 files changed

+104
-35
lines changed

src/Test/WindowWithDeclarativeViewTest.cc

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,10 @@ WindowWithDeclarativeViewTestWidget::WindowWithDeclarativeViewTestWidget(QWidget
1616
pLabel->setObjectName("labelStatus");
1717
pLabel->setVisible(true);
1818

19-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
20-
pView = new QQuickView();
21-
#else
2219
pView = new QDeclarativeView();
23-
#endif
24-
2520
pView->setObjectName("declarativeView");
2621

27-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
28-
connect(pView, SIGNAL(statusChanged(QQuickView::Status)), this, SLOT(displayStatus()));
29-
#else
3022
connect(pView, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(displayStatus()));
31-
#endif
3223

3324
QHBoxLayout* hbl = new QHBoxLayout();
3425
hbl->addWidget(pLineEdit);
@@ -37,12 +28,9 @@ WindowWithDeclarativeViewTestWidget::WindowWithDeclarativeViewTestWidget(QWidget
3728
QVBoxLayout *vbl = new QVBoxLayout(this);
3829
vbl->addLayout(hbl);
3930
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
31+
4432
vbl->addWidget(pView);
45-
#endif
33+
4634
this->setLayout(vbl);
4735
}
4836

@@ -54,17 +42,13 @@ void WindowWithDeclarativeViewTestWidget::loadQML() {
5442
}
5543

5644
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
45+
46+
if (pView->status() == QDeclarativeView::Ready) {
6247
pLabel->setText("Loading successfully");
48+
return;
49+
}
6350

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
51+
if (pView->status() == QDeclarativeView::Error) {
6952
pLabel->setText("Error");
53+
}
7054
}

src/Test/WindowWithDeclarativeViewTest.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33

44
#include "CommonQtTestHeaders.h"
55

6-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
7-
#include <QtQuick/QQuickView>
8-
#else
96
#include <QtDeclarative/QDeclarativeView>
10-
#endif
11-
127

138
class WindowWithDeclarativeViewTestWidget : public QWidget
149
{
@@ -25,12 +20,8 @@ public slots:
2520
QPushButton* pButton;
2621
QLineEdit* pLineEdit;
2722
QLabel *pLabel;
28-
29-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
30-
QQuickView *pView;
31-
#else
3223
QDeclarativeView *pView;
33-
#endif
24+
3425

3526
};
3627

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include "WindowWithSeparatedDeclarativeAndWebViewsTest.h"
2+
3+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
4+
#include <QtWebKitWidgets/QWebView>
5+
#else
6+
#include <QtWebKit/QWebView>
7+
#endif
8+
9+
#include <QtDeclarative/QDeclarativeView>
10+
11+
WindowWithSeparatedDeclarativeAndWebViewsTestWidget::WindowWithSeparatedDeclarativeAndWebViewsTestWidget(QWidget *parent) :
12+
QWidget(parent) {
13+
this->setWindowTitle("Test Widget");
14+
pLineEditForWeb = new QLineEdit();
15+
pLineEditForWeb->setObjectName("inputWebURL");
16+
connect(pLineEditForWeb, SIGNAL(returnPressed()), this, SLOT(openWebView()));
17+
18+
pButtonWeb = new QPushButton("Go to Web!");
19+
pButtonWeb->setObjectName("openWebViewButton");
20+
connect(pButtonWeb, SIGNAL(clicked()), this, SLOT(openWebView()));
21+
22+
pLineEditForQml = new QLineEdit();
23+
pLineEditForQml->setObjectName("inputQmlURL");
24+
connect(pLineEditForQml, SIGNAL(returnPressed()), this, SLOT(openQmlView()));
25+
26+
pButtonQml = new QPushButton("Go to Qml!");
27+
pButtonQml->setObjectName("openQmlViewButton");
28+
connect(pButtonQml, SIGNAL(clicked()), this, SLOT(openQmlView()));
29+
30+
QHBoxLayout* hblweb = new QHBoxLayout();
31+
hblweb->addWidget(pLineEditForWeb);
32+
hblweb->addWidget(pButtonWeb);
33+
34+
QHBoxLayout* hblqml = new QHBoxLayout();
35+
hblqml->addWidget(pLineEditForQml);
36+
hblqml->addWidget(pButtonQml);
37+
38+
QVBoxLayout* vbl = new QVBoxLayout();
39+
vbl->addLayout(hblweb);
40+
vbl->addLayout(hblqml);
41+
this->setLayout(vbl);
42+
}
43+
44+
WindowWithSeparatedDeclarativeAndWebViewsTestWidget::~WindowWithSeparatedDeclarativeAndWebViewsTestWidget() {}
45+
46+
void WindowWithSeparatedDeclarativeAndWebViewsTestWidget::openWebView() {
47+
QWebView *pWebView = new QWebView;
48+
pWebView->setAttribute(Qt::WA_DeleteOnClose);
49+
pWebView->load(pLineEditForWeb->text());
50+
pWebView->show();
51+
}
52+
53+
void WindowWithSeparatedDeclarativeAndWebViewsTestWidget::openQmlView() {
54+
QDeclarativeView *pView = new QDeclarativeView();
55+
pView->setAttribute(Qt::WA_DeleteOnClose);
56+
pView->setSource(pLineEditForQml->text());
57+
pView->show();
58+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef WINDOWWITHSEPARATEDDECLARATIVEANDWEBVIEWSTEST_H
2+
#define WINDOWWITHSEPARATEDDECLARATIVEANDWEBVIEWSTEST_H
3+
4+
#include "CommonQtTestHeaders.h"
5+
6+
class WindowWithSeparatedDeclarativeAndWebViewsTestWidget : public QWidget
7+
{
8+
Q_OBJECT
9+
public:
10+
explicit WindowWithSeparatedDeclarativeAndWebViewsTestWidget(QWidget *parent = 0);
11+
~WindowWithSeparatedDeclarativeAndWebViewsTestWidget();
12+
13+
public slots:
14+
void openWebView();
15+
void openQmlView();
16+
17+
private:
18+
QPushButton* pButtonWeb;
19+
QLineEdit* pLineEditForWeb;
20+
QPushButton* pButtonQml;
21+
QLineEdit* pLineEditForQml;
22+
23+
};
24+
25+
#endif // WINDOWWITHSEPARATEDDECLARATIVEANDWEBVIEWSTEST_H

src/Test/main.cc

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

39+
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
40+
#include "WindowWithSeparatedDeclarativeAndWebViewsTest.h"
3941
#include "WindowWithDeclarativeViewTest.h"
42+
#endif
4043

4144
// Commented VideoTest due to error https://bugreports.qt-project.org/browse/QTBUG-32949
4245
#ifndef OS_IOS
@@ -132,7 +135,9 @@ int main(int argc, char *argv[])
132135
widgetCreator->RegisterViewClass<StaleElementReferenceTestWidget>("StaleElementReferenceTestWidget");
133136
widgetCreator->RegisterViewClass<VisibilityTestWidget>("VisibilityTestWidget");
134137
widgetCreator->RegisterViewClass<BasicMouseInterfaceTestWidget>("BasicMouseInterfaceTestWidget");
138+
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
135139
widgetCreator->RegisterViewClass<WindowWithDeclarativeViewTestWidget>("WindowWithDeclarativeViewTestWidget");
140+
#endif
136141

137142
#ifndef OS_IOS
138143
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@@ -150,6 +155,9 @@ int main(int argc, char *argv[])
150155
webdriver::ViewCmdExecutorFactory::GetInstance()->AddViewCmdExecutorCreator(new webdriver::QWebViewCmdExecutorCreator());
151156
widgetCreator->RegisterViewClass<WindowWithEmbeddedViewTestWidget>("WindowWithEmbeddedViewTestWidget");
152157
widgetCreator->RegisterViewClass<WidgetAndWebViewTestWindows>("WidgetAndWebViewTestWindows");
158+
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
159+
widgetCreator->RegisterViewClass<WindowWithSeparatedDeclarativeAndWebViewsTestWidget>("WindowWithSeparatedDeclarativeAndWebViewsTestWidget");
160+
#endif
153161
#endif
154162

155163
#ifndef OS_IOS
@@ -178,7 +186,7 @@ int main(int argc, char *argv[])
178186
qmlRegisterType<QDeclarativeWebView>("CiscoQtWebKit", 1, 1, "CiscoWebView");
179187
qmlRegisterRevision<QDeclarativeWebView, 0>("CiscoQtWebKit", 1, 0);
180188
qmlRegisterRevision<QDeclarativeWebView, 1>("CiscoQtWebKit", 1, 1);
181-
webdriver::ViewEnumerator::AddViewEnumeratorImpl(new webdriver::QmlWebViewEnumeratorImpl());
189+
webdriver::ViewEnumerator::AddViewEnumeratorImpl(new webdriver::QmlWebViewEnumeratorImpl());
182190
webdriver::ViewCmdExecutorFactory::GetInstance()->AddViewCmdExecutorCreator(new webdriver::QmlWebViewCmdExecutorCreator());
183191
#endif
184192

wd_test.gyp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@
241241
'src/Test/WindowWithDeclarativeViewTest.cc',
242242
'src/Test/WindowWithDeclarativeViewTest.h',
243243
'<(INTERMEDIATE_DIR)/moc_WindowWithDeclarativeViewTest.cc',
244+
'src/Test/WindowWithSeparatedDeclarativeAndWebViewsTest.cc',
245+
'src/Test/WindowWithSeparatedDeclarativeAndWebViewsTest.h',
246+
'<(INTERMEDIATE_DIR)/moc_WindowWithSeparatedDeclarativeAndWebViewsTest.cc',
244247
],
245248
'conditions': [
246249
# IGNORE VideoTest due to error https://bugreports.qt-project.org/browse/QTBUG-32949

0 commit comments

Comments
 (0)