[gnome-packagekit] trivial: Fix the self tests to actually compile



commit f61523c7eaf4699799a815e0d2bf2eca0123504a
Author: Richard Hughes <richard hughsie com>
Date:   Tue Dec 6 19:47:40 2016 +0000

    trivial: Fix the self tests to actually compile

 src/gpk-self-test.c |  178 ---------------------------------------------------
 1 files changed, 0 insertions(+), 178 deletions(-)
---
diff --git a/src/gpk-self-test.c b/src/gpk-self-test.c
index f513ab9..60a1923 100644
--- a/src/gpk-self-test.c
+++ b/src/gpk-self-test.c
@@ -27,44 +27,6 @@
 #include "gpk-error.h"
 #include "gpk-task.h"
 
-
-/** ver:1.0 ***********************************************************/
-static GMainLoop *_test_loop = NULL;
-static guint _test_loop_timeout_id = 0;
-
-static gboolean
-_g_test_hang_wait_cb (gpointer user_data)
-{
-       g_main_loop_quit (_test_loop);
-       _test_loop_timeout_id = 0;
-       return FALSE;
-}
-
-static void
-_g_test_loop_wait (guint timeout_ms)
-{
-       g_assert (_test_loop_timeout_id == 0);
-       _test_loop = g_main_loop_new (NULL, FALSE);
-       _test_loop_timeout_id = g_timeout_add (timeout_ms, _g_test_hang_wait_cb, &timeout_ms);
-       g_main_loop_run (_test_loop);
-}
-
-static void
-_g_test_loop_quit (void)
-{
-       if (_test_loop_timeout_id > 0) {
-               g_source_remove (_test_loop_timeout_id);
-               _test_loop_timeout_id = 0;
-       }
-       if (_test_loop != NULL) {
-               g_main_loop_quit (_test_loop);
-               g_main_loop_unref (_test_loop);
-               _test_loop = NULL;
-       }
-}
-
-/**********************************************************************/
-
 static void
 gpk_test_enum_func (void)
 {
@@ -182,78 +144,10 @@ gpk_test_enum_func (void)
 }
 
 static void
-gpk_test_error_func (void)
-{
-       gboolean ret;
-
-       /* do dialog */
-       ret = gpk_error_dialog ("No space is left on the disk",
-                               "There is insufficient space on the device.\n"
-                               "Free some space on the system disk to perform this operation.",
-                               "[Errno 28] No space left on device");
-       g_assert (ret);
-}
-
-static void
 gpk_test_common_func (void)
 {
        gchar *text;
 
-       /* time zero */
-       text = gpk_time_to_localised_string (0);
-       g_assert_cmpstr (text, ==, "Now");
-       g_free (text);
-
-       /* time 1s */
-       text = gpk_time_to_localised_string (1);
-       g_assert_cmpstr (text, ==, "1 second");
-       g_free (text);
-
-       /* time 1m */
-       text = gpk_time_to_localised_string (1*60);
-       g_assert_cmpstr (text, ==, "1 minute");
-       g_free (text);
-
-       /* time 1h */
-       text = gpk_time_to_localised_string (1*60*60);
-       g_assert_cmpstr (text, ==, "1 hour");
-       g_free (text);
-
-       /* time 30s */
-       text = gpk_time_to_localised_string (30);
-       g_assert_cmpstr (text, ==, "30 seconds");
-       g_free (text);
-
-       /* time 30m */
-       text = gpk_time_to_localised_string (30*60);
-       g_assert_cmpstr (text, ==, "30 minutes");
-       g_free (text);
-
-       /* time 30m1s */
-       text = gpk_time_to_localised_string (30*60+1);
-       g_assert_cmpstr (text, ==, "30 minutes 1 second");
-       g_free (text);
-
-       /* time 30m10s */
-       text = gpk_time_to_localised_string (30*60+10);
-       g_assert_cmpstr (text, ==, "30 minutes 10 seconds");
-       g_free (text);
-
-       /* imprecise time 1s */
-       text = gpk_time_to_imprecise_string (1);
-       g_assert_cmpstr (text, ==, "1 second");
-       g_free (text);
-
-       /* imprecise time 30m */
-       text = gpk_time_to_imprecise_string (30*60);
-       g_assert_cmpstr (text, ==, "30 minutes");
-       g_free (text);
-
-       /* imprecise time 30m10s */
-       text = gpk_time_to_imprecise_string (30*60+10);
-       g_assert_cmpstr (text, ==, "30 minutes");
-       g_free (text);
-
        /* package id pretty valid package id, no summary */
        text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;i386;data", NULL);
        g_assert_cmpstr (text, ==, "simon-0.0.1 (32-bit)");
@@ -275,73 +169,6 @@ gpk_test_common_func (void)
        g_free (text);
 }
 
