[gnome-software] Add self test for the fwupd plugin
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add self test for the fwupd plugin
- Date: Fri, 29 Apr 2016 10:03:32 +0000 (UTC)
commit c79f09902f7b706c2841de6b6d5bc01b2f80169d
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 28 18:57:47 2016 +0100
Add self test for the fwupd plugin
data/tests/build-cab.sh | 4 +++
data/tests/chiron-0.2.cab | Bin 0 -> 34376 bytes
data/tests/firmware.dfu | Bin 0 -> 32784 bytes
data/tests/firmware.dfu.asc | 11 +++++++++
data/tests/firmware.metainfo.xml | 30 ++++++++++++++++++++++++
src/gs-self-test.c | 47 ++++++++++++++++++++++++++++++++++++++
src/plugins/gs-plugin-fwupd.c | 11 +++++++++
7 files changed, 103 insertions(+), 0 deletions(-)
---
diff --git a/data/tests/build-cab.sh b/data/tests/build-cab.sh
new file mode 100755
index 0000000..ea7bed6
--- /dev/null
+++ b/data/tests/build-cab.sh
@@ -0,0 +1,4 @@
+gcab --create chiron-0.2.cab \
+ firmware.dfu \
+ firmware.dfu.asc \
+ firmware.metainfo.xml
diff --git a/data/tests/chiron-0.2.cab b/data/tests/chiron-0.2.cab
new file mode 100644
index 0000000..6618361
Binary files /dev/null and b/data/tests/chiron-0.2.cab differ
diff --git a/data/tests/firmware.dfu b/data/tests/firmware.dfu
new file mode 100644
index 0000000..50f00c0
Binary files /dev/null and b/data/tests/firmware.dfu differ
diff --git a/data/tests/firmware.dfu.asc b/data/tests/firmware.dfu.asc
new file mode 100644
index 0000000..0ea79a7
--- /dev/null
+++ b/data/tests/firmware.dfu.asc
@@ -0,0 +1,11 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2.0.14 (GNU/Linux)
+
+iQEcBAABAgAGBQJWUy6EAAoJEEim2A5FOLrCxokIAJJtLVkuXZHgEu2C2Eq9jGrR
+FZ9/z9XtsMgs33teLdmYUAQwvnNIbtIb6z7JViP8llCREP8y2fH+1OjrOOdtuS/A
+bIJ0r40c9wYeH97ZcXBdHZiYVEFO+etbMBUg5ifuRO5VPjD9H1NqL05Wx9kUg/1T
+a1fwgHopXR0T4jYcg5aijp3mdgfmg4boIklDaRV/g2c93W+0VhDZ2h5sKwBxxlFS
+TrptclTMCvRYmVvL1CDOsBtgzu3jGo03wV9rcnSKzeBWvINcvlRLdS0ejlPaRYDK
+MUY4MBVz3fDW1vFsqLpU80XMOYk0bxtQqQ2MsrlXWp9qazB+A6mC7kOnJQfx0yI=
+=A3W8
+-----END PGP SIGNATURE-----
diff --git a/data/tests/firmware.metainfo.xml b/data/tests/firmware.metainfo.xml
new file mode 100644
index 0000000..d942fd8
--- /dev/null
+++ b/data/tests/firmware.metainfo.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2016 Richard Hughes <richard hughsie com> -->
+<component type="firmware">
+ <id>com.test.chiron.firmware</id>
+ <name>Chiron</name>
+ <summary>Single line synopsis</summary>
+ <description>
+ <p>
+ This is the first paragraph in the example cab file.
+ </p>
+ <p>
+ This is the second paragraph.
+ </p>
+ </description>
+ <provides>
+ <firmware type="flashed">fd9f37b4-36fb-5245-86a8-4d5993bb153b</firmware>
+ </provides>
+ <url type="homepage">http://127.0.0.1/</url>
+ <metadata_license>CC0-1.0</metadata_license>
+ <project_license>GPL-2.0+</project_license>
+ <developer_name>ACME Corp</developer_name>
+ <releases>
+ <release urgency="medium" version="0.2" timestamp="1447353015">
+ <checksum target="content" filename="firmware.dfu"/>
+ <description>
+ <p>Latest firmware release.</p>
+ </description>
+ </release>
+ </releases>
+</component>
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index f634308..c40450a 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -522,6 +522,49 @@ gs_plugin_loader_packagekit_local_func (GsPluginLoader *plugin_loader)
"package spec file. This is the second paragraph.");
}
+static void
+gs_plugin_loader_fwupd_func (GsPluginLoader *plugin_loader)
+{
+ g_autoptr(GsApp) app = NULL;
+ g_autoptr(GError) error = NULL;
+ g_autofree gchar *fn = NULL;
+ g_autoptr(GFile) file = NULL;
+
+ /* no dpkg, abort */
+ if (!gs_plugin_loader_get_enabled (plugin_loader, "fwupd"))
+ return;
+
+ /* load local file */
+ fn = gs_test_get_filename ("tests/chiron-0.2.cab");
+ g_assert (fn != NULL);
+ file = g_file_new_for_path (fn);
+ app = gs_plugin_loader_file_to_app (plugin_loader,
+ file,
+ GS_PLUGIN_REFINE_FLAGS_DEFAULT,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (app != NULL);
+ g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_FIRMWARE);
+ g_assert (gs_app_get_pixbuf (app) != NULL);
+ g_assert (gs_app_get_license (app) != NULL);
+ g_assert (gs_app_has_category (app, "System"));
+ g_assert_cmpstr (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE), ==, "http://127.0.0.1/");
+ g_assert_cmpstr (gs_app_get_name (app), ==, "Chiron");
+ g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
+ g_assert_cmpstr (gs_app_get_version (app), ==, "0.2");
+ g_assert_cmpint (gs_app_get_size_download (app), ==, 32784);
+ g_assert_cmpstr (gs_app_get_description (app), ==,
+ "This is the first paragraph in the example "
+ "cab file.\n\nThis is the second paragraph.");
+ g_assert_cmpstr (gs_app_get_update_details (app), ==,
+ "Latest firmware release.");
+
+ /* seems wrong, but this is only set if the update is available */
+ g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_UNKNOWN);
+ g_assert_cmpstr (gs_app_get_id (app), ==, NULL);
+}
+
int
main (int argc, char **argv)
{
@@ -535,6 +578,7 @@ main (int argc, char **argv)
"dpkg",
"dummy",
"epiphany",
+ "fwupd",
"hardcoded-blacklist",
"icons",
"menu-spec-refine",
@@ -628,6 +672,9 @@ main (int argc, char **argv)
g_assert (gs_plugin_loader_get_enabled (plugin_loader, "dummy"));
/* plugin tests go here */
+ g_test_add_data_func ("/gnome-software/plugin-loader{fwupd}",
+ plugin_loader,
+ (GTestDataFunc) gs_plugin_loader_fwupd_func);
g_test_add_data_func ("/gnome-software/plugin-loader{key-colors}",
plugin_loader,
(GTestDataFunc) gs_plugin_loader_key_colors_func);
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 4625ac4..43aa785 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -261,6 +261,10 @@ gs_plugin_fwupd_new_app_from_results (FwupdResult *res)
gs_app_set_summary (app, GS_APP_QUALITY_NORMAL,
fwupd_result_get_update_summary (res));
}
+ if (fwupd_result_get_update_homepage (res) != NULL) {
+ gs_app_set_url (app, AS_URL_KIND_HOMEPAGE,
+ fwupd_result_get_update_homepage (res));
+ }
if (fwupd_result_get_device_version (res) != NULL) {
gs_app_set_version (app, fwupd_result_get_device_version (res));
}
@@ -278,6 +282,13 @@ gs_plugin_fwupd_new_app_from_results (FwupdResult *res)
gs_app_set_license (app, GS_APP_QUALITY_NORMAL,
fwupd_result_get_update_license (res));
}
+ if (fwupd_result_get_device_description (res) != NULL) {
+ g_autofree gchar *tmp = NULL;
+ tmp = as_markup_convert (fwupd_result_get_device_description (res),
+ AS_MARKUP_CONVERT_FORMAT_SIMPLE, NULL);
+ if (tmp != NULL)
+ gs_app_set_description (app, GS_APP_QUALITY_NORMAL, tmp);
+ }
if (fwupd_result_get_update_description (res) != NULL) {
g_autofree gchar *tmp = NULL;
tmp = as_markup_convert (fwupd_result_get_update_description (res),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]