[gnome-software] Initialize progress to zero right before and after processing and action
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Initialize progress to zero right before and after processing and action
- Date: Thu, 23 Feb 2017 16:07:09 +0000 (UTC)
commit 89b5dcde7fec0ef046f967c3d1e77d8039d9334c
Author: Mario Sanchez Prada <mario endlessm com>
Date: Thu Feb 23 14:35:52 2017 +0000
Initialize progress to zero right before and after processing and action
This will make sure that, even after a successful installation, the
progress bar is reset to zero, to prevent confusion in the unlikely
event of the user going for a install + uninstall + reinstall process.
src/gs-plugin-loader.c | 7 +++++++
src/gs-self-test.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 430ecb8..700ad3f 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -1190,6 +1190,9 @@ gs_plugin_loader_run_action (GsPluginLoaderJob *job,
{
GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (job->plugin_loader);
+ /* make sure the progress is properly initialized */
+ gs_app_set_progress (job->app, 0);
+
/* run each plugin */
for (guint i = 0; i < priv->plugins->len; i++) {
GsPlugin *plugin = g_ptr_array_index (priv->plugins, i);
@@ -2602,6 +2605,10 @@ gs_plugin_loader_app_action_thread_cb (GTask *task,
/* perform action */
if (gs_plugin_loader_run_action (job, cancellable, &error)) {
g_autoptr(GsPluginLoaderJob) job2 = NULL;
+
+ /* reset the progress after successful operations */
+ gs_app_set_progress (job->app, 0);
+
/* unstage addons */
addons = gs_app_get_addons (job->app);
for (i = 0; i < addons->len; i++) {
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index b6cb01a..aae70c4 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -1152,6 +1152,7 @@ gs_plugin_loader_flatpak_repo_func (GsPluginLoader *plugin_loader)
g_assert_no_error (error);
g_assert (ret);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
+ g_assert_cmpint (gs_app_get_progress (app), ==, 0);
}
static void
@@ -1299,6 +1300,7 @@ gs_plugin_loader_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
g_assert (ret);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_INSTALLED);
g_assert_cmpstr (gs_app_get_version (app), ==, "1.2.3");
+ g_assert_cmpint (gs_app_get_progress (app), ==, 0);
/* check the application exists in the right places */
metadata_fn = g_build_filename (root,
@@ -1350,6 +1352,35 @@ gs_plugin_loader_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
g_assert (!g_file_test (metadata_fn, G_FILE_TEST_IS_REGULAR));
g_assert (!g_file_test (desktop_fn, G_FILE_TEST_IS_REGULAR));
+ /* install again, to check whether the progress gets initialized */
+ ret = gs_plugin_loader_app_action (plugin_loader, app,
+ GS_PLUGIN_ACTION_INSTALL,
+ GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
+ NULL,
+ &error);
+
+ /* progress should be set to zero right before installing */
+ g_assert_cmpint (gs_app_get_progress (app), ==, 0);
+
+ gs_test_flush_main_context ();
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_INSTALLED);
+ g_assert_cmpstr (gs_app_get_version (app), ==, "1.2.3");
+ g_assert_cmpint (gs_app_get_progress (app), ==, 0);
+
+ /* remove the application */
+ ret = gs_plugin_loader_app_action (plugin_loader, app,
+ GS_PLUGIN_ACTION_REMOVE,
+ GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
+ g_assert (!g_file_test (metadata_fn, G_FILE_TEST_IS_REGULAR));
+ g_assert (!g_file_test (desktop_fn, G_FILE_TEST_IS_REGULAR));
+
/* remove the remote (fail, as the runtime is still installed) */
ret = gs_plugin_loader_app_action (plugin_loader, app_source,
GS_PLUGIN_ACTION_REMOVE,
@@ -1472,6 +1503,7 @@ gs_plugin_loader_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader
g_assert (!ret);
g_clear_error (&error);
g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE);
+ g_assert_cmpint (gs_app_get_progress (app), ==, 0);
/* remove the remote */
ret = gs_plugin_loader_app_action (plugin_loader, app_source,
@@ -1621,6 +1653,7 @@ gs_plugin_loader_flatpak_app_update_func (GsPluginLoader *plugin_loader)
g_assert_cmpstr (gs_app_get_version (app), ==, "1.2.3");
g_assert_cmpstr (gs_app_get_update_version (app), ==, NULL);
g_assert_cmpstr (gs_app_get_update_details (app), ==, NULL);
+ g_assert_cmpint (gs_app_get_progress (app), ==, 0);
/* switch to the new repo */
g_assert (unlink ("/var/tmp/self-test/repo") == 0);
@@ -1685,6 +1718,7 @@ gs_plugin_loader_flatpak_app_update_func (GsPluginLoader *plugin_loader)
g_assert_cmpstr (gs_app_get_version (app), ==, "1.2.4");
g_assert_cmpstr (gs_app_get_update_version (app), ==, NULL);
g_assert_cmpstr (gs_app_get_update_details (app), ==, NULL);
+ g_assert_cmpint (gs_app_get_progress (app), ==, 0);
g_assert (got_progress_installing);
//g_assert_cmpint (progress_cnt, >, 20); //FIXME: bug in OSTree
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]