[totem/wip/hadess/lang-menus: 6/6] tests: Add a test for the language menu items
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem/wip/hadess/lang-menus: 6/6] tests: Add a test for the language menu items
- Date: Sat, 16 Feb 2019 17:59:55 +0000 (UTC)
commit 972153c214f2f3b2ac75b84751f271ec5652a138
Author: Bastien Nocera <hadess hadess net>
Date: Sat Feb 16 18:53:42 2019 +0100
tests: Add a test for the language menu items
To make sure that the display of language names and codecs never
regresses.
src/meson.build | 10 +++++++
src/test-totem.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/totem-menu.c | 2 +-
src/totem-menu.h | 3 +++
4 files changed, 94 insertions(+), 1 deletion(-)
---
diff --git a/src/meson.build b/src/meson.build
index 3c9e7310c..59e05be7d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -298,4 +298,14 @@ if have_gir
)
endif
+tests = [ 'test-totem' ]
+
+foreach test_name : tests
+ exe = executable(test_name, '@0@.c'.format(test_name),
+ include_directories: [src_inc, top_inc],
+ dependencies: libtotem_dep)
+
+ test(test_name, exe)
+endforeach
+
subdir('plugins')
diff --git a/src/test-totem.c b/src/test-totem.c
new file mode 100644
index 000000000..a56c10af2
--- /dev/null
+++ b/src/test-totem.c
@@ -0,0 +1,80 @@
+#include "config.h"
+
+#include <locale.h>
+#define GST_USE_UNSTABLE_API 1
+#include <gst/tag/tag.h>
+
+#include "backend/bacon-video-widget.h"
+#include "totem-menu.h"
+
+static BvwLangInfo *
+bvw_lang_info_new (const char *language,
+ const char *codec)
+{
+ BvwLangInfo *info;
+
+ info = g_new0 (BvwLangInfo, 1);
+ info->language = g_strdup (language);
+ info->codec = g_strdup (codec);
+ return info;
+}
+
+static void
+test_menus_lang_info (void)
+{
+ GList *l, *ret;
+
+ /* Same language, same codecs */
+ l = NULL;
+ l = g_list_append (l, bvw_lang_info_new ("eng", "Dolby Pro Racing"));
+ l = g_list_append (l, bvw_lang_info_new ("eng", "Dolby Pro Racing"));
+ l = g_list_append (l, bvw_lang_info_new ("fre", "Dolby Amateur 5.1"));
+
+ ret = bvw_lang_info_to_menu_labels (l);
+ g_list_free_full (l, (GDestroyNotify) bacon_video_widget_lang_info_free);
+
+ g_assert_cmpstr (g_list_nth_data (ret, 0), ==, "English #1");
+ g_assert_cmpstr (g_list_nth_data (ret, 1), ==, "English #2");
+ g_assert_cmpstr (g_list_nth_data (ret, 2), ==, "French");
+ g_list_free_full (ret, g_free);
+
+ /* Same language, different codecs */
+ l = NULL;
+ l = g_list_append (l, bvw_lang_info_new ("eng", "Dolby Pro Racing"));
+ l = g_list_append (l, bvw_lang_info_new ("eng", "Dolby Amateur 5.1"));
+ l = g_list_append (l, bvw_lang_info_new ("fre", "Dolby Amateur 5.1"));
+
+ ret = bvw_lang_info_to_menu_labels (l);
+ g_list_free_full (l, (GDestroyNotify) bacon_video_widget_lang_info_free);
+
+ g_assert_cmpstr (g_list_nth_data (ret, 0), ==, "English — Dolby Pro Racing");
+ g_assert_cmpstr (g_list_nth_data (ret, 1), ==, "English — Dolby Amateur 5.1");
+ g_assert_cmpstr (g_list_nth_data (ret, 2), ==, "French");
+ g_list_free_full (ret, g_free);
+
+ /* Different languages */
+ l = NULL;
+ l = g_list_append (l, bvw_lang_info_new ("eng", "Dolby Amateur 5.1"));
+ l = g_list_append (l, bvw_lang_info_new ("spa", "Dolby Amateur 5.1"));
+ l = g_list_append (l, bvw_lang_info_new ("fre", "Dolby Amateur 5.1"));
+
+ ret = bvw_lang_info_to_menu_labels (l);
+ g_list_free_full (l, (GDestroyNotify) bacon_video_widget_lang_info_free);
+
+ g_assert_cmpstr (g_list_nth_data (ret, 0), ==, "English");
+ g_assert_cmpstr (g_list_nth_data (ret, 1), ==, "Spanish; Castilian");
+ g_assert_cmpstr (g_list_nth_data (ret, 2), ==, "French");
+ g_list_free_full (ret, g_free);
+}
+
+int main (int argc, char **argv)
+{
+ setlocale (LC_ALL, "en_GB.UTF-8");
+
+ g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=");
+
+ g_test_add_func ("/menus/lang_info", test_menus_lang_info);
+
+ return g_test_run ();
+}
diff --git a/src/totem-menu.c b/src/totem-menu.c
index e4145c02e..4570659e7 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -401,7 +401,7 @@ get_language_name_no_und (const char *lang)
return gst_tag_get_language_name (lang);
}
-static GList *
+GList *
bvw_lang_info_to_menu_labels (GList *langs)
{
GList *l, *ret;
diff --git a/src/totem-menu.h b/src/totem-menu.h
index 251c69286..bf13159e5 100644
--- a/src/totem-menu.h
+++ b/src/totem-menu.h
@@ -33,6 +33,9 @@ void totem_app_actions_setup (Totem *totem);
void totem_sublang_update (Totem *totem);
void totem_sublang_exit (Totem *totem);
+/* For test use only */
+GList *bvw_lang_info_to_menu_labels (GList *langs);
+
G_END_DECLS
#endif /* TOTEM_MENU_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]