Falkon
Develop
Cross-platform Qt-based web browser
pyfalkontestrunner.cpp
Go to the documentation of this file.
1
/* ============================================================
2
* Falkon - Qt web browser
3
* Copyright (C) 2018 David Rosca <nowrep@gmail.com>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* ============================================================ */
18
#include "
qztools.h
"
19
#include "
mainapplication.h
"
20
21
#include <iostream>
22
#include <QLibrary>
23
#include <QtTest/QTest>
24
25
int
main
(
int
argc,
char
**argv)
26
{
27
if
(argc != 2) {
28
std::cerr <<
"pyfalkontestrunner [test.py]"
<< std::endl;
29
return
1;
30
}
31
32
QzTools::removeRecursively
(QDir::tempPath() +
QSL
(
"/Falkon-test"
));
33
MainApplication::setTestModeEnabled
(
true
);
34
MainApplication
app(argc, argv);
35
36
#if defined(Q_OS_MACOS)
37
const
QString suffix =
QSL
(
"dylib"
);
38
#elif defined(Q_OS_UNIX)
39
const
QString suffix =
QSL
(
"so"
);
40
#elif defined(Q_OS_WIN)
41
const
QString suffix =
QSL
(
"dll"
);
42
#endif
43
44
QLibrary library(QFINDTESTDATA(
QSL
(
"plugins/PyFalkon."
) + suffix));
45
library.setLoadHints(QLibrary::ExportExternalSymbolsHint);
46
if
(!library.load()) {
47
std::cerr << qPrintable(library.errorString()) << std::endl;
48
return
2;
49
}
50
51
auto
run_script = (bool(*)(
const
QByteArray&)) library.resolve(
"pyfalkon_run_script"
);
52
if
(!run_script) {
53
return
3;
54
}
55
56
QFile file(app.arguments().at(1));
57
if
(!file.open(QFile::ReadOnly)) {
58
std::cerr <<
"Failed to open "
<< qPrintable(file.fileName()) <<
" for reading"
<< std::endl;
59
return
4;
60
}
61
62
if
(!run_script(file.readAll())) {
63
return
5;
64
}
65
66
return
0;
67
}
MainApplication
Definition:
mainapplication.h:59
MainApplication::setTestModeEnabled
static void setTestModeEnabled(bool enabled)
Definition:
mainapplication.cpp:694
QzTools::removeRecursively
static bool removeRecursively(const QString &filePath)
Definition:
qztools.cpp:139
mainapplication.h
main
int main(int argc, char **argv)
Definition:
pyfalkontestrunner.cpp:25
QSL
#define QSL(x)
Definition:
qzcommon.h:40
qztools.h
src
plugins
PyFalkon
autotests
pyfalkontestrunner.cpp
Generated by
1.9.3