Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Librem5
calls
Commits
3e138eec
Unverified
Commit
3e138eec
authored
Mar 20, 2020
by
Julian Sparber
Browse files
Manager: add test
parent
9055724f
Changes
3
Hide whitespace changes
Inline
Side-by-side
meson.build
View file @
3e138eec
...
...
@@ -40,10 +40,13 @@ calls_version = meson.project_version()
top_include
=
include_directories
(
'.'
)
prefix
=
get_option
(
'prefix'
)
builddir
=
meson
.
current_build_dir
()
libdir
=
get_option
(
'libdir'
)
localedir
=
get_option
(
'localedir'
)
full_localedir
=
join_paths
(
prefix
,
localedir
)
full_calls_plugin_libdir
=
join_paths
(
prefix
,
libdir
,
calls_name
,
'plugins'
)
# Path to plugins inside the build dir, used for testing
full_calls_plugin_builddir
=
join_paths
(
builddir
,
'plugins'
)
config_data
=
configuration_data
()
config_data
.
set_quoted
(
'APP_ID'
,
calls_id
)
...
...
tests/meson.build
View file @
3e138eec
...
...
@@ -12,7 +12,8 @@ test_env = [
test_cflags
=
[
'-fPIE'
,
'-DFOR_TESTING'
,
'-Wno-error=deprecated-declarations'
'-Wno-error=deprecated-declarations'
,
'-DPLUGIN_BUILDDIR="@0@"'
.
format
(
full_calls_plugin_builddir
),
]
test_link_args
=
[
...
...
@@ -54,4 +55,20 @@ foreach test : tests
test
(
name
,
t
,
env
:
test_env
)
endforeach
test_sources
=
[
'test-manager.c'
]
t
=
executable
(
'manager'
,
test_sources
,
calls_sources
,
calls_enum_sources
,
calls_resources
,
wl_proto_sources
,
wayland_sources
,
c_args
:
test_cflags
,
link_args
:
test_link_args
,
link_with
:
calls_vala
,
dependencies
:
calls_deps
,
include_directories
:
[
calls_includes
]
)
test
(
'manager'
,
t
,
env
:
test_env
)
endif
tests/test-manager.c
0 → 100644
View file @
3e138eec
/*
* Copyright (C) 2020 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include
"calls-manager.h"
#include
<gtk/gtk.h>
#include
<libpeas/peas.h>
gint
origin_count
=
0
;
CallsCall
*
test_call
=
NULL
;
static
void
origin_add_cb
(
CallsManager
*
manager
)
{
origin_count
++
;
}
static
void
origin_remove_cb
(
CallsManager
*
manager
)
{
origin_count
--
;
}
static
void
call_add_cb
(
CallsManager
*
manager
,
CallsCall
*
call
)
{
test_call
=
call
;
}
static
void
call_remove_cb
(
CallsManager
*
manager
,
CallsCall
*
call
)
{
g_assert
(
call
==
test_call
);
test_call
=
NULL
;
}
static
void
test_calls_manager_without_provider
()
{
g_autoptr
(
CallsManager
)
manager
=
calls_manager_new
();
g_assert
(
CALLS_IS_MANAGER
(
manager
));
g_assert_null
(
calls_manager_get_provider
(
manager
));
g_assert
(
calls_manager_get_state
(
manager
)
==
CALLS_MANAGER_STATE_NO_PROVIDER
);
g_assert_null
(
calls_manager_get_origins
(
manager
));
g_assert_null
(
calls_manager_get_calls
(
manager
));
g_assert_null
(
calls_manager_get_default_origin
(
manager
));
}
static
void
test_calls_manager_dummy_provider
()
{
g_autoptr
(
CallsManager
)
manager
=
calls_manager_new
();
g_autoptr
(
GList
)
origins
=
NULL
;
gint
no_origins
=
0
;
CallsOrigin
*
origin
;
g_assert
(
CALLS_IS_MANAGER
(
manager
));
origin_count
=
0
;
g_signal_connect
(
manager
,
"origin-remove"
,
G_CALLBACK
(
origin_remove_cb
),
NULL
);
g_signal_connect
(
manager
,
"origin-add"
,
G_CALLBACK
(
origin_add_cb
),
NULL
);
g_assert_null
(
calls_manager_get_provider
(
manager
));
g_assert
(
calls_manager_get_state
(
manager
)
==
CALLS_MANAGER_STATE_NO_PROVIDER
);
calls_manager_set_provider
(
manager
,
"dummy"
);
g_assert_cmpstr
(
calls_manager_get_provider
(
manager
),
==
,
"dummy"
);
g_assert
(
calls_manager_get_state
(
manager
)
==
CALLS_MANAGER_STATE_READY
);
origins
=
calls_manager_get_origins
(
manager
);
no_origins
=
g_list_length
(
origins
);
g_assert_cmpint
(
origin_count
,
==
,
no_origins
);
g_assert_nonnull
(
calls_manager_get_origins
(
manager
));
g_assert_null
(
calls_manager_get_calls
(
manager
));
g_assert_null
(
calls_manager_get_default_origin
(
manager
));
test_call
=
NULL
;
if
(
no_origins
>
0
)
{
g_signal_connect
(
manager
,
"call-add"
,
G_CALLBACK
(
call_add_cb
),
NULL
);
g_signal_connect
(
manager
,
"call-remove"
,
G_CALLBACK
(
call_remove_cb
),
NULL
);
origin
=
CALLS_ORIGIN
(
g_list_first
(
origins
)
->
data
);
g_assert
(
CALLS_IS_ORIGIN
(
origin
));
calls_manager_set_default_origin
(
manager
,
origin
);
g_assert
(
calls_manager_get_default_origin
(
manager
)
==
origin
);
calls_origin_dial
(
origin
,
"+393422342"
);
g_assert
(
CALLS_IS_CALL
(
test_call
));
calls_call_hang_up
(
test_call
);
g_assert_null
(
test_call
);
/* Add new call do check if we remove it when we unload the provider */
calls_origin_dial
(
origin
,
"+393422342"
);
}
/* Unload the provider */
calls_manager_set_provider
(
manager
,
NULL
);
g_assert_cmpint
(
origin_count
,
==
,
0
);
g_assert_null
(
test_call
);
g_assert
(
calls_manager_get_state
(
manager
)
==
CALLS_MANAGER_STATE_NO_PROVIDER
);
}
static
void
test_calls_manager_mm_provider
()
{
g_autoptr
(
CallsManager
)
manager
=
calls_manager_new
();
g_assert
(
CALLS_IS_MANAGER
(
manager
));
g_assert_null
(
calls_manager_get_provider
(
manager
));
g_assert
(
calls_manager_get_state
(
manager
)
==
CALLS_MANAGER_STATE_NO_PROVIDER
);
calls_manager_set_provider
(
manager
,
"mm"
);
g_assert_cmpstr
(
calls_manager_get_provider
(
manager
),
==
,
"mm"
);
g_assert
(
calls_manager_get_state
(
manager
)
>
CALLS_MANAGER_STATE_NO_PROVIDER
);
g_assert_null
(
calls_manager_get_calls
(
manager
));
g_assert_null
(
calls_manager_get_default_origin
(
manager
));
calls_manager_set_provider
(
manager
,
NULL
);
g_assert
(
calls_manager_get_state
(
manager
)
==
CALLS_MANAGER_STATE_NO_PROVIDER
);
}
gint
main
(
gint
argc
,
gchar
*
argv
[])
{
gtk_test_init
(
&
argc
,
&
argv
,
NULL
);
/* Add builddir as search path */
#ifdef PLUGIN_BUILDDIR
peas_engine_add_search_path
(
peas_engine_get_default
(),
PLUGIN_BUILDDIR
,
NULL
);
#endif
g_test_add_func
(
"/Calls/Manager/without_provider"
,
test_calls_manager_without_provider
);
g_test_add_func
(
"/Calls/Manager/dummy_provider"
,
test_calls_manager_dummy_provider
);
g_test_add_func
(
"/Calls/Manager/mm_provider"
,
test_calls_manager_mm_provider
);
return
g_test_run
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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