-static void
-gpk_task_test_install_packages_cb (GObject *object, GAsyncResult *res, gpointer user_data)
-{
-       GpkTask *task = GPK_TASK (object);
-       g_autoptr(GError) error = NULL;
-       g_autoptr(PkResults) results = NULL;
-       g_autoptr(GPtrArray) packages = NULL;
-       g_autoptr(PkError) error_code = NULL;
-
-       /* get the results */
-       results = pk_task_generic_finish (PK_TASK(task), res, &error);
-       if (results == NULL) {
-               g_warning ("failed to resolve: %s", error->message);
-               goto out;
-       }
-
-       /* check error code */
-       error_code = pk_results_get_error_code (results);
-       if (error_code != NULL)
-               g_warning ("failed to resolve success: %s", pk_error_get_details (error_code));
-
-       packages = pk_results_get_package_array (results);
-       if (packages == NULL)
-               g_warning ("no packages!");
-
-       if (packages->len != 4)
-               g_warning ("invalid number of packages: %i", packages->len);
-out:
-       _g_test_loop_quit ();
-}
-
-static void
-gpk_task_test_progress_cb (PkProgress *progress, PkProgressType type, gpointer user_data)
-{
-       PkStatusEnum status;
-       if (type == PK_PROGRESS_TYPE_STATUS) {
-               g_object_get (progress,
-                             "status", &status,
-                             NULL);
-               g_debug ("now %s", pk_status_enum_to_string (status));
-       }
-}
-
-static void
-gpk_test_task_func (void)
-{
-       g_autoptr(GpkTask) task = NULL;
-       g_auto(GStrv) package_ids = NULL;
-
-       /* get task */
-       task = gpk_task_new ();
-       g_assert (task);
-
-       /* For testing, you will need to manually do:
-       pkcon repo-set-data dummy use-gpg 1
-       pkcon repo-set-data dummy use-eula 1
-       pkcon repo-set-data dummy use-media 1
-       */
-
-       /* install package */
-       package_ids = pk_package_ids_from_id ("vips-doc;7.12.4-2.fc8;noarch;linva");
-       pk_task_install_packages_async (PK_TASK(task), package_ids, NULL,
-                                       (PkProgressCallback) gpk_task_test_progress_cb, NULL,
-                                       (GAsyncReadyCallback) gpk_task_test_install_packages_cb, NULL);
-       _g_test_loop_wait (150000);
-}
-
 int
 main (int argc, char **argv)
 {
@@ -350,11 +177,6 @@ main (int argc, char **argv)
 
        g_test_add_func ("/gnome-packagekit/enum", gpk_test_enum_func);
        g_test_add_func ("/gnome-packagekit/common", gpk_test_common_func);
-       g_test_add_func ("/gnome-packagekit/markdown", gpk_test_markdown_func);
-       if (g_test_thorough ()) {
-               g_test_add_func ("/gnome-packagekit/error", gpk_test_error_func);
-               g_test_add_func ("/gnome-packagekit/task", gpk_test_task_func);
-       }
 
        return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]