Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
b83fe641
Commit
b83fe641
authored
Sep 06, 2017
by
Ronan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(EventsDb): fixes + add new test
parent
7dab187b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
15 deletions
+85
-15
src/db/abstract/abstract-db.cpp
src/db/abstract/abstract-db.cpp
+13
-2
src/db/events-db.cpp
src/db/events-db.cpp
+7
-7
tester/CMakeLists.txt
tester/CMakeLists.txt
+13
-6
tester/db/linphone.db
tester/db/linphone.db
+0
-0
tester/db/messages.db
tester/db/messages.db
+0
-0
tester/events-db-tester.cpp
tester/events-db-tester.cpp
+50
-0
tester/liblinphone_tester.h
tester/liblinphone_tester.h
+1
-0
tester/tester.c
tester/tester.c
+1
-0
No files found.
src/db/abstract/abstract-db.cpp
View file @
b83fe641
...
...
@@ -18,6 +18,7 @@
#include "abstract-db-p.h"
#include "db/provider/db-session-provider.h"
#include "logger/logger.h"
#include "abstract-db.h"
...
...
@@ -32,12 +33,22 @@ AbstractDb::AbstractDb (AbstractDbPrivate &p) : Object(*new AbstractDbPrivate) {
bool
AbstractDb
::
connect
(
Backend
backend
,
const
string
&
parameters
)
{
L_D
(
AbstractDb
);
d
->
backend
=
backend
;
d
->
dbSession
=
DbSessionProvider
::
getInstance
()
->
getSession
(
(
backend
==
Mysql
?
"mysql://"
:
"sqlite3://"
)
+
parameters
);
if
(
d
->
dbSession
)
init
();
if
(
d
->
dbSession
)
{
try
{
init
();
}
catch
(
const
exception
&
e
)
{
lWarning
()
<<
"Unable to init database: "
<<
e
.
what
();
// Reset session.
d
->
dbSession
=
DbSession
();
}
}
return
d
->
dbSession
;
}
...
...
src/db/events-db.cpp
View file @
b83fe641
...
...
@@ -140,7 +140,7 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
*
session
<<
"CREATE TABLE IF NOT EXISTS event_type ("
" id
"
+
primaryKeyAutoIncrementStr
(
"TINYINT"
)
+
"
,"
" id
TINYINT UNSIGNED
,"
" value VARCHAR(255) NOT NULL"
")"
;
...
...
@@ -156,14 +156,14 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
*
session
<<
"CREATE TABLE IF NOT EXISTS message_state ("
" id
"
+
primaryKeyAutoIncrementStr
(
"TINYINT"
)
+
"
,"
"
stat
e VARCHAR(255) NOT NULL"
" id
TINYINT UNSIGNED
,"
"
valu
e VARCHAR(255) NOT NULL"
")"
;
*
session
<<
"CREATE TABLE IF NOT EXISTS message_direction ("
" id
"
+
primaryKeyAutoIncrementStr
(
"TINYINT"
)
+
"
,"
"
direction
VARCHAR(255) NOT NULL"
" id
TINYINT UNSIGNED
,"
"
value
VARCHAR(255) NOT NULL"
")"
;
*
session
<<
...
...
@@ -188,9 +188,9 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
" state_id TINYINT UNSIGNED NOT NULL,"
" direction_id TINYINT UNSIGNED NOT NULL,"
" imdn_message_id VARCHAR(255) NOT NULL,"
// See: https://tools.ietf.org/html/rfc5438#section-6.3
" content_type VARCHAR(255) NOT NULL,"
" content_type VARCHAR(255) NOT NULL,"
// Content type of text. (Html or text for example.)
" is_secured BOOLEAN NOT NULL,"
" app_data VARCHAR(2048),"
" app_data VARCHAR(2048),"
// App user data.
" FOREIGN KEY (dialog_id)"
" REFERENCES dialog(id)"
" ON DELETE CASCADE,"
...
...
tester/CMakeLists.txt
View file @
b83fe641
...
...
@@ -76,6 +76,11 @@ set(CERTIFICATE_CLIENT_FILES
set
(
CERTIFICATE_FILES
${
CERTIFICATE_ALT_FILES
}
${
CERTIFICATE_CN_FILES
}
${
CERTIFICATE_CLIENT_FILES
}
)
set
(
DB_FILES
db/linphone.db
db/messages.db
)
set
(
RC_FILES
rcfiles/account_creator_rc
rcfiles/assistant_create.rc
...
...
@@ -146,11 +151,11 @@ set(VCARD_FILES
set
(
OTHER_FILES
tester_hosts
local_tester_hosts
messages.db
)
set
(
IOS_RESOURCES_FILES
${
OTHER_FILES
}
${
DB_FILES
}
certificates
images
rcfiles
...
...
@@ -195,6 +200,7 @@ set(SOURCE_FILES_C
set
(
SOURCE_FILES_CXX
clonable-object-tester.cpp
cpim-tester.cpp
events-db-tester.cpp
)
set
(
SOURCE_FILES_OBJC
)
...
...
@@ -308,14 +314,15 @@ if (NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
install
(
FILES
${
OTHER_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester"
)
install
(
FILES
${
SOUND_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/sounds"
)
install
(
FILES
${
SIPP_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/sipp"
)
install
(
FILES
${
CERTIFICATE_ALT_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/certificates/altname"
)
install
(
FILES
${
CERTIFICATE_CN_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/certificates/cn"
)
install
(
FILES
${
CERTIFICATE_CLIENT_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/certificates/client"
)
install
(
FILES
${
RC_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/rcfiles"
)
install
(
FILES
${
CERTIFICATE_CN_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/certificates/cn"
)
install
(
FILES
${
DB_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/db"
)
install
(
FILES
${
IMAGE_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/images"
)
install
(
FILES
${
OTHER_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester"
)
install
(
FILES
${
RC_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/rcfiles"
)
install
(
FILES
${
SIPP_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/sipp"
)
install
(
FILES
${
SOUND_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/sounds"
)
install
(
FILES
${
VCARD_FILES
}
DESTINATION
"
${
CMAKE_INSTALL_DATADIR
}
/liblinphone_tester/vcards"
)
endif
()
endif
()
tester/db/linphone.db
0 → 100644
View file @
b83fe641
File added
tester/messages.db
→
tester/
db/
messages.db
View file @
b83fe641
File moved
tester/events-db-tester.cpp
0 → 100644
View file @
b83fe641
/*
* events-db-tester.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "db/events-db.h"
#include "liblinphone_tester.h"
// =============================================================================
using
namespace
std
;
using
namespace
LinphonePrivate
;
// -----------------------------------------------------------------------------
static
const
string
getDatabasePath
()
{
static
const
string
path
=
string
(
bc_tester_get_resource_dir_prefix
())
+
"/db/linphone.db"
;
return
path
;
}
// -----------------------------------------------------------------------------
static
void
open_database
()
{
EventsDb
eventsDb
;
eventsDb
.
connect
(
EventsDb
::
Sqlite3
,
getDatabasePath
());
}
test_t
events_db_tests
[]
=
{
TEST_NO_TAG
(
"Open database"
,
open_database
)
};
test_suite_t
events_db_test_suite
=
{
"EventsDb"
,
NULL
,
NULL
,
liblinphone_tester_before_each
,
liblinphone_tester_after_each
,
sizeof
(
events_db_tests
)
/
sizeof
(
events_db_tests
[
0
]),
events_db_tests
};
tester/liblinphone_tester.h
View file @
b83fe641
...
...
@@ -46,6 +46,7 @@ extern test_suite_t clonable_object_test_suite;
extern
test_suite_t
cpim_test_suite
;
extern
test_suite_t
dtmf_test_suite
;
extern
test_suite_t
event_test_suite
;
extern
test_suite_t
events_db_test_suite
;
extern
test_suite_t
flexisip_test_suite
;
extern
test_suite_t
log_collection_test_suite
;
extern
test_suite_t
message_test_suite
;
...
...
tester/tester.c
View file @
b83fe641
...
...
@@ -575,6 +575,7 @@ void liblinphone_tester_add_suites() {
bc_tester_add_suite
(
&
dtmf_test_suite
);
bc_tester_add_suite
(
&
cpim_test_suite
);
bc_tester_add_suite
(
&
clonable_object_test_suite
);
bc_tester_add_suite
(
&
events_db_test_suite
);
#if defined(VIDEO_ENABLED) && defined(HAVE_GTK)
bc_tester_add_suite
(
&
video_test_suite
);
#endif
...
...
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