Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
4524a403
Commit
4524a403
authored
Jul 17, 2017
by
Wescoeur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(App): supports test, `self-test` is now a test and not a program option
parent
c457fbad
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
110 additions
and
71 deletions
+110
-71
CMakeLists.txt
CMakeLists.txt
+2
-1
en.ts
assets/languages/en.ts
+0
-8
fr.ts
assets/languages/fr.ts
+0
-8
App.cpp
src/app/App.cpp
+6
-25
App.hpp
src/app/App.hpp
+0
-2
AppController.cpp
src/app/AppController.cpp
+1
-7
AppController.hpp
src/app/AppController.hpp
+1
-4
main.cpp
src/app/main.cpp
+1
-1
main.cpp
src/tests/main.cpp
+56
-8
SelfTest.cpp
src/tests/self-test/SelfTest.cpp
+37
-0
SelfTest.hpp
src/tests/self-test/SelfTest.hpp
+6
-7
No files found.
CMakeLists.txt
View file @
4524a403
...
...
@@ -213,7 +213,8 @@ set(HEADERS
)
set
(
TESTS
src/tests/SelfTest.cpp
src/tests/self-test/SelfTest.cpp
src/tests/self-test/SelfTest.hpp
)
set
(
MAIN_FILE src/app/main.cpp
)
...
...
assets/languages/en.ts
View file @
4524a403
...
...
@@ -40,10 +40,6 @@
<
/context
>
<
context
>
<
name
>
App
<
/name
>
<
message
>
<
source
>
selfTestResult
<
/source
>
<
translation
>
Linphone
seems
to
be
running
correctly
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
commandLineOptionVerbose
<
/source
>
<
translation
>
log
to
stdout
some
debug
information
while
running
<
/translation
>
...
...
@@ -52,10 +48,6 @@
<
source
>
commandLineOptionConfig
<
/source
>
<
translation
>
specify
the
linphone
configuration
file
to
be
used
<
/translation
>
<
/message
>
<
message
>
<
source
>
commandLineOptionSelfTest
<
/source
>
<
translation
>
run
self
test
and
exit
0
if
it
succeeded
<
/translation
>
<
/message
>
<
message
>
<
source
>
applicationDescription
<
/source
>
<
translation
>
A
free
(
libre
)
SIP
video
-
phone
.
<
/translation
>
...
...
assets/languages/fr.ts
View file @
4524a403
...
...
@@ -40,10 +40,6 @@
<
/context
>
<
context
>
<
name
>
App
<
/name
>
<
message
>
<
source
>
selfTestResult
<
/source
>
<
translation
>
Linphone
semble
fonctionner
normalement
.
<
/translation
>
<
/message
>
<
message
>
<
source
>
commandLineOptionVerbose
<
/source
>
<
translation
>
afficher
sur
stdout
les
informations
de
debug
<
/translation
>
...
...
@@ -52,10 +48,6 @@
<
source
>
commandLineOptionConfig
<
/source
>
<
translation
>
sp
é
cifier
un
fichier
de
configuration
à
utiliser
<
/translation
>
<
/message
>
<
message
>
<
source
>
commandLineOptionSelfTest
<
/source
>
<
translation
>
é
x
é
cuter
un
test
automatique
et
retourner
0
en
cas
de
succ
è
s
<
/translation
>
<
/message
>
<
message
>
<
source
>
applicationDescription
<
/source
>
<
translation
>
Un
logiciel
libre
de
voix
sur
IP
SIP
.
<
/translation
>
...
...
src/app/App.cpp
View file @
4524a403
...
...
@@ -55,8 +55,6 @@
#define QML_VIEW_SPLASH_SCREEN "qrc:/ui/views/App/SplashScreen/SplashScreen.qml"
#define SELF_TEST_DELAY 300000
#define VERSION_UPDATE_CHECK_INTERVAL 86400000 // 24 hours in milliseconds.
using
namespace
std
;
...
...
@@ -202,19 +200,12 @@ void App::initContentApp () {
mNotifier
=
new
Notifier
(
mEngine
);
// Load splashscreen.
bool
selfTest
=
mParser
->
isSet
(
"self-test"
);
if
(
!
selfTest
)
{
#ifdef Q_OS_MACOS
::
activeSplashScreen
(
mEngine
);
#else
if
(
!
mParser
->
isSet
(
"iconified"
))
::
activeSplashScreen
(
mEngine
);
#endif // ifdef Q_OS_MACOS
}
else
// Set a self test limit.
QTimer
::
singleShot
(
SELF_TEST_DELAY
,
this
,
[]
{
qFatal
(
"Self test failed. :("
);
});
// Load main view.
qInfo
()
<<
QStringLiteral
(
"Loading main view..."
);
...
...
@@ -225,7 +216,7 @@ void App::initContentApp () {
QObject
::
connect
(
CoreManager
::
getInstance
()
->
getHandlers
().
get
(),
&
CoreHandlers
::
coreStarted
,
this
,
selfTest
?
&
App
::
quit
:
&
App
::
openAppAfterInit
this
,
&
App
::
openAppAfterInit
);
}
...
...
@@ -308,7 +299,6 @@ void App::createParser () {
#ifndef Q_OS_MACOS
{
"iconified"
,
tr
(
"commandLineOptionIconified"
)
},
#endif // ifndef Q_OS_MACOS
{
"self-test"
,
tr
(
"commandLineOptionSelfTest"
)
},
{
{
"V"
,
"verbose"
},
tr
(
"commandLineOptionVerbose"
)
}
// TODO: Enable me in future version!
// ,
...
...
@@ -569,12 +559,3 @@ void App::checkForUpdate () {
::
Utils
::
appStringToCoreString
(
applicationVersion
())
);
}
// -----------------------------------------------------------------------------
void
App
::
quit
()
{
if
(
mParser
->
isSet
(
"self-test"
))
cout
<<
tr
(
"selfTestResult"
).
toStdString
()
<<
endl
;
QApplication
::
quit
();
}
src/app/App.hpp
View file @
4524a403
...
...
@@ -71,8 +71,6 @@ public:
bool
hasFocus
()
const
;
void
quit
()
override
;
static
App
*
getInstance
()
{
return
static_cast
<
App
*>
(
QApplication
::
instance
());
}
...
...
src/app/AppController.cpp
View file @
4524a403
...
...
@@ -39,15 +39,9 @@ using namespace std;
// =============================================================================
#ifndef QT_NO_DEBUG
bool
AppController
::
mCreated
=
false
;
#endif // ifndef QT_NO_DEBUG
AppController
::
AppController
(
int
&
argc
,
char
*
argv
[])
{
Q_ASSERT
(
!
mCreated
);
mCreated
=
true
;
QT_REQUIRE_VERSION
(
argc
,
argv
,
APPLICATION_MINIMAL_QT_VERSION
);
Q_ASSERT
(
!
mApp
);
// Disable QML cache. Avoid malformed cache.
qputenv
(
"QML_DISABLE_DISK_CACHE"
,
"true"
);
...
...
src/app/AppController.hpp
View file @
4524a403
...
...
@@ -30,13 +30,10 @@ public:
~
AppController
();
App
*
getApp
()
const
{
Q_CHECK_PTR
(
mApp
);
return
mApp
;
}
private:
App
*
mApp
=
nullptr
;
#ifndef QT_NO_DEBUG
static
bool
mCreated
;
#endif // ifndef QT_NO_DEBUG
};
src/app/main.cpp
View file @
4524a403
...
...
@@ -28,7 +28,7 @@ int main (int argc, char *argv[]) {
AppController
controller
(
argc
,
argv
);
App
*
app
=
controller
.
getApp
();
if
(
app
->
isSecondary
())
return
0
;
return
EXIT_SUCCESS
;
qInfo
()
<<
QStringLiteral
(
"Running app..."
);
...
...
src/tests/main.cpp
View file @
4524a403
...
...
@@ -20,22 +20,70 @@
* Author: Ronan Abhamon
*/
#include <QTest>
#include <QTimer>
#include "../app/AppController.hpp"
#include "../utils/Utils.hpp"
#include "self-test/SelfTest.hpp"
// =============================================================================
static
QHash
<
QString
,
QObject
*>
initializeTests
()
{
QHash
<
QString
,
QObject
*>
hash
;
// TODO: Add tests here.
return
hash
;
}
// -----------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[])
{
AppController
controller
(
argc
,
argv
);
int
fakeArgc
=
1
;
AppController
controller
(
fakeArgc
,
argv
);
App
*
app
=
controller
.
getApp
();
if
(
app
->
isSecondary
())
return
0
;
qFatal
(
"Unable to run test with secondary app."
)
;
qInfo
()
<<
QStringLiteral
(
"Running test..."
);
const
QHash
<
QString
,
QObject
*>
tests
=
initializeTests
();
QObject
*
test
=
nullptr
;
if
(
argc
>
1
)
{
if
(
!
strcmp
(
argv
[
1
],
"self-test"
))
// Execute only self-test.
QTimer
::
singleShot
(
0
,
[
app
]
{
QTest
::
qExec
(
new
SelfTest
(
app
));
QCoreApplication
::
quit
();
});
else
{
// Execute only one test.
const
QString
testName
=
::
Utils
::
coreStringToAppString
(
argv
[
1
]);
test
=
tests
[
testName
];
if
(
!
test
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to run invalid test: `%1`."
).
arg
(
testName
);
return
EXIT_FAILURE
;
}
QTimer
::
singleShot
(
0
,
[
app
,
test
,
argc
,
argv
]
{
QTest
::
qExec
(
new
SelfTest
(
app
));
QTest
::
qExec
(
test
,
argc
-
1
,
argv
+
1
);
QCoreApplication
::
quit
();
});
}
}
else
// Execute all tests.
QTimer
::
singleShot
(
0
,
[
app
,
&
tests
]
{
QTest
::
qExec
(
new
SelfTest
(
app
));
for
(
const
auto
&
test
:
tests
)
QTest
::
qExec
(
test
);
QCoreApplication
::
quit
();
});
int
ret
;
do
{
app
->
initContentApp
();
ret
=
app
->
exec
();
}
while
(
ret
==
APP_CODE_RESTART
);
int
ret
=
app
->
exec
();
for
(
auto
&
test
:
tests
)
delete
test
;
return
ret
;
}
src/tests/self-test/SelfTest.cpp
0 → 100644
View file @
4524a403
/*
* SelfTest.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: July 17, 2017
* Author: Ronan Abhamon
*/
#include <QSignalSpy>
#include <QTest>
#include "../../components/core/CoreManager.hpp"
#include "SelfTest.hpp"
#define SELF_TEST_DELAY 5000
// =============================================================================
void
SelfTest
::
checkAppStartup
()
{
QSignalSpy
spy
(
CoreManager
::
getInstance
()
->
getHandlers
().
get
(),
&
CoreHandlers
::
coreStarted
);
QVERIFY
(
spy
.
wait
(
SELF_TEST_DELAY
));
}
src/tests/
SelfTest.c
pp
→
src/tests/
self-test/SelfTest.h
pp
View file @
4524a403
/*
* SelfTest.
c
pp
* SelfTest.
h
pp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
...
...
@@ -20,17 +20,16 @@
* Author: Ronan Abhamon
*/
#include <Q
Tes
t>
#include <Q
Objec
t>
// =============================================================================
class
SelfTest
:
public
QObject
{
Q_OBJECT
;
public:
SelfTest
(
QObject
*
parent
=
Q_NULLPTR
)
:
QObject
(
parent
)
{}
private
slots
:
void
t1
()
{
QVERIFY
(
true
);
}
void
checkAppStartup
();
};
#include "SelfTest.moc"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment