Skip to content

Commit 7225cf1

Browse files
author
Mykola Tryshnivskyy
committed
Merge branch 'WD_1.X_dev' of https://portal-ua.globallogic.com/git/wd into WD_1.X_dev
2 parents 2ac021b + e932019 commit 7225cf1

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

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: 16 additions & 0 deletions
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"
@@ -203,6 +207,18 @@ int main(int argc, char *argv[])
203207
return 0;
204208
}
205209

210+
// check if --test_data_folder CL argument is present
211+
std::string testDataFolderSwitch = "test_data_folder";
212+
if (cmd_line.HasSwitch(testDataFolderSwitch)) {
213+
std::cout << "HasSwitch"<<std::endl;
214+
tests::testDataFolder = cmd_line.GetSwitchValueASCII(testDataFolderSwitch);
215+
std::cout << "HasSwitch "<< tests::testDataFolder << std::endl;
216+
} else {
217+
std::cout << "Hasn'tSwitch"<<std::endl;
218+
tests::testDataFolder = "./";
219+
std::cout << "Hasn'tSwitch"<<std::endl;
220+
}
221+
206222
#if defined(OS_WIN)
207223
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
208224
system("qtenv2.bat vsvars");

0 commit comments

Comments
 (0)