From 1a85eb2ce73907d4f9b11a05efbc3f5c2c77e82a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 15:13:29 -0600 Subject: Create a testing desktop file --- tests/keyfile-well-formed.desktop | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/keyfile-well-formed.desktop (limited to 'tests') diff --git a/tests/keyfile-well-formed.desktop b/tests/keyfile-well-formed.desktop new file mode 100644 index 0000000..fc906a3 --- /dev/null +++ b/tests/keyfile-well-formed.desktop @@ -0,0 +1,20 @@ +[Desktop Entry] +Name=My Application +Exec=ls +NotShowIn=Germany +X-Ayatana-Desktop-Shortcuts=bob;alvin;jim + +[bob Shortcut Group] +Name=Bob's shortcut +Exec=ls bob + +[alvin Shortcut Group] +Name=Alivin's shortcut +Exec=ls alvin +OnlyShowIn=France + +[jim Shortcut Group] +Name=Jim's shortcut +Exec=ls jim +NotShowIn=France + -- cgit v1.2.3 From 53c9f60b7438764853c54d977a37b267bdf64485 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 15:24:51 -0600 Subject: Adding in a basic test desktop file test --- tests/Makefile.am | 35 +++++++++++++++++++++++++++++++++++ tests/test-desktop-shortcuts.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/test-desktop-shortcuts.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index b111655..ab776a9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,41 @@ test_loader_LDADD = \ -L$(top_builddir)/libindicator/.libs \ -lindicator +############################# +# Test Desktop Shortcuts +############################# + +check_PROGRAMS += test-desktop-shortcuts + +test_desktop_shortcuts_SOURCES = \ + test-desktop-shortcuts.c + +test_desktop_shortcuts_CFLAGS = \ + -Wall -Werror \ + -DSRCDIR="\"$(srcdir)\"" \ + $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) \ + -DBUILD_DIR="\"$(builddir)\"" + +test_desktop_shortcuts_LDADD = \ + $(LIBINDICATOR_LIBS) \ + -L$(top_builddir)/libindicator/.libs \ + -lindicator + +DS_XML_REPORT = desktop-shortcuts-check-results.xml +DS_HTML_REPORT = desktop-shortcuts-check-results.html + +test-desktop-shortcuts-tester: test-desktop-shortcuts Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo gtester -k --verbose -o=$(XML_REPORT) ./test-desktop-shortcuts >> $@ + @chmod +x $@ + +TESTS += test-desktop-shortcuts-tester +DISTCLEANFILES += test-desktop-shortcuts-tester \ + $(DS_XML_REPORT) + $(DS_HTML_REPORT) + + ############################# # Dummy Indicator Blank ############################# diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c new file mode 100644 index 0000000..3368c9e --- /dev/null +++ b/tests/test-desktop-shortcuts.c @@ -0,0 +1,38 @@ +#include +#include "libindicator/indicator-desktop-shortcuts.h" + +void +test_desktop_shortcuts_creation (void) +{ + + IndicatorDesktopShortcuts * ids = indicator_desktop_shortcuts_new(SRCDIR "/test-well-formed.desktop", "France"); + g_assert(ids != NULL); + + g_object_add_weak_pointer(G_OBJECT(ids), (gpointer *)&ids); + g_object_unref(G_OBJECT(ids)); + + g_assert(ids == NULL); + return; +} + +void +test_desktop_shortcuts_suite (void) +{ + g_test_add_func ("/libindicator/desktopshortcuts/creation", test_desktop_shortcuts_creation); + + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init (); + g_test_init (&argc, &argv, NULL); + gtk_init(&argc, &argv); + + test_desktop_shortcuts_suite(); + + g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); + + return g_test_run(); +} -- cgit v1.2.3 From 0a4d6689dccccc0556c4ec811e2783442a97fae9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 15:26:03 -0600 Subject: A backslash off --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index ab776a9..c7c9a1d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -64,7 +64,7 @@ test-desktop-shortcuts-tester: test-desktop-shortcuts Makefile.am TESTS += test-desktop-shortcuts-tester DISTCLEANFILES += test-desktop-shortcuts-tester \ - $(DS_XML_REPORT) + $(DS_XML_REPORT) \ $(DS_HTML_REPORT) -- cgit v1.2.3 From 755e697c2ba60010ea0fde875047a98c4f759513 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 15:27:18 -0600 Subject: Better name --- tests/keyfile-well-formed.desktop | 20 -------------------- tests/test-well-formed.desktop | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 tests/keyfile-well-formed.desktop create mode 100644 tests/test-well-formed.desktop (limited to 'tests') diff --git a/tests/keyfile-well-formed.desktop b/tests/keyfile-well-formed.desktop deleted file mode 100644 index fc906a3..0000000 --- a/tests/keyfile-well-formed.desktop +++ /dev/null @@ -1,20 +0,0 @@ -[Desktop Entry] -Name=My Application -Exec=ls -NotShowIn=Germany -X-Ayatana-Desktop-Shortcuts=bob;alvin;jim - -[bob Shortcut Group] -Name=Bob's shortcut -Exec=ls bob - -[alvin Shortcut Group] -Name=Alivin's shortcut -Exec=ls alvin -OnlyShowIn=France - -[jim Shortcut Group] -Name=Jim's shortcut -Exec=ls jim -NotShowIn=France - diff --git a/tests/test-well-formed.desktop b/tests/test-well-formed.desktop new file mode 100644 index 0000000..fc906a3 --- /dev/null +++ b/tests/test-well-formed.desktop @@ -0,0 +1,20 @@ +[Desktop Entry] +Name=My Application +Exec=ls +NotShowIn=Germany +X-Ayatana-Desktop-Shortcuts=bob;alvin;jim + +[bob Shortcut Group] +Name=Bob's shortcut +Exec=ls bob + +[alvin Shortcut Group] +Name=Alivin's shortcut +Exec=ls alvin +OnlyShowIn=France + +[jim Shortcut Group] +Name=Jim's shortcut +Exec=ls jim +NotShowIn=France + -- cgit v1.2.3 From edaa80e3a3fe85b11cb193179e7e7f5b1e9d310a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 21:16:02 -0600 Subject: Check to ensure a global no show works. --- tests/test-desktop-shortcuts.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index 3368c9e..621721b 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -15,10 +15,26 @@ test_desktop_shortcuts_creation (void) return; } +void +test_desktop_shortcuts_globalnoshow (void) +{ + + IndicatorDesktopShortcuts * ids = indicator_desktop_shortcuts_new(SRCDIR "/test-well-formed.desktop", "Germany"); + g_assert(ids != NULL); + + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(ids); + g_assert(nicks[0] == NULL); + + g_object_unref(ids); + + return; +} + void test_desktop_shortcuts_suite (void) { - g_test_add_func ("/libindicator/desktopshortcuts/creation", test_desktop_shortcuts_creation); + g_test_add_func ("/libindicator/desktopshortcuts/creation", test_desktop_shortcuts_creation); + g_test_add_func ("/libindicator/desktopshortcuts/globalnosho", test_desktop_shortcuts_globalnoshow); return; } -- cgit v1.2.3 From b6b2a65e651701650c2dbd6b99b5c44ec2dfb534 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 21:23:59 -0600 Subject: Adding in local filter test functions. --- tests/test-desktop-shortcuts.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index 621721b..6dab100 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -1,6 +1,8 @@ #include #include "libindicator/indicator-desktop-shortcuts.h" +/* Basic object creation and destruction. Stop big + f*** ups here. */ void test_desktop_shortcuts_creation (void) { @@ -15,6 +17,8 @@ test_desktop_shortcuts_creation (void) return; } +/* Tests that the NotShowIn the desktop group is watched + for */ void test_desktop_shortcuts_globalnoshow (void) { @@ -30,11 +34,40 @@ test_desktop_shortcuts_globalnoshow (void) return; } +gboolean +nicks_contains (const gchar ** nicks, const gchar * search) +{ + if (nicks[0] == NULL) + return FALSE; + if (g_strcmp0(nicks[0], search) == 0) + return TRUE; + return nicks_contains(&nicks[1], search); +} + +/* Checking that the local show OnlyIn works. */ +void +test_desktop_shortcuts_localfilter (void) +{ + IndicatorDesktopShortcuts * ids = indicator_desktop_shortcuts_new(SRCDIR "/test-well-formed.desktop", "France"); + g_assert(ids != NULL); + + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(ids); + + g_assert(nicks_contains(nicks, "bob")); + g_assert(nicks_contains(nicks, "alvin")); + g_assert(!nicks_contains(nicks, "jim")); + + g_object_unref(ids); + + return; +} + void test_desktop_shortcuts_suite (void) { g_test_add_func ("/libindicator/desktopshortcuts/creation", test_desktop_shortcuts_creation); g_test_add_func ("/libindicator/desktopshortcuts/globalnosho", test_desktop_shortcuts_globalnoshow); + g_test_add_func ("/libindicator/desktopshortcuts/localfilter", test_desktop_shortcuts_localfilter); return; } -- cgit v1.2.3 From e0bc1911d9618a2d8ac4d1d93de3e7f81d1a14ae Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 21:34:30 -0600 Subject: Adding a check to ensure we're getting the right names from the nicks. --- tests/test-desktop-shortcuts.c | 32 +++++++++++++++++++++++++++++++- tests/test-well-formed.desktop | 4 ++-- 2 files changed, 33 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index 6dab100..02137ef 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -62,12 +62,42 @@ test_desktop_shortcuts_localfilter (void) return; } +/* Nick names -- checks to see they all have names */ +void +test_desktop_shortcuts_nicknames (void) +{ + IndicatorDesktopShortcuts * ids = indicator_desktop_shortcuts_new(SRCDIR "/test-well-formed.desktop", "France"); + g_assert(ids != NULL); + + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(ids); + gint i = 0; + while (nicks[i] != NULL) { + gchar * expectedstr = g_strdup_printf("%s's shortcut", nicks[i]); + gchar * name = indicator_desktop_shortcuts_nick_get_name(ids, nicks[i]); + g_assert(name != NULL); + + gboolean same = (g_strcmp0(expectedstr, name) == 0); + + g_free(name); + g_free(expectedstr); + + g_assert(same); + + i++; + } + + + g_object_unref(ids); + + return; +} + void test_desktop_shortcuts_suite (void) { g_test_add_func ("/libindicator/desktopshortcuts/creation", test_desktop_shortcuts_creation); g_test_add_func ("/libindicator/desktopshortcuts/globalnosho", test_desktop_shortcuts_globalnoshow); - g_test_add_func ("/libindicator/desktopshortcuts/localfilter", test_desktop_shortcuts_localfilter); + g_test_add_func ("/libindicator/desktopshortcuts/nicknames", test_desktop_shortcuts_nicknames); return; } diff --git a/tests/test-well-formed.desktop b/tests/test-well-formed.desktop index fc906a3..dc2744f 100644 --- a/tests/test-well-formed.desktop +++ b/tests/test-well-formed.desktop @@ -5,11 +5,11 @@ NotShowIn=Germany X-Ayatana-Desktop-Shortcuts=bob;alvin;jim [bob Shortcut Group] -Name=Bob's shortcut +Name=bob's shortcut Exec=ls bob [alvin Shortcut Group] -Name=Alivin's shortcut +Name=alvin's shortcut Exec=ls alvin OnlyShowIn=France -- cgit v1.2.3 From af36cb86cf0cb671cd8521e66562341a2a015fd1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 21:40:50 -0600 Subject: Add a test to launch an nick --- tests/test-desktop-shortcuts.c | 20 ++++++++++++++++++++ tests/test-well-formed.desktop | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index 02137ef..7594e51 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -92,12 +92,32 @@ test_desktop_shortcuts_nicknames (void) return; } +/* Try executing a shortcut which will touch a file */ +void +test_desktop_shortcuts_launch (void) +{ + IndicatorDesktopShortcuts * ids = indicator_desktop_shortcuts_new(SRCDIR "/test-well-formed.desktop", "Touch"); + g_assert(ids != NULL); + + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(ids); + g_assert(nicks[0] != NULL); + + g_assert(indicator_desktop_shortcuts_nick_exec(ids, nicks[0])); + g_assert(g_file_test("test-desktop-shortcuts-touch-test", G_FILE_TEST_EXISTS)); + + g_object_unref(ids); + + return; +} + +/* Build our test suite */ void test_desktop_shortcuts_suite (void) { g_test_add_func ("/libindicator/desktopshortcuts/creation", test_desktop_shortcuts_creation); g_test_add_func ("/libindicator/desktopshortcuts/globalnosho", test_desktop_shortcuts_globalnoshow); g_test_add_func ("/libindicator/desktopshortcuts/nicknames", test_desktop_shortcuts_nicknames); + g_test_add_func ("/libindicator/desktopshortcuts/launch", test_desktop_shortcuts_launch); return; } diff --git a/tests/test-well-formed.desktop b/tests/test-well-formed.desktop index dc2744f..84e2e02 100644 --- a/tests/test-well-formed.desktop +++ b/tests/test-well-formed.desktop @@ -2,7 +2,7 @@ Name=My Application Exec=ls NotShowIn=Germany -X-Ayatana-Desktop-Shortcuts=bob;alvin;jim +X-Ayatana-Desktop-Shortcuts=bob;alvin;jim;touch [bob Shortcut Group] Name=bob's shortcut @@ -18,3 +18,7 @@ Name=Jim's shortcut Exec=ls jim NotShowIn=France +[touch Shortcut Group] +Name=Touch Test +Exec=touch test-desktop-shortcuts-touch-test +OnlyShowIn=TouchTest -- cgit v1.2.3 From b0e8d1c61b0558f67478e51dd680cd00f87baee2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 22:07:38 -0600 Subject: Wrong identity --- tests/test-desktop-shortcuts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index 7594e51..a7b57d3 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -96,7 +96,7 @@ test_desktop_shortcuts_nicknames (void) void test_desktop_shortcuts_launch (void) { - IndicatorDesktopShortcuts * ids = indicator_desktop_shortcuts_new(SRCDIR "/test-well-formed.desktop", "Touch"); + IndicatorDesktopShortcuts * ids = indicator_desktop_shortcuts_new(SRCDIR "/test-well-formed.desktop", "TouchTest"); g_assert(ids != NULL); const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(ids); -- cgit v1.2.3 From b10dd199a267842284f9baaf9e6e065ed9bad109 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 22:21:29 -0600 Subject: Using the nick directly to make this work better. --- tests/test-desktop-shortcuts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index a7b57d3..a4e767a 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -100,9 +100,9 @@ test_desktop_shortcuts_launch (void) g_assert(ids != NULL); const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(ids); - g_assert(nicks[0] != NULL); + g_assert(nicks != NULL); - g_assert(indicator_desktop_shortcuts_nick_exec(ids, nicks[0])); + g_assert(indicator_desktop_shortcuts_nick_exec(ids, "touch")); g_assert(g_file_test("test-desktop-shortcuts-touch-test", G_FILE_TEST_EXISTS)); g_object_unref(ids); -- cgit v1.2.3 From 0aa8119e4813f84d5c0f1a8001bce69518d1d756 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 22:35:03 -0600 Subject: Checking to ensure the right nick is in the list --- tests/test-desktop-shortcuts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index a4e767a..c2344db 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -100,7 +100,7 @@ test_desktop_shortcuts_launch (void) g_assert(ids != NULL); const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(ids); - g_assert(nicks != NULL); + g_assert(nicks_contains(nicks, "touch")); g_assert(indicator_desktop_shortcuts_nick_exec(ids, "touch")); g_assert(g_file_test("test-desktop-shortcuts-touch-test", G_FILE_TEST_EXISTS)); -- cgit v1.2.3 From 7e69f61eb09bc73067a4cf963b2fe4c44bf936a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 22:39:45 -0600 Subject: Clean up touch file --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index c7c9a1d..1f000bd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -64,6 +64,7 @@ test-desktop-shortcuts-tester: test-desktop-shortcuts Makefile.am TESTS += test-desktop-shortcuts-tester DISTCLEANFILES += test-desktop-shortcuts-tester \ + test-desktop-shortcuts-touch-test \ $(DS_XML_REPORT) \ $(DS_HTML_REPORT) -- cgit v1.2.3 From ef9c19ed6aec8a078a612a9e9b069934bf262b80 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 22:43:11 -0600 Subject: Shipping our test desktop file --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f000bd..cd1a958 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -67,7 +67,7 @@ DISTCLEANFILES += test-desktop-shortcuts-tester \ test-desktop-shortcuts-touch-test \ $(DS_XML_REPORT) \ $(DS_HTML_REPORT) - +EXTRA_DIST += test-well-formed.desktop ############################# # Dummy Indicator Blank -- cgit v1.2.3 From 1b58c66bcd65fa6fe7e59b62aa357cce38308fde Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 22:45:54 -0600 Subject: Being more specific about where we should find the touch file for distcheck --- tests/test-desktop-shortcuts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-desktop-shortcuts.c b/tests/test-desktop-shortcuts.c index c2344db..1a655f7 100644 --- a/tests/test-desktop-shortcuts.c +++ b/tests/test-desktop-shortcuts.c @@ -103,7 +103,7 @@ test_desktop_shortcuts_launch (void) g_assert(nicks_contains(nicks, "touch")); g_assert(indicator_desktop_shortcuts_nick_exec(ids, "touch")); - g_assert(g_file_test("test-desktop-shortcuts-touch-test", G_FILE_TEST_EXISTS)); + g_assert(g_file_test(BUILD_DIR "/test-desktop-shortcuts-touch-test", G_FILE_TEST_EXISTS)); g_object_unref(ids); -- cgit v1.2.3