Skip to content

Commit 329ce03

Browse files
committed
added WindowWithDeclarativeViewTestWidget for hybrid tests
1 parent 8cec55c commit 329ce03

File tree

4 files changed

+108
-1
lines changed

4 files changed

+108
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
vbl->addWidget(pView);
41+
this->setLayout(vbl);
42+
}
43+
44+
WindowWithDeclarativeViewTestWidget::~WindowWithDeclarativeViewTestWidget() { }
45+
46+
void WindowWithDeclarativeViewTestWidget::loadQML() {
47+
pView->setSource(QUrl(pLineEdit->text()));
48+
pView->show();
49+
}
50+
51+
void WindowWithDeclarativeViewTestWidget::displayStatus() {
52+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
53+
if (pView->status() == QQuickView::Ready)
54+
#else
55+
if (pView->status() == QDeclarativeView::Ready)
56+
#endif
57+
pLabel->setText("Loading successfully");
58+
59+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
60+
if (pView->status() == QQuickView::Error)
61+
#else
62+
if (pView->status() == QDeclarativeView::Error)
63+
#endif
64+
pLabel->setText("Error");
65+
}
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
@@ -32,6 +32,8 @@
3232
#include "VisibilityTest.h"
3333
#include "BasicMouseInterfaceTest.h"
3434

35+
#include "WindowWithDeclarativeViewTest.h"
36+
3537
// Commented VideoTest due to error https://bugreports.qt-project.org/browse/QTBUG-32949
3638
#ifndef OS_IOS
3739
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@@ -126,6 +128,7 @@ int main(int argc, char *argv[])
126128
widgetCreator->RegisterViewClass<StaleElementReferenceTestWidget>("StaleElementReferenceTestWidget");
127129
widgetCreator->RegisterViewClass<VisibilityTestWidget>("VisibilityTestWidget");
128130
widgetCreator->RegisterViewClass<BasicMouseInterfaceTestWidget>("BasicMouseInterfaceTestWidget");
131+
widgetCreator->RegisterViewClass<WindowWithDeclarativeViewTestWidget>("WindowWithDeclarativeViewTestWidget");
129132

130133
#ifndef OS_IOS
131134
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@@ -229,7 +232,6 @@ int main(int argc, char *argv[])
229232
return startError;
230233

231234
setQtSettings();
232-
233235
return app.exec();
234236
}
235237

wd_test.gyp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@
238238
'src/Test/RestyledLabel.cc',
239239
'src/Test/DragableWidget.cc',
240240
'src/Test/BasicMouseInterfaceTest.cc',
241+
'src/Test/WindowWithDeclarativeViewTest.cc',
242+
'src/Test/WindowWithDeclarativeViewTest.h',
243+
'<(INTERMEDIATE_DIR)/moc_WindowWithDeclarativeViewTest.cc',
241244
],
242245
'conditions': [
243246
# IGNORE VideoTest due to error https://bugreports.qt-project.org/browse/QTBUG-32949

0 commit comments

Comments
 (0)